forked from canva-public/js2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
42 lines (38 loc) · 1.24 KB
/
shell.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
{ nixpkgs ? import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/13e0d337037b3f59eccbbdf3bc1fe7b1e55c93fd.tar.gz") { } }:
let
js2nix = nixpkgs.callPackage ./default.nix { };
tree = js2nix.load ./yarn.lock {
overlays = [
(self: super: {
"[email protected]" = super."[email protected]".override
# Fix peer dependencies
(x: { modules = x.modules ++ [ (self."@babel/[email protected]") ]; });
})
];
};
devNodeModules = js2nix.makeNodeModules ./package.json {
name = "dev";
inherit tree;
prefix = "/lib/node_modules";
exposeBin = true;
};
prodNodeModules = js2nix.makeNodeModules ./package.json {
name = "prod";
inherit tree;
sections = [ "dependencies" ];
};
in nixpkgs.mkShell {
# Give the nix-build access to resulting artifact directly with an a standart folder
# structure instead of the structure that would be picked up by nodejs pachage setup-hook.
# To create a folder type:
# nix-build -o node_modules -A devNodeModules ./shell.nix
devNodeModules = devNodeModules.override { prefix = ""; };
prodNodeModules = prodNodeModules;
buildInputs = [
devNodeModules
nixpkgs.nodejs
js2nix.bin
js2nix.proxy
js2nix.node-gyp
];
}