diff --git a/.forgejo/workflows/eval.yaml b/.forgejo/workflows/eval.yaml index b5cbf0a..d1628b4 100644 --- a/.forgejo/workflows/eval.yaml +++ b/.forgejo/workflows/eval.yaml @@ -68,3 +68,21 @@ jobs: run: | # Enter the shell nix-shell --run 'colmena build --on rescue01' + + push_to_cache: + runs-on: nix + needs: + - build_compute01 + - build_storage01 + - build_vault01 + - build_web01 + - build_web02 + - build_rescue01 + steps: + - uses: actions/checkout@v3 + + - name: Push to cache + run: nix-shell --run push-to-cache + env: + ATTIC_ENDPOINT: "https://cachix.dgnum.eu" + ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} diff --git a/default.nix b/default.nix index 44d2c02..d04dfad 100644 --- a/default.nix +++ b/default.nix @@ -76,6 +76,7 @@ in [ npins nixos-generators + attic-client ] ++ (builtins.map (p: callPackage p { }) [ (sources.disko + "/package.nix") diff --git a/machines/storage01/atticd.nix b/machines/storage01/atticd.nix index 61a5b94..0bc6897 100644 --- a/machines/storage01/atticd.nix +++ b/machines/storage01/atticd.nix @@ -58,7 +58,7 @@ in proxyPass = "http://127.0.0.1:9090"; extraConfig = '' - client_max_body_size 700M; + client_max_body_size 10G; ''; }; }; diff --git a/scripts/cache.sh b/scripts/cache.sh new file mode 100755 index 0000000..503a7e9 --- /dev/null +++ b/scripts/cache.sh @@ -0,0 +1,12 @@ +ENDPOINT=${ATTIC_ENDPOINT:-https://cachix.dgnum.eu} + +if [ "$1" == "off" ]; then + echo "Please edit $XDG_CONFIG_DIRS/nix/nix.conf to remove the cache" +elif [ "$1" == "on" ]; then + @attic@/bin/attic login dgnum "$ENDPOINT" + @attic@/bin/attic use dgnum:infra +else + echo "Help:" + echo " cache {on|off}" +fi + diff --git a/scripts/default.nix b/scripts/default.nix index c349792..84945a0 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -10,6 +10,7 @@ let git jq ; + attic = pkgs.attic-client; }; mkShellScript = @@ -32,6 +33,8 @@ let "check-deployment" "launch-vm" "list-nodes" + "push-to-cache" + "cache" ]; in diff --git a/scripts/push-to-cache.sh b/scripts/push-to-cache.sh new file mode 100755 index 0000000..b6d1ae3 --- /dev/null +++ b/scripts/push-to-cache.sh @@ -0,0 +1,13 @@ +set -e +set -u +set -o pipefail + +ENDPOINT=${ATTIC_ENDPOINT:-https://cachix.dgnum.eu} + +@attic@/bin/attic login dgnum "$ENDPOINT" "$ATTIC_TOKEN" + +@colmena@/bin/colmena eval -E '{ nodes, lib, ... }: lib.mapAttrsToList (_: v: v.config.system.build.toplevel.drvPath) nodes' |\ +@jq@/bin/jq -r '.[]' |\ +xargs nix-store -q -R --include-outputs |\ +sed '/\.drv$/d' |\ +xargs @attic@/bin/attic push dgnum:infra