blob: 96795bc674b7b8eda7131d09e774dbe19382d9b3 (
plain) (
blame)
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
|
let
common = import ./common.nix;
pkgs = import common.pkgsSrc {};
nodejs = pkgs.${common.nodejs};
bower2nix =
bowerNix = pkgs.stdenv.mkDerivation {
name = "cryptpad-bower-ifd";
src = common.cryptpadSrc;
buildPhase = ''
${pkgs.nodePackages.bower2nix}/bin/bower2nix bower.json bower.nix
'';
installPhase = ''
cp bower.nix $out
'';
dontFixup = true;
};
bower = pkgs.buildBowerComponents {
name = "cryptpad-bower";
generated = bowerNix;
src = common.cryptpadSrc;
};
npmNix = pkgs.stdenv.mkDerivation {
name = "cryptpad-npm-ifd";
src = common.cryptpadSrc;
buildPhase = ''
${pkgs.nodePackages.node2nix}/bin/node2nix -l package-lock.json
'';
installPhase = ''
mkdir -p $out/
cp *.nix $out/
'';
dontFixup = true;
};
npm = (import npmNix {
inherit pkgs nodejs;
}).nodeDependencies;
in
pkgs.stdenv.mkDerivation {
name = "cryptpad";
src = common.cryptpadSrc;
installPhase = ''
mkdir -p $out/{bin,opt}
# copy the source code
cp -r customize.dist lib server.js www $out/opt/
# mount node_modules
ln -s ${npm}/lib/node_modules $out/opt/node_modules
# mount bower, based on the .bowerrc file at the git repo root
ln -s ${bower} $out/opt/www/bower_components
# cryptpad is bugged with absolute path, this is a workaround to use absolute path as relative path
ln -s / $out/opt/root
# start script
cat > $out/bin/cryptpad <<EOF
#!${pkgs.bash}/bin/bash
cd $out/opt/
export PATH="${npm}/bin:$PATH"
${nodejs}/bin/node server.js
EOF
chmod +x $out/bin/cryptpad
'';
dontFixup = true;
}
|