Merge remote-tracking branch 'origin/update-flake'

This commit is contained in:
Charlotte 🦝 Delenk 2023-03-10 16:18:44 +01:00
commit f3d9bdd3aa
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
22 changed files with 1059 additions and 1164 deletions

View file

@ -1,9 +1,9 @@
{
"url": "https://akkoma.dev/AkkomaGang/akkoma.git",
"rev": "45a11aa20ff9dd1909ec5bee54abcafbf50f4c6f",
"date": "2023-02-26T22:12:31+00:00",
"path": "/nix/store/3795087ic182ps0m83an5w9v883nqjvb-akkoma",
"sha256": "1y318qh5jmjhkbn2d2jpv7s4ajbfmam9b7ccgm74kdrjk31q15jr",
"rev": "08dfce98bebcfa308660b726c24b5c8d410ecb70",
"date": "2023-03-10T03:51:45+00:00",
"path": "/nix/store/bgkri1p0srfc4jp7rp92s2l3dyjv7j49-akkoma",
"sha256": "1jkf4h41rsraqm5zycf6qc8gs9994jm25wp4kgm45nf47gpzpnph",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,

View file

@ -1,9 +1,9 @@
{
"url": "https://git.chir.rs/darkkirb/lotte-art",
"rev": "fd8cd46d350e545ef97aaca58e2ed3ae8132a051",
"date": "2022-12-28T11:09:15+01:00",
"path": "/nix/store/ayrc1zrk8ydb2rqk9md58a1idgbbsxw2-lotte-art",
"sha256": "1l5ah914hn1fq91dfq5dnl16nnd53fqmcmwc70g01vbpx6zkc7ds",
"rev": "e74de60ac2c296a3afab5bd34a53a0e6e43f3d6b",
"date": "2023-03-09T11:09:25+01:00",
"path": "/nix/store/g73hsilzzf059s01brh0pcciixskgx5z-lotte-art",
"sha256": "1qmym782rjmd22ak0xly1vfrwhsrdddgwan2idlcq5ygjwfvqazx",
"fetchLFS": true,
"fetchSubmodules": false,
"deepClone": false,

View file

@ -11,6 +11,10 @@
input = "attic";
inherit (pkgs) system;
};
mautrix-cleanup' = lib.importFlake {
input = "mautrix-cleanup";
inherit (pkgs) system;
};
in rec {
# The `lib`, `modules`, and `overlay` names are special
inherit lib;
@ -60,11 +64,11 @@ in rec {
plover-dict-didoesdigital = pkgs.callPackage ./plover/didoesdigital-dictionary.nix {};
miifox-net = pkgs.python3Packages.callPackage ./web/miifox-net.nix {};
old-homepage = pkgs.callPackage ./web/old-homepage.nix {};
clean-s3-cache = pkgs.python3Packages.callPackage ./scripts/clean-s3-cache.nix {};
python-instagram = pkgs.python3Packages.callPackage ./python/instagram.nix {};
moa = pkgs.python3Packages.callPackage ./moa {};
inherit (attic'.defaultNix.packages.${pkgs.system}) attic attic-client attic-server;
vf2Kernel = pkgs.callPackage ./linux/vf2 {kernelPatches = [];};
vf2KernelPackages = pkgs.linuxPackagesFor vf2Kernel;
element-web = pkgs.callPackage ./matrix/element-web {};
mautrix-cleanup = mautrix-cleanup'.defaultNix.packages.${pkgs.system}.default;
}

View file

@ -7,15 +7,17 @@
"flake-utils": [
"flake-utils"
],
"nixpkgs": "nixpkgs",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1676581287,
"narHash": "sha256-a/6ClchROZ5PoLz0WK42mkAkUtJlMDbe5QyyZZ7bomc=",
"lastModified": 1678041467,
"narHash": "sha256-qqHbiN0ZfEuZ2guMAW5T011TqgrPqGqNWlHtd8AXtQA=",
"owner": "zhaofengli",
"repo": "attic",
"rev": "0bb3d001365a5d75947a7a713dfd06307b3934d4",
"rev": "1a3b6513b02202198bb497608d0cedc45119799b",
"type": "github"
},
"original": {
@ -41,17 +43,16 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1673405853,
"narHash": "sha256-6Nq9DuOo+gE2I8z5UZaKuumykz2xxZ9JGYmUthOuwSA=",
"lastModified": 1677892403,
"narHash": "sha256-/Wi0L1spSWLFj+UQxN3j0mPYMoc7ZoAujpUF/juFVII=",
"owner": "ipetkov",
"repo": "crane",
"rev": "b13963c8c18026aa694acd98d14f66d24666f70b",
"rev": "105e27adb70a9890986b6d543a67761cbc1964a2",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"rev": "b13963c8c18026aa694acd98d14f66d24666f70b",
"type": "github"
}
},
@ -89,32 +90,54 @@
},
"flake-utils": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"lastModified": 1677835344,
"narHash": "sha256-+SF1dfj02xAizhtY2/pEPyA0DP0pMvZZjC2aMyprYhA=",
"owner": "DarkKirb",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"rev": "17cffe5284b6da6b50cc82f4d2b4c3ff8185f83c",
"type": "github"
},
"original": {
"owner": "numtide",
"owner": "DarkKirb",
"repo": "flake-utils",
"type": "github"
}
},
"mautrix-cleanup": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1678395415,
"narHash": "sha256-l7upZ8y8SobYtv+RYD7DodRU74DGvDRjvaKfj8VmAow=",
"owner": "DarkKirb",
"repo": "mautrix-cleanup",
"rev": "5f5f51ce8b7560d18ddae1824bc253a9e896ab0b",
"type": "github"
},
"original": {
"owner": "DarkKirb",
"repo": "mautrix-cleanup",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1672428209,
"narHash": "sha256-eejhqkDz2cb2vc5VeaWphJz8UXNuoNoM8/Op8eWv2tQ=",
"lastModified": 1678433091,
"narHash": "sha256-dsD0Yhr5yuxY55xRHupQAcKtCwnqCfihGMYriqwUD0k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847",
"rev": "88bdb6d79b0bdf03d3338f6f3d1416a55ec199ab",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847",
"type": "github"
}
},
@ -134,27 +157,13 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1677746272,
"narHash": "sha256-4raJuGYuBiZ2h+vl71i1itduZ5OLnXbipslPeGzOLds=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a87b99a3c708dc91d2a7149fa28302aa0fae8c84",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"attic": "attic",
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
"mautrix-cleanup": "mautrix-cleanup",
"nixpkgs": "nixpkgs"
}
},
"rust-overlay": {

View file

@ -3,16 +3,21 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.url = "github:DarkKirb/flake-utils";
attic = {
url = "github:zhaofengli/attic";
#inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
mautrix-cleanup = {
url = "github:DarkKirb/mautrix-cleanup";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {

View file

@ -44,19 +44,29 @@
"start": "yarn build:module_system && concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js\"",
"start:https": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js --https\"",
"start:res": "yarn build:jitsi && node scripts/copy-res.js -w",
"start:js": "webpack-dev-server --host=0.0.0.0 --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --mode development --disable-host-check --hot",
"start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --mode development --disable-host-check --hot",
"lint": "yarn lint:types && yarn lint:js && yarn lint:style",
"lint:js": "eslint --max-warnings 0 src module_system test && prettier --check .",
"lint:js-fix": "prettier --write . && eslint --fix src module_system test",
"lint:types": "tsc --noEmit --jsx react && tsc --noEmit --project ./tsconfig.module_system.json",
"lint:js": "yarn lint:js:src && yarn lint:js:module_system",
"lint:js:src": "eslint --max-warnings 0 src test && prettier --check .",
"lint:js:module_system": "eslint --max-warnings 0 --config .eslintrc-module_system.js module_system",
"lint:js-fix": "yarn lint:js-fix:src && yarn lint:js-fix:module_system",
"lint:js-fix:src": "prettier --write . && eslint --fix src test",
"lint:js-fix:module_system": "eslint --fix --config .eslintrc-module_system.js module_system",
"lint:types": "yarn lint:types:src && yarn lint:types:module_system",
"lint:types:src": "tsc --noEmit --jsx react",
"lint:types:module_system": "tsc --noEmit --project ./tsconfig.module_system.json",
"lint:style": "stylelint \"res/css/**/*.pcss\"",
"test": "jest",
"coverage": "yarn test --coverage",
"analyse:unused-exports": "node ./scripts/analyse_unused_exports.js"
},
"resolutions": {
"@types/react-dom": "17.0.19",
"@types/react": "17.0.53"
},
"dependencies": {
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.12.tgz",
"@matrix-org/react-sdk-module-api": "^0.0.3",
"@matrix-org/react-sdk-module-api": "^0.0.4",
"gfm.css": "^1.1.2",
"jsrsasign": "^10.5.25",
"katex": "^0.16.0",
@ -95,12 +105,12 @@
"@types/jsrsasign": "^10.5.4",
"@types/modernizr": "^3.5.3",
"@types/node": "^16",
"@types/react": "17.0.49",
"@types/react-dom": "17.0.17",
"@types/react": "17.0.53",
"@types/react-dom": "17.0.19",
"@types/sanitize-html": "^2.3.1",
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"allchange": "^1.0.6",
"babel-jest": "^29.0.0",
"babel-loader": "^8.2.2",
@ -109,12 +119,12 @@
"cpx": "^1.5.0",
"css-loader": "^4",
"dotenv": "^16.0.2",
"eslint": "8.28.0",
"eslint": "8.35.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-deprecate": "^0.7.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-matrix-org": "^0.9.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-matrix-org": "^1.0.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unicorn": "^45.0.0",
@ -149,20 +159,20 @@
"postcss-preset-env": "^6.7.0",
"postcss-scss": "^4.0.4",
"postcss-simple-vars": "^5.0.2",
"prettier": "2.8.0",
"prettier": "2.8.4",
"raw-loader": "^4.0.2",
"rimraf": "^3.0.2",
"semver": "^7.3.7",
"simple-proxy-agent": "^1.1.0",
"string-replace-loader": "3",
"style-loader": "2",
"stylelint": "^14.9.1",
"stylelint": "^15.0.0",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-standard": "^30.0.0",
"stylelint-scss": "^4.2.0",
"terser-webpack-plugin": "^4.0.0",
"ts-prune": "^0.10.3",
"typescript": "4.9.3",
"typescript": "4.9.5",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.2",

View file

@ -1,9 +1,9 @@
{
"url": "https://github.com/maunium/element-web",
"rev": "4c216b4b4c1c3f3ca94b0483d9f71f06d8a858e7",
"date": "2023-02-28T21:29:10+02:00",
"path": "/nix/store/ahpn6gsnhb81hahgz92zl8f9dgrj2z9j-element-web",
"sha256": "0gmnkg68zhvllhb255p556vic2azwrsx49ggckyqh11m63yh2w6n",
"rev": "213399d4caab84d015ac201a9c29ebc76e0e36e0",
"date": "2023-03-07T17:09:23+02:00",
"path": "/nix/store/ryxh455r2690izvf24859snqiz7f8zvq-element-web",
"sha256": "1mjng5ih9pd6pwqd5k96y1hjrfvxpbzrvn5mr3hrha3ln4h0ry46",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
{
buildGo118Module,
buildGo119Module,
git,
fetchFromGitHub,
lib,
@ -7,7 +7,7 @@
}: let
source = builtins.fromJSON (builtins.readFile ./source.json);
in
buildGo118Module rec {
buildGo119Module rec {
pname = "matrix-media-repo";
version = source.date;
src = fetchFromGitHub {
@ -15,7 +15,8 @@ in
repo = "matrix-media-repo";
inherit (source) rev sha256;
};
patches = [./async-media.patch];
#patches = [./async-media.patch];
patches = [./fix-build.patch];
vendorSha256 = builtins.readFile ./vendor.sha256;
nativeBuildInputs = [
git
@ -35,7 +36,7 @@ in
description = "Matrix media repository with multi-domain in mind.";
license = lib.licenses.mit;
};
passthru.updateScript' = writeScript "update-matrix-media-repo" ''
passthru.updateScript = writeScript "update-matrix-media-repo" ''
${../../scripts/update-git.sh} "https://github.com/turt2live/matrix-media-repo" matrix/matrix-media-repo/source.json
if [ "$(git diff -- matrix/matrix-media-repo/source.json)" ]; then
SRC_PATH=$(nix-build -E '(import ./. {}).${pname}.src')

View file

@ -0,0 +1,22 @@
From 4728b8b0faf0fedc4dcb19e7bfa932333fc25147 Mon Sep 17 00:00:00 2001
From: Charlotte <lotte@chir.rs>
Date: Fri, 10 Mar 2023 16:06:54 +0100
Subject: [PATCH] Readd io import in plugin_antispam_ocr
Fixes broken build
---
cmd/plugin_antispam_ocr/main.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/cmd/plugin_antispam_ocr/main.go b/cmd/plugin_antispam_ocr/main.go
index 5b07356..0cf0899 100644
--- a/cmd/plugin_antispam_ocr/main.go
+++ b/cmd/plugin_antispam_ocr/main.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"image"
+ "io"
"math"
"net/http"
"os"

View file

@ -1,9 +1,9 @@
{
"url": "https://github.com/turt2live/matrix-media-repo",
"rev": "fc9fc24719d248e35c3344d0d784bec7f7f8c774",
"date": "2023-02-09T16:34:44-07:00",
"path": "/nix/store/zv1rl3axs88x1cxp9zyrl123aca9lvv2-matrix-media-repo",
"sha256": "130gi04gfaj41kvgfj2xcky2h4zhcm636myrn09qc6675khvh1v2",
"rev": "f32bbbf6a370a399303e9e35248d889a0aa31daa",
"date": "2023-03-05T19:11:24-07:00",
"path": "/nix/store/2dc6mvj6kx0s479n0zc7day9qj7phrjk-matrix-media-repo",
"sha256": "1829k6mfbb8acx9k4ygnz5c9yb20f0xd2fmdpyzlx3v2fi92023y",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,

View file

@ -1 +1 @@
sha256-VtVovG9LjTnpLkQkeYzMDqqfAWX210uPda3I1TxFv68=
sha256-IAgUn29xm21ncT83ZCAxmudlwGNtpzSbG/6Oyj0Cb8g=

View file

@ -1,9 +1,9 @@
{
"url": "https://github.com/mautrix/discord",
"rev": "0e8b845014cfb5cd42e3a52f2ad7a01d0824f2bd",
"date": "2023-03-01T22:50:19+02:00",
"path": "/nix/store/r8w9cpkrmpmhgbwc07233wkaphiib4mi-discord",
"sha256": "1w3al7gwnpy21dpyrw3wj1l7llsm03xcj3wbh6xqam2h6c27a1wv",
"rev": "d42c4722c939246bf9042838f8c8ce0b570b336c",
"date": "2023-03-08T19:49:43+02:00",
"path": "/nix/store/ns1pjqw9r3fj82155cmy5vg9z6vwyzq0-discord",
"sha256": "1hs01m70b6aa5qn7bgvgbcsiv9q234chl9c012x52d3f4hcyvljw",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,

View file

@ -1 +1 @@
sha256-Mx16wh4W7Vg6z7nSiRElPHd8Nkbuz4wHkj8a3I1ikGY=
sha256-B3eVS3/ZFbRMJAFOz+vqZIvsiF1+zAzmDzFrulyFcCg=

View file

@ -1,9 +1,9 @@
{
"url": "https://github.com/mautrix/signal",
"rev": "d5824550172cbb8f58a45a56e312db828dd9c887",
"date": "2023-03-01T09:22:53-07:00",
"path": "/nix/store/39d0jpix3l2384iy8qkjiwqgq9s9j7b7-signal",
"sha256": "09811q0zl9alx4m951bmgjkczs5lz7dsn05xc4nv28h4ldhscvdc",
"rev": "b5b91030acf431189ef35a00408e2922cebb4dd0",
"date": "2023-03-03T18:03:17-07:00",
"path": "/nix/store/y8s39wshy8ycaqrrlypvmpq2l0ri7c5n-signal",
"sha256": "103i19c17h5w955385h6mm49k2br6aps1d9yz24095d0xmarslrm",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,

View file

@ -1,9 +1,9 @@
{
"url": "https://github.com/mautrix/whatsapp",
"rev": "59b6e9f2721726088ac1554c9274fea89ffb997d",
"date": "2023-02-27T01:28:44+02:00",
"path": "/nix/store/hnms6vsb759l88h32lyxqrdgwa12s0yk-whatsapp",
"sha256": "00cwjp7hhbkya47r61l00nmmn7ah6nrjayg6fvrhs73174cw43n5",
"rev": "6df2ff725999ff82d0f3b171b44d748533bf34ee",
"date": "2023-03-08T17:14:31+02:00",
"path": "/nix/store/pqihn0m8dwr69p52j529cagrdykksi63-whatsapp",
"sha256": "1c6s101ffymxjfc7lg75c4k216ag16ly6vf0zx6xcxc09qk6ikjb",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,

View file

@ -1 +1 @@
sha256-rnn2LJi/8H3Xd4C643Xog+XBUR4LNjWoeUpWO1e872M=
sha256-z22iPU6KyQ/YaK7tnIxhe+QkwKqtrR1fXyrwD+qVDwc=

View file

@ -1,6 +1,6 @@
{
"version": "1.19.3",
"build": 431,
"name": "paper-1.19.3-431.jar",
"sha256": "2802c3c36b623b78bef6c075959e7fad8237ab9704aa566df792d2e6a4e780cb"
"build": 445,
"name": "paper-1.19.3-445.jar",
"sha256": "109d7e838402c045a5b571123ea7791dcfb99d1cb858ab97b1edf09b83ee49fa"
}

View file

@ -12,11 +12,11 @@
}:
buildPythonPackage rec {
pname = "mautrix";
version = "0.19.4";
version = "0.19.5";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-OkB5UYIJCGuQeyRNoany9adJmmuftyl0CajOS+HAYRs=";
sha256 = "sha256-eZhfpbI03Nv1RlOSog/um6R4PJQbDHpGqRBm7GAD4tI=";
};
propagatedBuildInputs = [

View file

@ -1,31 +0,0 @@
{
python3,
boto3,
aiohttp,
stdenvNoCC,
lib,
}: let
clean-s3-cache-env = python3.buildEnv.override {
extraLibs = [boto3 aiohttp];
};
in
stdenvNoCC.mkDerivation {
name = "clean-s3-cache";
src = ./clean-s3-cache.py;
python = clean-s3-cache-env;
unpackPhase = ''
cp $src clean-s3-cache.py
'';
buildPhase = ''
substituteAllInPlace clean-s3-cache.py
'';
installPhase = ''
mkdir -p $out/bin
cp clean-s3-cache.py $out/bin
chmod +x $out/bin/clean-s3-cache.py
'';
meta = {
description = "Scriept for cleaning a nix s3 binary cache";
license = lib.licenses.bsd2;
};
}

View file

@ -1,194 +0,0 @@
#!@python@/bin/python
import asyncio
from concurrent.futures import ThreadPoolExecutor
import functools
from typing import Any, AsyncIterable, Awaitable, Callable, Optional, TypeVar
from typing import cast
from os import path, listdir
import json
import boto3
from botocore.response import StreamingBody
import aiohttp
ENDPOINT_URL: str = "https://s3.us-west-000.backblazeb2.com"
BUCKET_NAME: str = "cache-chir-rs"
executor: ThreadPoolExecutor = ThreadPoolExecutor()
F = TypeVar('F', bound=Callable[..., Any])
T = TypeVar('T')
def with_backoff(
f: Callable[..., Awaitable[T]]) -> Callable[..., Awaitable[T]]:
async def with_backoff_wrapper(*args: Any, **kwargs: Any) -> T:
last_delay = 2
while True:
try:
return await f(*args, **kwargs)
except Exception as e:
print(f"{e}")
if last_delay >= 120:
raise
await asyncio.sleep(last_delay)
last_delay *= last_delay
return with_backoff_wrapper
def aio(f: Callable[..., T]) -> Callable[..., Awaitable[T]]:
async def aio_wrapper(*args: Any, **kwargs: Any) -> T:
f_bound: Callable[[], T] = functools.partial(f, *args, **kwargs)
loop: asyncio.AbstractEventLoop = asyncio.get_running_loop()
return await loop.run_in_executor(executor, f_bound)
return aio_wrapper
@aio
def exists_locally(store_path: str) -> bool:
return path.exists(store_path)
class NarInfo(object):
def __init__(self, narinfo: str) -> None:
self.compression = "bzip2"
for narinfo_line in narinfo.splitlines():
key, value = narinfo_line.split(": ", 1)
if key == "StorePath":
self.store_path = value
elif key == "URL":
self.url = value
elif key == "Compression":
self.compression = value
elif key == "FileHash":
self.file_hash = value
elif key == "FileSize":
self.file_size = int(value)
elif key == "NarHash":
self.nar_hash = value
elif key == "NarSize":
self.nar_size = int(value)
elif key == "References":
self.references = value.split()
elif key == "Deriver":
self.deriver = value
elif key == "System":
self.system = value
elif key == "Sig":
self.sig = value
elif key == "CA":
self.ca = value
async def exists_locally(self) -> bool:
return await exists_locally(self.store_path)
s3 = boto3.client("s3", endpoint_url=ENDPOINT_URL)
@with_backoff
@aio
def get_object(Key: str) -> str:
obj = s3.get_object(Bucket=BUCKET_NAME, Key=Key)
if "Body" not in obj:
raise Exception("No Body")
if isinstance(obj["Body"], StreamingBody):
return obj["Body"].read().decode("utf-8")
raise Exception("Not StreamingBody")
async def list_cache_objects() -> AsyncIterable[str]:
@with_backoff
@aio
def list_objects_v2(ContinuationToken: Optional[str]) -> dict[str, Any]:
if ContinuationToken is not None:
return s3.list_objects_v2(Bucket=BUCKET_NAME,
ContinuationToken=ContinuationToken)
else:
return s3.list_objects_v2(Bucket=BUCKET_NAME)
cont_token = None
while True:
objs = await list_objects_v2(cont_token)
if "Contents" not in objs:
raise Exception("No Contents")
if isinstance(objs["Contents"], list):
for obj in cast(list[Any], objs["Contents"]):
if not isinstance(obj, dict):
raise Exception("Not dict")
obj = cast(dict[str, Any], obj)
yield obj["Key"]
if "NextContinuationToken" not in objs:
break
cont_token = objs["NextContinuationToken"]
@with_backoff
@aio
def delete_object(key: str) -> None:
s3.delete_object(Bucket=BUCKET_NAME, Key=key)
def get_store_hashes() -> set[str]:
hashes = set()
for obj in listdir("/nix/store"):
hashes.add(obj.split("-")[0])
return hashes
async def is_in_nixos_cache(client: aiohttp.ClientSession, narinfo: str) -> bool:
async with client.get(f"https://cache.nixos.org/{narinfo}"):
if response.status == 200:
return True
return False
async def main() -> None:
nars_to_delete = set()
nars_to_keep = set()
async with aiohttp.ClientSession() as client:
async for obj_key in list_cache_objects():
if obj_key.endswith(".narinfo"):
# check if we have the hash locally
narinfo = await get_object(obj_key)
narinfo = NarInfo(narinfo)
# check if cache.nixos.org has the narinfo
if await is_in_nixos_cache(client, obj_key):
print(f"Found duplicated NAR for {narinfo.store_path}")
await delete_object(obj_key)
nars_to_delete.add(narinfo.url)
elif not await narinfo.exists_locally():
print(f"Found unused NAR for {narinfo.store_path}")
await delete_object(obj_key)
nars_to_delete.add(narinfo.url)
else:
nars_to_keep.add(narinfo.url)
if obj_key.startswith("realisations/"):
realisation = await get_object(obj_key)
realisation = json.loads(realisation)
if not isinstance(realisation, dict):
continue
if "outPath" not in realisation:
continue
if not await exists_locally("/nix/store/" +
realisation["outPath"]):
print(f"Found unused realisation for {realisation['outPath']}")
await delete_object(obj_key)
if obj_key.startswith("nar/"):
nars_to_delete.add(obj_key)
for nar in nars_to_delete:
if nar in nars_to_keep:
continue
print(f"Deleting unused NAR {nar}")
await delete_object(nar)
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())