diff --git a/pkgs/default.nix b/pkgs/default.nix index 74ea8e6..fe78838 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -32,6 +32,8 @@ let --prefix "LD_LIBRARY_PATH" : "${pkgs.lib.makeLibraryPath wrapLibraries}" ''; }); + + peertube = callPackage ./peertube { nodejs = pkgs.nodejs-12_x; }; }; in pkgs.extend(_: _: newpkgs) diff --git a/pkgs/peertube/default.nix b/pkgs/peertube/default.nix new file mode 100644 index 0000000..31ba6c1 --- /dev/null +++ b/pkgs/peertube/default.nix @@ -0,0 +1,141 @@ +{ stdenv, yarn2nix-moretea, lib, nodePackages, fetchFromGitHub, fetchurl, youtube-dl, jq, nodejs }: + +let + inherit (yarn2nix-moretea) mkYarnPackage defaultYarnFlags; +in rec { + mkYarnModules = args: (yarn2nix-moretea.mkYarnModules args).overrideAttrs(old: { + buildPhase = builtins.replaceStrings [" ./package.json"] [" /dev/null; cp deps/*/package.json ."] old.buildPhase; + }); + + source = stdenv.mkDerivation { + name = "peertube-src"; + src = fetchFromGitHub { + owner = "Chocobozzz"; + repo = "peertube"; + rev = "v3.0.1"; + sha256 = "0zrrhc5kml7mqxafmr8yggiakjh3a33wvn2m1i6ij112nkjyv1bc"; + }; + + phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ]; + patches = [ ./fix-yarnlock.patch ]; + + installPhase = '' + mkdir $out + cp -a . $out + ''; + + fixupPhase = '' + patchShebangs $out/scripts + ''; + }; + + nodeHeaders = fetchurl { + url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz"; + sha256 = "18nsc6qc3f367vk63bm3wwmcw6lwi8jqxgv025jnv9mc539zx4iy"; + }; + + yarnModulesConfig = { + bcrypt = { + buildInputs = [ nodePackages.node-pre-gyp ]; + postInstall = let + bcrypt_version = "5.0.0"; + bcrypt_lib = fetchurl { + url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v${bcrypt_version}/bcrypt_lib-v${bcrypt_version}-napi-v3-linux-x64-glibc.tar.gz"; + sha256 = "0j3p2px1xb17sw3gpm8l4apljajxxfflal1yy552mhpzhi21wccn"; + }; + in + '' + if [ "${bcrypt_version}" != "$(cat package.json | ${jq}/bin/jq -r .version)" ]; then + echo "Mismatching version please update bcrypt in derivation" + false + fi + mkdir -p lib/binding && tar -C lib/binding -xf ${bcrypt_lib} + patchShebangs ../node-pre-gyp + npm run install + ''; + }; + 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 <