diff --git a/flake.nix b/flake.nix index 9b33500824..21294f58d3 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ }; in # `appendOverlays` with a singleton is identical to `extend`. let pkgs = haskellNix.legacyPackages.${system}.appendOverlays [android26]; in + let compilerSelection = import ./scripts/nix/compiler-selection.nix { inherit haskellNix; }; in let drv' = { extra-modules, pkgs', package-flags ? {}, package-ghc-options ? {}, ... }: let packageFlags = pkgs.lib.recursiveUpdate { direct-sqlcipher = { openssl = true; commoncrypto = false; tomcrypt = false; }; @@ -47,6 +48,7 @@ }) package-ghc-options; in pkgs'.haskell-nix.project { compiler-nix-name = "ghc914-sh"; + inherit compilerSelection; # We need this, to specify we want the cabal project. # If the stack.yaml was dropped, this would not be necessary. projectFileName = "cabal.project"; diff --git a/scripts/nix/README.md b/scripts/nix/README.md index 8e9acf8e84..b402e0bcc1 100644 --- a/scripts/nix/README.md +++ b/scripts/nix/README.md @@ -5,6 +5,10 @@ The compiler and all cross-compilers come from the haskell.nix input pinned in GHC 9.14 release from GHCup. Use the same source checkout and lock file for every platform; Android ARMv7 does not require a separate branch or tag. +`compiler-selection.nix` matches Hydra's compiler build context so the pinned +compiler can use its existing cache. That context is scoped to the compiler and +its build tools; application dependencies keep the project's current packages. + Run these commands from the repository root: ```sh diff --git a/scripts/nix/compiler-selection.nix b/scripts/nix/compiler-selection.nix new file mode 100644 index 0000000000..1cc1c4dfa8 --- /dev/null +++ b/scripts/nix/compiler-selection.nix @@ -0,0 +1,7 @@ +{ haskellNix }: +pkgs: +# Hydra's compiler builds use this overlay. Its pkg-config metadata changes +# the Cabal build tool's hash, and therefore every compiler slice's hash. +# Keep that context inside compiler selection: application dependencies still +# use the project's package set and its current libsodium mapping. +(pkgs.appendOverlays [ (import (haskellNix + "/test/overlay.nix")) ]).haskell-nix.compiler