-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
61 lines (49 loc) · 1.65 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let
sources = import nix/sources.nix;
availableBuildTools = [ "cabal" "stack" ];
in
{ pkgs ? import sources.nixpkgs {}
, ghcVersion ? null # e.g. “--argstr ghcVersion ghc923”
, haskellPackages ?
if isNull ghcVersion
then pkgs.haskellPackages # The default one from the nixpkgs pin
else
assert builtins.isString ghcVersion;
pkgs.haskell.packages.${ghcVersion}
# nix-shell options
, inNixShell ? false # Automatically set to `true` when used by nix-shell
, buildTools ? [ "cabal" ] # See “availableBuildTools”
, withHoogle ? true
, withHLS ? true
}:
assert builtins.all (x: builtins.elem x availableBuildTools) buildTools;
let
inherit (pkgs) lib;
cleanSource = pkgs.nix-gitignore.gitignoreRecursiveSource [ ./.gitignore ];
hsPkgs = haskellPackages.extend (self: super: {
qm-interpolated-string =
self.callCabal2nix "qm-interpolated-string" (cleanSource ./.) {};
});
generate-cr-and-crlf-tests = pkgs.writeShellApplication {
name = "generate-cr-and-crlf-tests.sh";
text = builtins.readFile ./generate-cr-and-crlf-tests.sh;
runtimeInputs = [
pkgs.coreutils
pkgs.gnused
];
};
shell = hsPkgs.shellFor {
name = "qm-interpolated-string-shell";
packages = p: [ p.qm-interpolated-string ];
inherit withHoogle;
buildInputs = [
generate-cr-and-crlf-tests
] ++ lib.optional (builtins.elem "cabal" buildTools) hsPkgs.cabal-install
++ lib.optional (builtins.elem "stack" buildTools) hsPkgs.stack
++ lib.optional withHLS hsPkgs.haskell-language-server;
};
in
(if inNixShell then shell else {}) // {
inherit shell;
inherit (hsPkgs) qm-interpolated-string;
}