2023-10-29 22:52:33 +00:00
|
|
|
name: Flake checks
|
2023-11-10 18:10:22 +00:00
|
|
|
on: [pull_request]
|
2023-11-18 18:46:02 +00:00
|
|
|
env:
|
|
|
|
USER: ci
|
2023-10-29 22:52:33 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
Check:
|
2023-11-18 18:46:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-10-29 22:52:33 +00:00
|
|
|
steps:
|
|
|
|
- name: Check out repository code
|
|
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
2023-11-18 18:46:02 +00:00
|
|
|
|
2024-04-21 17:58:58 +00:00
|
|
|
- uses: https://github.com/nixbuild/nix-quick-install-action@v27
|
2023-11-18 18:46:02 +00:00
|
|
|
with:
|
|
|
|
load_nixConfig: false
|
|
|
|
nix_conf: |
|
|
|
|
substituters = https://cache.nixos.org/ https://nix-community.cachix.org
|
|
|
|
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
|
|
|
|
keep-outputs = true
|
|
|
|
|
|
|
|
- name: Calculate flake.lock hash
|
|
|
|
id: flake-lock-hash
|
|
|
|
run: |
|
|
|
|
echo "hash=$(md5sum flake.lock | awk '{print $1}')" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Restore and cache Nix store
|
2024-04-23 10:03:16 +00:00
|
|
|
uses: https://github.com/nix-community/cache-nix-action@v4.0.3
|
2023-11-18 18:46:02 +00:00
|
|
|
id: nix-store-cache
|
|
|
|
with:
|
2024-04-23 10:03:16 +00:00
|
|
|
key: cache-${{ runner.os }}-nix-store-${{ steps.flake-lock-hash.outputs.hash }}
|
|
|
|
restore-keys: |
|
2023-11-18 18:46:02 +00:00
|
|
|
cache-${{ runner.os }}-nix-store-
|
|
|
|
|
|
|
|
gc-linux: true
|
|
|
|
gc-max-store-size-linux: 10000000000
|
|
|
|
|
2024-04-23 10:03:16 +00:00
|
|
|
purge-caches: true
|
|
|
|
purge-key: cache-${{ runner.os }}-nix-store-
|
|
|
|
purge-created: true
|
|
|
|
purge-created-max-age: 42
|
2024-04-23 00:18:10 +00:00
|
|
|
|
2023-11-06 21:05:25 +00:00
|
|
|
- name: Prepare cachix
|
2024-04-21 17:58:58 +00:00
|
|
|
uses: https://github.com/cachix/cachix-action@v14
|
2023-11-06 21:05:25 +00:00
|
|
|
with:
|
|
|
|
name: pub-solar
|
2023-11-09 03:19:26 +00:00
|
|
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
2024-04-23 00:18:10 +00:00
|
|
|
useDaemon: false
|
2023-11-18 18:46:02 +00:00
|
|
|
|
2024-05-08 12:05:41 +00:00
|
|
|
- name: Check formatting
|
|
|
|
run: |
|
|
|
|
nix --accept-flake-config --access-tokens '' develop --command treefmt --fail-on-change
|
|
|
|
|
2023-10-29 22:52:33 +00:00
|
|
|
- name: Run flake checks
|
|
|
|
run: |
|
2024-05-14 21:22:09 +00:00
|
|
|
set -exuo pipefail
|
2024-04-23 14:00:16 +00:00
|
|
|
# Prevent cache garbage collection by creating GC roots
|
2024-04-23 10:03:16 +00:00
|
|
|
for target in $(nix flake show --json --all-systems | jq '
|
|
|
|
.["nixosConfigurations"] |
|
|
|
|
to_entries[] |
|
|
|
|
.key
|
|
|
|
' | tr -d '"'
|
|
|
|
); do
|
2024-04-23 14:00:16 +00:00
|
|
|
nix --print-build-logs --verbose --accept-flake-config --access-tokens '' \
|
2024-05-14 21:22:09 +00:00
|
|
|
build --out-link ./result-"$target" ".#nixosConfigurations.${target}.config.system.build.toplevel"
|
2024-04-23 10:03:16 +00:00
|
|
|
done
|
2024-04-23 14:32:11 +00:00
|
|
|
|
2024-04-23 14:00:16 +00:00
|
|
|
nix --print-build-logs --verbose --accept-flake-config --access-tokens '' flake check
|