diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c1482e5..ec4f834 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,7 @@ jobs: with: primary-key: nix-${{ hashFiles('npins/sources.json', 'nix/*.nix', '*.cabal') }} restore-prefixes-first-match: nix- - - run: nix-build + - run: nix-build nix/ci.nix - run: nix-shell --run "echo OK" - run: nix-shell --run "cabal build" - name: Cancel workflow on failure diff --git a/nix/ci.nix b/nix/ci.nix new file mode 100644 index 0000000..0899a31 --- /dev/null +++ b/nix/ci.nix @@ -0,0 +1,37 @@ +{ sources ? import ../npins +, pkgs ? import ./pkgs.nix { inherit sources; } +, hpkgs ? import ./hpkgs.nix { inherit pkgs; } +, +}: +let + # The fileset filter on ../nix/hpkgs.nix already keeps the haskell + # build from being invalidated by edits to .hlint.yaml, so we can + # safely use the wider tree here without thrashing the cabal cache. + src = builtins.path { + path = ../.; + name = "template-project-src"; + filter = path: _type: + let base = baseNameOf (toString path); + in !(builtins.elem base [ "dist-newstyle" "dist" "result" ".git" ]); + }; +in +{ + # The cabal build / library / executable derivation — what + # 'nix-build' has always built. Kept here so CI builds the project + # /and/ the hlint pass with a single 'nix-build nix/ci.nix' rather + # than two separate invocations. + native = import ../default.nix { inherit hpkgs; }; + + # Enforce .hlint.yaml across app/src/test as part of CI. Treating + # hlint as a derivation lets the same 'nix-build nix/ci.nix' run + # locally and in GitHub Actions, and keeps the hlint version pinned + # to the same nixpkgs as the rest of the toolchain. + hlint = pkgs.runCommand "ci-hlint" + { + nativeBuildInputs = [ pkgs.hlint ]; + } '' + cd ${src} + hlint -h .hlint.yaml app src test + touch $out + ''; +}