-
Notifications
You must be signed in to change notification settings - Fork 8
/
release.nix
58 lines (49 loc) · 2.16 KB
/
release.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
{
nixpkgs ? import ./nix/nixpkgs.nix,
compiler ? null,
}:
let
config = { allowUnfree = true; };
overlays = [
(newPkgs: oldPkgs: rec {
origHaskellPackages = if compiler == null then oldPkgs.haskellPackages
else oldPkgs.haskell.packages."${compiler}";
haskellPackages = origHaskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld:
{ semver-range =
haskellPackagesNew.callPackage ./nix/semver-range.nix { };
text-render =
haskellPackagesNew.callPackage ./nix/text-render.nix { };
hnix = haskellPackagesOld.hnix_0_4_0;
nixfromnpm =
let
inherit (newPkgs.lib) any flip elem hasSuffix hasPrefix elemAt splitString;
# We'll typically have a lot of files in this directory;
# we only want to take a few of them though. Make a filtering
# function which will choose them.
dirsToInclude = ["src" "tests" "nix-libs"];
filesToInclude = ["LICENSE" "nixfromnpm.cabal"];
_filter = path: type: let
subpath = elemAt (splitString "${toString ./.}/" path) 1;
spdir = elemAt (splitString "/" subpath) 0;
in
elem spdir dirsToInclude ||
(type == "regular" && elem subpath filesToInclude);
in
newPkgs.haskell.lib.overrideCabal
(haskellPackagesNew.callPackage ./default.nix { })
(oldDerivation: rec {
src = builtins.filterSource _filter oldDerivation.src;
shellHook = builtins.trace src ((oldDerivation.shellHook or "") + ''
export SRC=${src}
export CURL_CA_BUNDLE=${newPkgs.cacert}/etc/ssl/certs/ca-bundle.crt
export NIX_LIBS_DIR=$PWD/nix-libs
'');
});
};
};
})
];
pkgs = import nixpkgs { inherit config overlays; };
in
{ inherit (pkgs.haskellPackages) nixfromnpm; inherit pkgs; }