write-lock (#79) #351
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: flake-check | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| jobs: | |
| find-templates: | |
| name: Find templates | |
| runs-on: ubuntu-latest | |
| outputs: | |
| templates: ${{ steps.templates.outputs.templates }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: templates | |
| run: | | |
| templates=$(find templates -mindepth 2 -maxdepth 2 -name flake.nix -print0 | xargs -0 dirname | xargs -n 1 basename | jq -R | jq -sc) | |
| echo "$templates" | |
| echo "templates=$templates" >> $GITHUB_OUTPUT | |
| bootstrap: | |
| name: Bootstrap | |
| runs-on: ubuntu-latest | |
| env: | |
| NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz" | |
| steps: | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - uses: actions/checkout@v4 | |
| - run: nix-shell ./dev/bootstrap-tests.nix --run test-all | |
| template: | |
| name: Check template ${{matrix.template}} | |
| needs: [dev, find-templates] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| template: ${{ fromJSON(needs.find-templates.outputs.templates) }} | |
| exclude: | |
| - template: "unflake" | |
| steps: | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - run: | | |
| set -uveo pipefail | |
| cat <<EOF | tee forced.nix | |
| { lib, ... }: | |
| { | |
| flake-file.inputs.flake-file.url = lib.mkForce "github:$GITHUB_REPOSITORY/$GITHUB_SHA"; | |
| } | |
| EOF | |
| mkdir templated; cd templated | |
| nix flake init -t github:$GITHUB_REPOSITORY/$GITHUB_SHA#${{ matrix.template }} | |
| nix run .#write-flake -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA" | |
| if test -d ./modules; then cp ../forced.nix ./modules/; fi; | |
| if test -d ./flake-parts; then cp ../forced.nix ./flake-parts/; fi; | |
| nix run .#write-flake -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA" | |
| nix flake metadata | |
| nix run .#write-flake -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA" | |
| nix flake check -L --show-trace --override-input flake-file "github:$GITHUB_REPOSITORY/$GITHUB_SHA" | |
| npins: | |
| needs: [dev] | |
| name: Check npins | |
| runs-on: ubuntu-latest | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'npins') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - run: | | |
| set -e -o pipefail | |
| cd templates/npins | |
| sed -i 's/# flake-file = import/flake-file = import/' default.nix | |
| echo "{ inputs, ... }: { npins.pkgs = import inputs.nixpkgs {}; }" | tee modules/pkgs.nix | |
| nix-shell . -A flake-file.sh --run write-npins | |
| unflake: | |
| needs: [dev] | |
| name: Check unflake | |
| runs-on: ubuntu-latest | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'unflake') }} | |
| env: | |
| NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - run: | | |
| set -e -o pipefail | |
| cd templates/unflake | |
| sed -i 's/# flake-file = import/flake-file = import/' default.nix | |
| nix-shell . -A flake-file.sh --run 'write-unflake --verbose' | |
| nixlock: | |
| needs: [dev] | |
| name: Check nixlock | |
| runs-on: ubuntu-latest | |
| # if: ${{ contains(github.event.pull_request.labels.*.name, 'unflake') }} | |
| env: | |
| NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - run: | | |
| set -e -o pipefail | |
| cd templates/nixlock | |
| sed -i 's/# flake-file = import/flake-file = import/' default.nix | |
| nix-shell . -A flake-file.sh --run write-nixlock | |
| dev: | |
| needs: [bootstrap, nix-fmt] | |
| name: Check flake dev | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - run: cd dev && nix flake check && nix flake metadata && nix flake check | |
| nix-fmt: | |
| name: Nix Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: wimpysworld/nothing-but-nix@main | |
| - uses: cachix/install-nix-action@v31 | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - run: nix run -L ./dev#fmt -- --ci |