2 , lib, stdenv, fetchzip, youtube-dl, fetchurl, mylibs, python, nodejs, nodePackages }:
4 nodeHeaders = fetchurl {
5 url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
6 sha256 = "1g6zi96k8sbim8wa8rzskxy44mgpcv1mn2bs8p4mq36w3kwglwyj";
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 ];
12 cp package.json yarn.lock $out/
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";
24 name = "peertube-yarn-modules-${version}";
25 packageJSON = "${patchedPackages}/package.json";
26 yarnLock = "${patchedPackages}/yarn.lock";
27 yarnNix = ./yarn-packages.nix;
30 buildInputs = [ mylibs.yarn2nixPackage.src ];
33 buildInputs = [ nodePackages.node-pre-gyp ];
35 bcrypt_lib = fetchurl {
36 url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v64-linux-x64-glibc.tar.gz";
37 sha256 = "0i0dx4h52fqi3mda2zzqrxp2fh7spbvf7h88mjk218h8d7vl53yx";
41 mkdir lib && tar -C lib -xf ${bcrypt_lib}
42 patchShebangs ../node-pre-gyp
47 buildInputs = [ python nodePackages.node-gyp ];
49 npx node-gyp rebuild --tarball=${nodeHeaders}
53 buildInputs = [ python nodePackages.node-gyp ];
55 npx node-gyp rebuild --tarball=${nodeHeaders}
59 buildInputs = [ python nodePackages.node-gyp ];
63 url = "https://github.com/lovell/sharp-libvips/releases/download/v8.7.0/libvips-8.7.0-linux-x64.tar.gz";
64 sha256 = "1sq7qrp1q1pcrd165c3sky7qjx1kqihfpr4ailb5k73rwyh8lxg4";
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}
77 buildInputs = [ nodePackages.node-gyp-build ];
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"}
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 ];
95 ln -s ${yarnModules}/node_modules .
100 cp -a dist/server $out
102 buildInputs = [ nodejs yarnModules ];
105 stdenv.mkDerivation rec {
107 name = "peertube-${version}";
109 url = "https://github.com/Chocobozzz/PeerTube/releases/download/${version}/${name}.zip";
110 sha256 = "18fp3fy1crw67gdpc29nr38b5zy2f68l70w47zwp7dzhd8bbbipp";
112 patches = lib.optionals ldap [ ./ldap_yarn.patch ];
114 ln -s ${yarnModulesProd}/node_modules .
115 rm -rf dist/server && cp -a ${patchedServer}/server dist
120 ln -s /tmp $out/.cache
122 buildInputs = [ yarnModulesProd ];