diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-12-13 21:25:24 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-24 01:40:13 +0200 |
commit | 24fd1fe6c62b7a9fc347794fde043285da272f5c (patch) | |
tree | 65557bf1d241ca389b619dbd24d18d51932ee030 /pkgs/webapps/peertube/default.nix | |
download | NUR-24fd1fe6c62b7a9fc347794fde043285da272f5c.tar.gz NUR-24fd1fe6c62b7a9fc347794fde043285da272f5c.tar.zst NUR-24fd1fe6c62b7a9fc347794fde043285da272f5c.zip |
Initial commit published for NUR
Diffstat (limited to 'pkgs/webapps/peertube/default.nix')
-rw-r--r-- | pkgs/webapps/peertube/default.nix | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/pkgs/webapps/peertube/default.nix b/pkgs/webapps/peertube/default.nix new file mode 100644 index 00000000..a04d4908 --- /dev/null +++ b/pkgs/webapps/peertube/default.nix | |||
@@ -0,0 +1,123 @@ | |||
1 | { ldap ? false | ||
2 | , lib, stdenv, fetchzip, youtube-dl, fetchurl, mylibs, python, nodejs, nodePackages }: | ||
3 | let | ||
4 | nodeHeaders = fetchurl { | ||
5 | url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz"; | ||
6 | sha256 = "16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32"; | ||
7 | }; | ||
8 | patchedPackages = stdenv.mkDerivation (mylibs.fetchedGithub ./peertube.json // rec { | ||
9 | patches = if ldap then [ ./ldap.patch ././yarn_fix_bluebird_ldap.patch ] else [ ./yarn_fix_bluebird.patch ]; | ||
10 | installPhase = '' | ||
11 | mkdir $out | ||
12 | cp package.json yarn.lock $out/ | ||
13 | ''; | ||
14 | }); | ||
15 | # if yarn complains about | ||
16 | # TypeError: Cannot read property 'lang' of undefined yarn | ||
17 | # make sure that all package names in yarn-packages.nix finish in | ||
18 | # .tar.gz where due (especially jsonld-signatures) | ||
19 | # Most errors where due to jsonld-signature (name, git version, etc.) | ||
20 | # or bluebird (3.5.18 instead vs 3.5.21) | ||
21 | yarnModulesArg = rec { | ||
22 | pname = "peertube-yarn-modules"; | ||
23 | version = "1.2.0"; | ||
24 | name = "peertube-yarn-modules-${version}"; | ||
25 | packageJSON = "${patchedPackages}/package.json"; | ||
26 | yarnLock = "${patchedPackages}/yarn.lock"; | ||
27 | yarnNix = ./yarn-packages.nix; | ||
28 | pkgConfig = { | ||
29 | all = { | ||
30 | buildInputs = [ mylibs.yarn2nixPackage.src ]; | ||
31 | }; | ||
32 | bcrypt = { | ||
33 | buildInputs = [ nodePackages.node-pre-gyp ]; | ||
34 | postInstall = let | ||
35 | bcrypt_lib = fetchurl { | ||
36 | url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v57-linux-x64-glibc.tar.gz"; | ||
37 | sha256 = "04bj3yn1wi8a6izihskyks0bb4nls3mndgb2yj12iraiv5dmg097"; | ||
38 | }; | ||
39 | in | ||
40 | '' | ||
41 | mkdir lib && tar -C lib -xf ${bcrypt_lib} | ||
42 | patchShebangs ../node-pre-gyp | ||
43 | npm run install | ||
44 | ''; | ||
45 | }; | ||
46 | dtrace-provider = { | ||
47 | buildInputs = [ python nodePackages.node-gyp ]; | ||
48 | postInstall = '' | ||
49 | npx node-gyp rebuild --tarball=${nodeHeaders} | ||
50 | ''; | ||
51 | }; | ||
52 | rdf-canonize = { | ||
53 | buildInputs = [ python nodePackages.node-gyp ]; | ||
54 | postInstall = '' | ||
55 | npx node-gyp rebuild --tarball=${nodeHeaders} | ||
56 | ''; | ||
57 | }; | ||
58 | sharp = { | ||
59 | buildInputs = [ python nodePackages.node-gyp ]; | ||
60 | postInstall = | ||
61 | let | ||
62 | tarball = fetchurl { | ||
63 | url = "https://github.com/lovell/sharp-libvips/releases/download/v8.7.0/libvips-8.7.0-linux-x64.tar.gz"; | ||
64 | sha256 = "1sq7qrp1q1pcrd165c3sky7qjx1kqihfpr4ailb5k73rwyh8lxg4"; | ||
65 | }; | ||
66 | in | ||
67 | '' | ||
68 | mkdir vendor | ||
69 | tar -C vendor -xf ${tarball} | ||
70 | patchShebangs ../prebuild-install | ||
71 | npx node install/libvips | ||
72 | npx node install/dll-copy | ||
73 | npx prebuild-install || npx node-gyp rebuild --tarball=${nodeHeaders} | ||
74 | ''; | ||
75 | }; | ||
76 | utf-8-validate = { | ||
77 | buildInputs = [ nodePackages.node-gyp-build ]; | ||
78 | }; | ||
79 | youtube-dl = { | ||
80 | postInstall = '' | ||
81 | mkdir bin | ||
82 | ln -s ${youtube-dl}/bin/youtube-dl bin/youtube-dl | ||
83 | cat > bin/details <<EOF | ||
84 | {"version":"${youtube-dl.version}","path":null,"exec":"youtube-dl"} | ||
85 | EOF | ||
86 | ''; | ||
87 | }; | ||
88 | }; | ||
89 | }; | ||
90 | yarnModules = mylibs.yarn2nixPackage.mkYarnModules yarnModulesArg; | ||
91 | yarnModulesProd = mylibs.yarn2nixPackage.mkYarnModules (yarnModulesArg // { yarnFlags = mylibs.yarn2nixPackage.defaultYarnFlags ++ [ "--production" ]; }); | ||
92 | patchedServer = stdenv.mkDerivation (mylibs.fetchedGithub ./peertube.json // rec { | ||
93 | patches = lib.optionals ldap [ ./ldap.patch ] ++ [ ./sendmail.patch ]; | ||
94 | buildPhase = '' | ||
95 | ln -s ${yarnModules}/node_modules . | ||
96 | npm run build:server | ||
97 | ''; | ||
98 | installPhase = '' | ||
99 | mkdir $out | ||
100 | cp -a dist/server $out | ||
101 | ''; | ||
102 | buildInputs = [ nodejs yarnModules ]; | ||
103 | }); | ||
104 | in | ||
105 | stdenv.mkDerivation rec { | ||
106 | version = "v1.2.0"; | ||
107 | name = "peertube-${version}"; | ||
108 | src = fetchzip { | ||
109 | url = "https://github.com/Chocobozzz/PeerTube/releases/download/${version}/${name}.zip"; | ||
110 | sha256 = "18fp3fy1crw67gdpc29nr38b5zy2f68l70w47zwp7dzhd8bbbipp"; | ||
111 | }; | ||
112 | patches = lib.optionals ldap [ ./ldap_yarn.patch ]; | ||
113 | buildPhase = '' | ||
114 | ln -s ${yarnModulesProd}/node_modules . | ||
115 | rm -rf dist/server && cp -a ${patchedServer}/server dist | ||
116 | ''; | ||
117 | installPhase = '' | ||
118 | mkdir $out | ||
119 | cp -a * $out | ||
120 | ln -s /tmp $out/.cache | ||
121 | ''; | ||
122 | buildInputs = [ yarnModulesProd ]; | ||
123 | } | ||