-
Notifications
You must be signed in to change notification settings - Fork 21
/
haskell-pkgs.nix
60 lines (54 loc) · 1.67 KB
/
haskell-pkgs.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
{ pkgs }:
let
inherit (pkgs) lib;
licensesJson = pkgs.writeText "licenses.json"
(builtins.toJSON (lib.filterAttrs (n: v: v ? spdxId) lib.licenses));
minimalHaskellSource = root: extra:
builtins.path {
path = root;
name = "${builtins.baseNameOf root}-source";
filter = path: type:
lib.any (p: lib.hasPrefix (toString root + "/" + p) path) ([
"package.yaml"
"LICENSE"
"CHANGELOG.md"
"src"
"tests"
] ++ extra);
};
in
pkgs.haskellPackages.override {
overrides =
(self: super: {
yarn-lock =
let
pkg = self.callPackage ./yarn-lock/yarn-lock.nix {
inherit (pkgs) hpack;
};
in pkgs.haskell.lib.overrideCabal pkg (old: {
version = "git";
src = minimalHaskellSource ./yarn-lock [];
});
yarn2nix =
let
pkg = self.callPackage ./yarn2nix/yarn2nix.nix {
inherit (pkgs) hpack;
};
in pkgs.haskell.lib.overrideCabal pkg (old: {
version = "git";
src = minimalHaskellSource ./yarn2nix [
"Main.hs"
"NodePackageTool.hs"
];
prePatch = ''
# we depend on the git prefetcher
substituteInPlace \
src/Distribution/Nixpkgs/Nodejs/ResolveLockfile.hs \
--replace '"nix-prefetch-git"' \
'"${pkgs.nix-prefetch-git.override { git = pkgs.gitMinimal; }}/bin/nix-prefetch-git"'
sed -i '/license-data/a \ <> O.value "${licensesJson}"' \
src/Distribution/Nixpkgs/Nodejs/Cli.hs
'' + old.prePatch or "";
});
});
}