Skip to content

Commit 4c63945

Browse files
authored
Make buildTools respect overrides (#23)
- Start breaking down developPackage, by using composeExtensions directly - update readme
1 parent 3c27b5b commit 4c63945

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To keep `flake.nix` smaller (eg.: going from this [91-line flake.nix](https://gi
2828
}
2929
```
3030

31-
See [`flake-module.nix` -> `options`](flake-module.nix) for a list of options available. Uses [`developPackage`](https://github.com/NixOS/nixpkgs/blob/f1c167688a6f81f4a51ab542e5f476c8c595e457/pkgs/development/haskell-modules/make-package-set.nix#L245) under the hood, but see [#7](https://github.com/srid/haskell-flake/issues/7) for future improvements.
31+
See [`flake-module.nix` -> `options`](flake-module.nix) for a list of options available. Uses [`callCabal2nixWithOptions`](https://github.com/NixOS/nixpkgs/blob/f1c167688a6f81f4a51ab542e5f476c8c595e457/pkgs/development/haskell-modules/make-package-set.nix#L245) under the hood. See [#7](https://github.com/srid/haskell-flake/issues/7) for future improvements.
3232

3333
## Template
3434

flake-module.nix

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,30 +118,27 @@ in
118118
(projectKey: cfg:
119119
let
120120
inherit (pkgs.lib.lists) optionals;
121-
hp = cfg.haskellPackages;
122-
defaultBuildTools = with hp; {
121+
# Apply user provided source-overrides and overrides to
122+
# `cfg.haskellPackages`.
123+
hp = cfg.haskellPackages.extend
124+
(pkgs.lib.composeExtensions
125+
(pkgs.haskell.lib.packageSourceOverrides cfg.source-overrides)
126+
cfg.overrides);
127+
defaultBuildTools = hp: with hp; {
123128
inherit
124129
cabal-install
125130
haskell-language-server
126131
ghcid
127132
hlint;
128133
};
129-
buildTools' = defaultBuildTools // cfg.buildTools hp;
130-
buildTools = lib.attrValues buildTools';
131-
mkProject = { returnShellEnv ? false, withHoogle ? false }:
132-
hp.developPackage {
133-
inherit returnShellEnv withHoogle;
134-
inherit (cfg) root name source-overrides overrides;
135-
modifier = drv:
136-
cfg.modifier (pkgs.haskell.lib.overrideCabal drv (oa: {
137-
buildTools = (oa.buildTools or [ ]) ++ optionals returnShellEnv buildTools;
138-
}));
139-
};
134+
buildTools = lib.attrValues (defaultBuildTools hp // cfg.buildTools hp);
135+
package = cfg.modifier (hp.callCabal2nixWithOptions cfg.name cfg.root "" { });
140136
in
141137
rec {
142-
package = mkProject { };
138+
inherit package;
143139
app = { type = "app"; program = pkgs.lib.getExe package; };
144-
devShell = mkProject { returnShellEnv = true; withHoogle = true; };
140+
devShell = with pkgs.haskell.lib;
141+
(addBuildTools package buildTools).envFunc { withHoogle = true; };
145142
checks =
146143
lib.optionalAttrs cfg.enableHLSCheck {
147144
"${projectKey}-hls" =

0 commit comments

Comments
 (0)