-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathdefault.nix
More file actions
150 lines (144 loc) · 3.49 KB
/
default.nix
File metadata and controls
150 lines (144 loc) · 3.49 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
makeWrapper,
lib,
stdenv,
purix,
purs-backend-es,
esbuild,
writeText,
nodejs,
compilers,
purs-versions,
dhall,
dhall-json,
git,
git-lfs,
licensee,
coreutils,
gzip,
gnutar,
# from the registry at the top level
spago-lock,
package-lock,
}:
let
# Since both the importer and the server share the same build process, we
# don't need to build them twice separately and can share an optimized output
# directory.
shared = stdenv.mkDerivation {
name = "registry-app-shared";
src = ./.;
phases = [
"buildPhase"
"installPhase"
];
nativeBuildInputs = [ purs-backend-es ];
buildPhase = ''
ln -s ${package-lock}/js/node_modules .
cp -r ${spago-lock.registry-app}/output .
echo "Optimizing with purs-backend-es..."
purs-backend-es build
'';
installPhase = ''
mkdir $out
mv output-es $out/output
'';
};
in
{
server = stdenv.mkDerivation rec {
name = "registry-server";
src = ./.;
database = ../db;
nativeBuildInputs = [
esbuild
makeWrapper
];
buildInputs = [ nodejs ];
entrypoint = writeText "entrypoint.js" ''
import { main } from "./output/Registry.App.Server";
main();
'';
buildPhase = ''
ln -s ${package-lock}/js/node_modules .
cp -r ${shared}/output .
cp ${entrypoint} entrypoint.js
esbuild entrypoint.js --bundle --outfile=${name}.js --platform=node --packages=external
'';
installPhase = ''
mkdir -p $out/bin
echo "Copying files..."
cp ${name}.js $out/${name}.js
ln -s ${package-lock}/js/node_modules $out
echo "Copying database..."
cp -r ${database} $out/bin/db
echo "Creating node script..."
echo '#!/usr/bin/env sh' > $out/bin/${name}
echo 'exec ${nodejs}/bin/node '"$out/${name}.js"' "$@"' >> $out/bin/${name}
chmod +x $out/bin/${name}
'';
postFixup = ''
wrapProgram $out/bin/${name} \
--set PATH ${
lib.makeBinPath [
compilers
purs-versions
dhall
dhall-json
licensee
git
git-lfs
coreutils
gzip
gnutar
]
} \
'';
};
github-importer = stdenv.mkDerivation rec {
name = "registry-github-importer";
src = ./.;
nativeBuildInputs = [
esbuild
makeWrapper
];
buildInputs = [ nodejs ];
entrypoint = writeText "entrypoint.js" ''
import { main } from "./output/Registry.App.GitHubIssue";
main();
'';
buildPhase = ''
ln -s ${package-lock}/js/node_modules .
cp -r ${shared}/output .
cp ${entrypoint} entrypoint.js
esbuild entrypoint.js --bundle --outfile=${name}.js --platform=node --packages=external
'';
installPhase = ''
mkdir -p $out/bin $out
echo "Copying files..."
cp ${name}.js $out/${name}.js
ln -s ${package-lock}/js/node_modules $out
echo "Creating node script..."
echo '#!/usr/bin/env sh' > $out/bin/${name}
echo 'exec ${nodejs}/bin/node '"$out/${name}.js"' "$@"' >> $out/bin/${name}
chmod +x $out/bin/${name}
'';
postFixup = ''
wrapProgram $out/bin/${name} \
--set PATH ${
lib.makeBinPath [
compilers
purs-versions
dhall
dhall-json
licensee
git
git-lfs
coreutils
gzip
gnutar
]
} \
'';
};
}