Skip to content

Commit 1138b74

Browse files
committed
docs: Explain default.nix better
1 parent c7cde5b commit 1138b74

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

default.nix

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
let
2+
# Use nixpkgs available on the system
23
pkgs = import <nixpkgs> {};
4+
haskellDependencies = with pkgs.haskellPackages; [
5+
stack
6+
cabal-install
7+
haskell-language-server
8+
hlint
9+
ghcid
10+
hpack
11+
];
12+
13+
# Build a Haskell package with those dependencies
14+
addBuildTools = pkgs.haskell.lib.addBuildTools;
315
package = pkgs.haskellPackages.developPackage {
416
root = ./.;
5-
modifier = drv:
6-
pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; [
7-
stack
8-
cabal-install
9-
haskell-language-server
10-
hlint
11-
ghcid
12-
hpack
13-
]);
17+
modifier = drv: addBuildTools drv haskellDependencies;
1418
};
15-
in
16-
package.overrideAttrs (old: {
19+
20+
# Extend the build environment with pre-commit installed and activated
21+
withPreCommitHook = old: {
1722
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ pkgs.pre-commit ];
1823
shellHook = (old.shellHook or "") + ''
1924
if [ -d .git ]; then
2025
pre-commit install --hook-type pre-push
2126
fi
2227
'';
23-
})
28+
};
29+
in
30+
package.overrideAttrs withPreCommitHook

0 commit comments

Comments
 (0)