-
Notifications
You must be signed in to change notification settings - Fork 3
/
default.nix
60 lines (51 loc) · 2.34 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
{ reflex-platform ? import ./deps/reflex-platform {} }:
let nixpkgs = reflex-platform.nixpkgs;
in nixpkgs.stdenv.mkDerivation (rec {
name = "hsnippet";
snaplets = ./app/snaplets;
static = ./app/static;
app = ./app;
deps = ./deps;
lib = ./hsnippet-lib;
deploy = ./deploy;
userbuild = ./userbuild;
backend = import ./backend { nixpkgs = reflex-platform.nixpkgs; };
frontend = import ./frontend { inherit reflex-platform; };
develCfgTemplate = ./app/devel.cfg.template;
buildEnv = (import ./userbuild/default.nix {}).env.nativeBuildInputs;
myNixPkgs = nixpkgs.path;
builder = builtins.toFile "builder.sh" ''
source "$stdenv/setup"
set -x
mkdir -p "$out"
ln -s "$myNixPkgs" "$out/nixpkgs"
cp -r --no-preserve=mode "$static" "$out/static"
cp -r --no-preserve=mode "$snaplets" "$out/snaplets"
ln -s "$static" "$out/static"
ln -s "$userbuild" "$out/userbuild-template"
ln -s "$lib" "$out/hsnippet-lib"
mkdir -p "$out/deps"
ln -s "$deps/diagrams-reflex" "$out/deps/diagrams-reflex"
ln -s "$deps/reflex-dom-contrib" "$out/deps/reflex-dom-contrib"
ln -s "$deps/reflex-platform" "$out/deps/reflex-platform"
echo "$buildEnv" >"$out/buildEnv"
rm -f "$out/static/rts.js"
rm -f "$out/static/lib.js"
rm -f "$out/static/hsnippet.js"
ln -s "$frontend/bin/hsnippet-frontend.jsexe/rts.js" "$out/static"
ln -s "$frontend/bin/hsnippet-frontend.jsexe/lib.js" "$out/static"
cat "$frontend/bin/hsnippet-frontend.jsexe/out.js" "$frontend/bin/hsnippet-frontend.jsexe/runmain.js" > "$out/static/hsnippet.js"
# closure-compiler -O ADVANCED --js_output_file="$out/static/rts.js" "$frontend/bin/hsnippet-frontend.jsexe/rts.js"
# closure-compiler -O ADVANCED --js_output_file="$out/static/lib.js" "$frontend/bin/hsnippet-frontend.jsexe/lib.js"
# cat "$frontend/bin/hsnippet-frontend.jsexe/out.js" "$frontend/bin/hsnippet-frontend.jsexe/runmain.js" > "$out/static/hsnippet-unoptimized.js"
# closure-compiler -O ADVANCED --js_output_file="$out/static/hsnippet.js" "$out/static/hsnippet-unoptimized.js"
mkdir "$out/bin"
ln -s "$backend/bin/main" "$out/bin"
ln -s "$backend/bin/build-snippet" "$out/bin"
ln -s "$deploy/setup-env.sh" "$out/bin/setup-env.sh"
ln -s "$develCfgTemplate" "$out/devel.cfg.template"
'';
buildInputs = with nixpkgs; [
closurecompiler
];
})