Unpin #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unpin | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 23 * * *" | |
| jobs: | |
| pin-kill: | |
| name: Unpin orphans | |
| runs-on: nyxbuilder | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| extra_nix_config: | | |
| accept-flake-config = true | |
| sandbox-fallback = false | |
| system-features = big-parallel gccarch-x86-64-v3 kvm | |
| install_options: --daemon | |
| # similar to build.yml | |
| - name: Create niks3 auth-token | |
| run: | | |
| export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} | |
| mkdir -p "$XDG_CONFIG_HOME"/niks3/ | |
| printf "%s" "$NIKS3_TOKEN" > "$XDG_CONFIG_HOME"/niks3/auth-token | |
| wc "$XDG_CONFIG_HOME"/niks3/auth-token | |
| env: | |
| NIKS3_TOKEN: ${{ secrets.NIKS3_TOKEN }} | |
| - name: Diff and save | |
| run: | | |
| set -euo pipefail | |
| NIKS3=$(nix build .#niks3_nyx --no-link --print-out-paths) | |
| export PATH="$PATH:$NIKS3/bin" | |
| EXPECTED_PINS=$(nix build ./maintenance#chaotic-nyx.expected-pins --no-link --print-out-paths) | |
| sort -u "$EXPECTED_PINS" > expected-pins.txt | |
| niks3 pins list | awk 'NR > 1 {print $1}' | sort -u > actual-pins.txt | |
| test -s expected-pins.txt && test -s actual-pins.txt || { echo "Pins list empty, aborting." >&2; exit 2; } | |
| comm -13 expected-pins.txt actual-pins.txt | tee orphan-pins.txt | |
| ORPHAN_PINS_SIZE=$(wc -c < orphan-pins.txt) | |
| if (( ORPHAN_PINS_SIZE < $(wc -c < actual-pins.txt) && ORPHAN_PINS_SIZE < $(wc -c < expected-pins.txt) )); then | |
| xargs -r -n 1 niks3 pins delete < orphan-pins.txt | |
| else | |
| echo "Trying to delete all pins or something which are not pins" >&2 | |
| exit 1 | |
| fi |