forked from WalletConnect/walletconnect-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
80 lines (76 loc) · 2.41 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{ pkgs ? import (import ./ops/nix/sources.nix).nixpkgs {}, githash ? ""}:
with pkgs; let
myNodejs = pkgs.nodejs-14_x;
nodeEnv = callPackage ./ops/node-env.nix {
nodejs = myNodejs;
inherit pkgs stdenv lib python2 runCommand writeTextFile;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
nodeAppDerivation = { path, pkgjson, nodeDependencies }: pkgs.stdenv.mkDerivation {
pname = builtins.replaceStrings [ "@" "/" ] [ "_at_" "_slash_" ] pkgjson.name;
version = "v${pkgjson.version}";
src = pkgs.nix-gitignore.gitignoreSourcePure [
"**/test"
"Makefile"
"result"
"dist"
"node_modules"
"ops"
".git"
./.gitignore
] path;
buildInputs = [ myNodejs ];
buildPhase = ''
export HOME=$TMP
mkdir -p $out
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
'';
installPhase = ''
${myNodejs}/bin/npm run compile
ln -s ${nodeDependencies}/lib/node_modules $out/node_modules
cp -r dist/ $out/
cp -r package.json $out/
export PATH=${myNodejs}/bin:$PATH
'';
};
relayApp = nodeAppDerivation {
pkgjson = builtins.fromJSON (builtins.readFile ./servers/relay/package.json);
nodeDependencies = (callPackage ./servers/relay/node-packages.nix {
inherit nodeEnv;
}).nodeDependencies;
path = ./servers/relay;
};
healthApp = nodeAppDerivation {
pkgjson = builtins.fromJSON (builtins.readFile ./servers/health/package.json);
nodeDependencies = (callPackage ./servers/health/node-packages.nix {
inherit nodeEnv;
}).nodeDependencies;
path = ./servers/health;
};
in {
relayDeps = (callPackage ./servers/relay/node-packages.nix {
inherit nodeEnv;
}).nodeDependencies;
relayApp = relayApp;
relay = pkgs.dockerTools.buildLayeredImage {
name = "walletconnect/${
pkgs.lib.lists.last (builtins.split "_slash_" relayApp.pname)
}";
tag = "${relayApp.version}";
config = {
Cmd = [ "${myNodejs}/bin/node" "${relayApp}/dist" ];
Env = [
"GITHASH=${githash}"
];
};
};
health = pkgs.dockerTools.buildLayeredImage {
name = "walletconnect/${
pkgs.lib.lists.last (builtins.split "_slash_" healthApp.pname)
}";
tag = "${healthApp.version}";
config = {
Cmd = [ "${myNodejs}/bin/node" "${healthApp}/dist" ];
};
};
}