]>
Commit | Line | Data |
---|---|---|
1feea3fe IB |
1 | # taken from nixpkgs to upgrade to latest version |
2 | { stdenv | |
3 | , pkgs | |
4 | , lib | |
5 | , buildBowerComponents | |
6 | , fetchurl | |
7 | , nodejs | |
8 | }: | |
9 | ||
10 | let | |
11 | nodePackages = import ./node-packages.nix { | |
12 | inherit pkgs nodejs; | |
13 | inherit (stdenv.hostPlatform) system; | |
14 | }; | |
15 | ||
16 | bowerPackages = buildBowerComponents { | |
17 | name = "${cryptpad.name}-bower-packages"; | |
18 | # this list had to be tweaked by hand: | |
19 | # * add the second jquery ~2.1.0 entry | |
20 | # * add the second bootstrap ~3.1.1 entry | |
21 | generated = ./bower-packages.nix; | |
22 | src = cryptpad.src; | |
23 | }; | |
24 | ||
25 | # find an element in an attribute set | |
26 | findValue = pred: default: set: | |
27 | let | |
28 | list = | |
29 | lib.concatMap | |
30 | (name: | |
31 | let v = set.${name}; in | |
32 | if pred name v then [v] else [] | |
33 | ) | |
34 | (lib.attrNames set) | |
35 | ; | |
36 | in | |
37 | if list == [] then default | |
38 | else lib.head list | |
39 | ; | |
40 | ||
41 | # The cryptpad package attribute key changes for each release. Get it out | |
42 | # programatically instead. | |
43 | cryptpad = findValue | |
44 | (k: v: v.packageName == "cryptpad") | |
45 | (throw "cryptpad not found") | |
46 | nodePackages | |
47 | ; | |
48 | ||
49 | combined = cryptpad.override { | |
50 | postInstall = '' | |
51 | out_cryptpad=$out/lib/node_modules/cryptpad | |
52 | ||
53 | substituteInPlace $out_cryptpad/lib/workers/index.js --replace "lib/workers/db-worker" "$out_cryptpad/lib/workers/db-worker" | |
54 | ||
55 | # add the bower components | |
56 | ln -sv \ | |
57 | ${bowerPackages}/bower_components \ | |
58 | $out_cryptpad/www/bower_components | |
59 | ||
60 | # add executable | |
61 | mkdir $out/bin | |
62 | cat <<EOF > $out/bin/cryptpad | |
63 | #!${stdenv.shell} | |
64 | exec ${nodejs}/bin/node $out_cryptpad/server.js | |
65 | EOF | |
66 | chmod +x $out/bin/cryptpad | |
67 | ''; | |
68 | }; | |
69 | in | |
70 | combined |