diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index ba9445b..556359a 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -25,15 +25,19 @@ jobs: extra-trusted-public-keys = nix-cache.nul.ie-1:BzH5yMfF4HbzY1C977XzOxoPhEc9Zbu39ftPkUbH+m4= - name: Check flake - run: nix flake check - - name: Build the world + run: nix flake check --no-build + - name: Build (and cache) the world id: build - run: | - path=$(nix build --no-link .#ci.x86_64-linux --json | jq -r .[0].outputs.out) - echo "path=$path" >> "$GITHUB_OUTPUT" - - - name: Push to cache env: HARMONIA_SSH_KEY: ${{ secrets.HARMONIA_SSH_KEY }} run: | - ci/push-to-cache.sh "${{ steps.build.outputs.path }}" + nix eval --json --apply "builtins.attrNames" | jq -cr '.[]' | while read job; do + echo "Building $job" + path="$(nix build --no-link .#ci.x86_64-linux."$job" --json | jq -r .[0].outputs.out)" + echo "Caching $job" + ci/push-to-cache.sh "$path" + done + + echo "Building and caching CI derivation" + path="$(nix build --no-link .#ciDrv.x86_64-linux --json | jq -r .[0].outputs.out)" + UPDATE_PROFILE=1 ci/push-to-cache.sh "$path" diff --git a/ci/push-to-cache.sh b/ci/push-to-cache.sh index 7cab76d..be53f94 100755 --- a/ci/push-to-cache.sh +++ b/ci/push-to-cache.sh @@ -22,8 +22,10 @@ path="$1" echo "Pushing $path to cache..." nix copy --no-check-sigs --to "$STORE_URI" "$path" -echo "Updating profile..." -remote_cmd nix-env -p "$REMOTE_STORE"/nix/var/nix/profiles/nixfiles --set "$path" +if [ -n "$UPDATE_PROFILE" ]; then + echo "Updating profile..." + remote_cmd nix-env -p "$REMOTE_STORE"/nix/var/nix/profiles/nixfiles --set "$path" -echo "Collecting garbage..." -remote_cmd nix-collect-garbage --delete-older-than 30d + echo "Collecting garbage..." + remote_cmd nix-collect-garbage --delete-older-than 60d +fi diff --git a/flake.nix b/flake.nix index 36b6819..1504a8e 100644 --- a/flake.nix +++ b/flake.nix @@ -204,8 +204,9 @@ systems' = mapAttrs' (n: v: nameValuePair "system-${n}" v) systems; packages' = mapAttrs' (n: v: nameValuePair "package-${n}" v) packages; in - pkgs.linkFarm "ci" (homes' // systems' // packages' // { + homes' // systems' // packages' // { inherit shell; - }); + }; + ciDrv = pkgs.linkFarm "ci" ci; })); }