generated from MatrixAI/TypeScript-Demo-Lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.nix
115 lines (114 loc) · 2.97 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{ pkgs ? import ./pkgs.nix {} }:
with pkgs;
let
utils = callPackage ./utils.nix {};
buildElf = arch:
stdenv.mkDerivation rec {
name = "${utils.basename}-${version}-linux-${arch}";
version = utils.node2nixDev.version;
src = "${utils.node2nixDev}/lib/node_modules/${utils.node2nixDev.packageName}";
buildInputs = [
utils.pkg
];
PKG_CACHE_PATH = utils.pkgCachePath;
PKG_IGNORE_TAG = 1;
# ensure that native modules are built from source
npm_config_build_from_source = "true";
buildPhase = ''
cp ${./package.json} package.json
pkg . \
--targets linux-${arch} \
--no-bytecode \
--public \
--public-packages "*" \
--output out
'';
installPhase = ''
cp out $out
'';
dontFixup = true;
};
buildExe = arch:
stdenv.mkDerivation rec {
name = "${utils.basename}-${version}-win32-${arch}.exe";
version = utils.node2nixDev.version;
src = "${utils.node2nixDev}/lib/node_modules/${utils.node2nixDev.packageName}";
buildInputs = [
utils.pkg
];
PKG_CACHE_PATH = utils.pkgCachePath;
PKG_IGNORE_TAG = 1;
# ensure that native modules are built from source
npm_config_build_from_source = "true";
buildPhase = ''
cp ${./package.json} package.json
pkg . \
--targets win-${arch} \
--no-bytecode \
--public \
--public-packages "*" \
--output out.exe
'';
installPhase = ''
cp out.exe $out
'';
dontFixup = true;
};
buildMacho = arch:
stdenv.mkDerivation rec {
name = "${utils.basename}-${version}-macos-${arch}";
version = utils.node2nixDev.version;
src = "${utils.node2nixDev}/lib/node_modules/${utils.node2nixDev.packageName}";
buildInputs = [
utils.pkg
];
PKG_CACHE_PATH = utils.pkgCachePath;
PKG_IGNORE_TAG = 1;
# ensure that native modules are built from source
npm_config_build_from_source = "true";
buildPhase = ''
cp ${./package.json} package.json
pkg . \
--targets macos-${arch} \
--no-bytecode \
--public \
--public-packages "*" \
--output out
'';
installPhase = ''
cp out $out
'';
dontFixup = true;
};
in
rec {
application = callPackage ./default.nix {};
docker = dockerTools.buildImage {
name = application.name;
contents = [ application ];
keepContentsDirlinks = true;
extraCommands = ''
mkdir -m 1777 tmp
'';
config = {
Cmd = [ "/bin/typescript-demo-lib" ];
};
};
package = {
linux = {
x64 = {
elf = buildElf "x64";
};
};
windows = {
x64 = {
exe = buildExe "x64";
};
};
macos = {
x64 = {
macho = buildMacho "x64";
};
};
};
}