Add trivial source filter to avoid rebuilds

This commit is contained in:
Robert Hensing 2023-03-11 12:19:42 +01:00 committed by Sridhar Ratnakumar
parent f995e244af
commit cd5e16917d
2 changed files with 24 additions and 6 deletions

View File

@ -10,6 +10,7 @@
- #92: Add `devShell.mkShellArgs` to pass custom arguments to `mkShell`
- #111: Add `devShell.extraLibraries` to add custom Haskell libraries to the devshell.
- #100: `source-overrides` option now supports specifying Hackage versions.
- #114: Prevent Nix rebuilds of packages in sub-directories when parent contents change.
- API changes
- #37: Group `buildTools` (renamed to `tools`), `hlsCheck` and `hlintCheck` under the `devShell` submodule option; and allow disabling them all using `devShell.enable = false;` (useful if you want haskell-flake to produce just the package outputs).
- #64: Remove hlintCheck (use [treefmt-nix](https://github.com/numtide/treefmt-nix#flake-parts) instead)

View File

@ -58,14 +58,31 @@ in
hpack
''
else root;
setSrc = name: root: pkg: hlib.overrideSrc {
src =
lib.cleanSourceWith {
name = "source-${name}-${pkg.version}";
src =
# NOTE: Even though cabal2nix does run hpack automatically,
# buildFromCabalSdist does not. So we must run hpack ourselves at
# the original source level.
realiseHpack name root;
};
} pkg;
in
lib.mapAttrs
(name: value:
# NOTE: Even though cabal2nix does run hpack automatically,
# buildFromCabalSdist does not. So we must run hpack ourselves at
# the original source level.
let root = realiseHpack name value.root;
in fromSdist (self.callCabal2nix name root { })
(name: pkgCfg:
lib.pipe pkgCfg
[
(pkgCfg: self.callCabal2nix name pkgCfg.root { })
# Avoid rebuilding because of changes in parent directories
(setSrc name pkgCfg.root)
# Make sure all files we use are included in the sdist, as a check
# for release-worthiness.
fromSdist
]
)
config.packages;