-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathjs2nix.nix
More file actions
39 lines (36 loc) · 837 Bytes
/
js2nix.nix
File metadata and controls
39 lines (36 loc) · 837 Bytes
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
{ nix
, yarn
, buildNodeModule
, loadNixExpression
, parseModuleID
, selectModules
}:
with builtins;
let
tree = loadNixExpression ./yarn.lock.nix { };
pkgInfo = fromJSON (readFile ./package.json);
inherit (pkgInfo) name version files;
id = parseModuleID name;
src = let p = ./.;
in path {
name = "${id.scope}-${id.name}";
path = p;
filter = _path: _:
let
rp = toString
(replaceStrings [ ((toString p) + "/") ] [ "" ] (toString _path));
in elem rp files;
};
in buildNodeModule {
inherit id version src;
lifeCycleScripts = [ ];
# Replace links to `yarn` and `nix` with paths to nix store.
inherit yarn nix;
prePatch = ''
substituteAllInPlace lib/proxy.js
'';
modules = selectModules ./package.json {
inherit tree;
sections = [ "dependencies" ];
};
}