X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=pkgs%2Fwebapps%2Fpeertube%2Fdefault.nix;h=3642a4477b1f26a6416f80a9815f2cc31d560266;hb=8a05c7fb2e7aad81ce4eb31b5173f4dabf353e31;hp=a04d4908118e30bdbda41f9e25a17fa377ec4aca;hpb=598aaa373c359046ee08ab5e7576ebaa4f0331e0;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/pkgs/webapps/peertube/default.nix b/pkgs/webapps/peertube/default.nix index a04d490..3642a44 100644 --- a/pkgs/webapps/peertube/default.nix +++ b/pkgs/webapps/peertube/default.nix @@ -1,123 +1,213 @@ -{ ldap ? false -, lib, stdenv, fetchzip, youtube-dl, fetchurl, mylibs, python, nodejs, nodePackages }: +{ ldap ? false, sendmail ? false, light ? null, syden ? false, runCommand, libsass +, lib, stdenv, rsync, fetchzip, youtube-dl, fetchurl, mylibs, python, nodejs, nodePackages, yarn2nix-moretea }: let nodeHeaders = fetchurl { url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz"; - sha256 = "16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32"; + sha256 = "1df3yhlwlvai0m9kvjyknjg11hnw0kj0rnhyzbwvsfjnmr6z8r76"; }; - patchedPackages = stdenv.mkDerivation (mylibs.fetchedGithub ./peertube.json // rec { - patches = if ldap then [ ./ldap.patch ././yarn_fix_bluebird_ldap.patch ] else [ ./yarn_fix_bluebird.patch ]; - installPhase = '' + source = mylibs.fetchedGithub ./peertube.json; + patchedSource = stdenv.mkDerivation (source // rec { + phases = [ "unpackPhase" "patchPhase" "installPhase" ]; + patches = [ ./yarn_fix_http_node.patch ] + ++ lib.optionals ldap [ ./ldap.patch ] + ++ lib.optionals sendmail [ ./sendmail.patch ] + ++ lib.optionals syden [ ./syden.patch ]; + installPhase = let + # Peertube supports several languages, but they take a very long + # time to build. The build script accepts --light which builds + # only English, and --light-fr which only builds English + French. + # This small hack permits to builds only English + A chosen + # language depending on the value of "light" + # Default (null) is to build every language + lightFix = if light == true || light == null then "" else '' + sed -i -e "s/fr-FR/${light}/g" -e "s/--light-fr/--light-language/" $out/scripts/build/client.sh + ''; + in '' mkdir $out - cp package.json yarn.lock $out/ + cp -a . $out/ + ${lightFix} ''; }); - # if yarn complains about - # TypeError: Cannot read property 'lang' of undefined yarn - # make sure that all package names in yarn-packages.nix finish in - # .tar.gz where due (especially jsonld-signatures) - # Most errors where due to jsonld-signature (name, git version, etc.) - # or bluebird (3.5.18 instead vs 3.5.21) - yarnModulesArg = rec { - pname = "peertube-yarn-modules"; - version = "1.2.0"; - name = "peertube-yarn-modules-${version}"; - packageJSON = "${patchedPackages}/package.json"; - yarnLock = "${patchedPackages}/yarn.lock"; - yarnNix = ./yarn-packages.nix; - pkgConfig = { - all = { - buildInputs = [ mylibs.yarn2nixPackage.src ]; - }; - bcrypt = { - buildInputs = [ nodePackages.node-pre-gyp ]; - postInstall = let - bcrypt_lib = fetchurl { - 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"; - sha256 = "04bj3yn1wi8a6izihskyks0bb4nls3mndgb2yj12iraiv5dmg097"; + serverPatchedPackage = runCommand "server-package" {} '' + mkdir -p $out + cp ${patchedSource}/package.json $out/ + cp ${patchedSource}/yarn.lock $out/ + ''; + clientPatchedPackage = runCommand "client-package" {} '' + mkdir -p $out + cp ${patchedSource}/client/package.json $out/ + cp ${patchedSource}/client/yarn.lock $out/ + ''; + + yarnModulesConfig = { + bcrypt = { + buildInputs = [ nodePackages.node-pre-gyp ]; + postInstall = let + bcrypt_lib = fetchurl { + url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v64-linux-x64-glibc.tar.gz"; + sha256 = "0gbq4grhp5wl0f9yqb4y43kjfh8nivfd6y0nkv1x6gfvs2v23wb0"; + }; + in + '' + mkdir lib && tar -C lib -xf ${bcrypt_lib} + patchShebangs ../node-pre-gyp + npm run install + ''; + }; + dtrace-provider = { + buildInputs = [ python nodePackages.node-gyp ]; + postInstall = '' + npx node-gyp rebuild --tarball=${nodeHeaders} + ''; + }; + node-sass = { + buildInputs = [ libsass python ]; + postInstall = + '' + node scripts/build.js --tarball=${nodeHeaders} + ''; + }; + + sharp = { + buildInputs = [ python nodePackages.node-gyp ]; + postInstall = + let + tarball = fetchurl { + url = "https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linux-x64.tar.gz"; + sha256 = "0xqv61g6s6rkvc31zq9a3bf8rp56ijnpw0xhr91hc88asqprd5yh"; }; in - '' - mkdir lib && tar -C lib -xf ${bcrypt_lib} - patchShebangs ../node-pre-gyp - npm run install - ''; - }; - dtrace-provider = { - buildInputs = [ python nodePackages.node-gyp ]; - postInstall = '' - npx node-gyp rebuild --tarball=${nodeHeaders} - ''; - }; - rdf-canonize = { - buildInputs = [ python nodePackages.node-gyp ]; - postInstall = '' - npx node-gyp rebuild --tarball=${nodeHeaders} - ''; - }; - sharp = { - buildInputs = [ python nodePackages.node-gyp ]; - postInstall = - let - tarball = fetchurl { - url = "https://github.com/lovell/sharp-libvips/releases/download/v8.7.0/libvips-8.7.0-linux-x64.tar.gz"; - sha256 = "1sq7qrp1q1pcrd165c3sky7qjx1kqihfpr4ailb5k73rwyh8lxg4"; - }; - in - '' - mkdir vendor - tar -C vendor -xf ${tarball} - patchShebangs ../prebuild-install - npx node install/libvips - npx node install/dll-copy - npx prebuild-install || npx node-gyp rebuild --tarball=${nodeHeaders} - ''; - }; - utf-8-validate = { - buildInputs = [ nodePackages.node-gyp-build ]; - }; - youtube-dl = { - postInstall = '' - mkdir bin - ln -s ${youtube-dl}/bin/youtube-dl bin/youtube-dl - cat > bin/details < bin/details <