From 5729103df3e35b5139deac00cec9739da5d57ba5 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Tue, 13 Apr 2021 11:09:54 +0100 Subject: [PATCH] peertube: init at 3.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Izorkin # maybe as the author of this commit seems to be Steven Co-authored-by: Moritz Hedtke Co-authored-by: Steven Roose Co-authored-by: Matthias Beyer Co-authored-by: Ismaƫl Bouya --- pkgs/servers/peertube/default.nix | 157 ++++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 + 2 files changed, 161 insertions(+) create mode 100644 pkgs/servers/peertube/default.nix diff --git a/pkgs/servers/peertube/default.nix b/pkgs/servers/peertube/default.nix new file mode 100644 index 000000000000..67f7fd76606c --- /dev/null +++ b/pkgs/servers/peertube/default.nix @@ -0,0 +1,157 @@ +{ lib, stdenv, callPackage, fetchurl, fetchFromGitHub, buildGoModule, fetchYarnDeps, nixosTests +, esbuild, fixup_yarn_lock, jq, nodejs, yarn +, nodePackages, youtube-dl +}: +let + arch = + if stdenv.hostPlatform.system == "x86_64-linux" then "linux-x64" + else throw "Unsupported architecture: ${stdenv.hostPlatform.system}"; + + version = "3.4.1"; + + source = fetchFromGitHub { + owner = "Chocobozzz"; + repo = "PeerTube"; + rev = "v${version}"; + sha256 = "0l1ibqmliy4aq60a16v383v4ijv1c9sf2a35k9q365mkl42jbzx1"; + }; + + yarnOfflineCacheServer = fetchYarnDeps { + yarnLock = "${source}/yarn.lock"; + sha256 = "0zyxf1km79w6329jay4bcpw5bgvhnvmvl11r9hka5c6s46d3ms7n"; + }; + + yarnOfflineCacheTools = fetchYarnDeps { + yarnLock = "${source}/server/tools/yarn.lock"; + sha256 = "12xmwc8lnalcpx3nww457avn5zw04ly4pp4kjxkvhsqs69arfl2m"; + }; + + yarnOfflineCacheClient = fetchYarnDeps { + yarnLock = "${source}/client/yarn.lock"; + sha256 = "1glnip6mpizif36vil61sw8i8lnn0jg5hrqgqw6k4cc7hkd2qkpc"; + }; + + bcrypt_version = "5.0.1"; + bcrypt_lib = fetchurl { + url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v${bcrypt_version}/bcrypt_lib-v${bcrypt_version}-napi-v3-${arch}-glibc.tar.gz"; + sha256 = "3R3dBZyPansTuM77Nmm3f7BbTDkDdiT2HQIrti2Ottc="; + }; + + wrtc_version = "0.4.7"; + wrtc_lib = fetchurl { + url = "https://node-webrtc.s3.amazonaws.com/wrtc/v${wrtc_version}/Release/${arch}.tar.gz"; + sha256 = "1zd3jlwq3lc2vhmr3bs1h6mrzyswdp3y20vb4d9s67ir9q7jn1zf"; + }; + + esbuild_locked = buildGoModule rec { + pname = "esbuild"; + version = "0.12.17"; + + src = fetchFromGitHub { + owner = "evanw"; + repo = "esbuild"; + rev = "v${version}"; + sha256 = "16xxscha2y69mgm20rpjdxykyqiy0qy8gayh8046q6m0sf6834y1"; + }; + vendorSha256 = "1n5538yik72x94vzfq31qaqrkpxds5xys1wlibw2gn2am0z5c06q"; + }; + +in stdenv.mkDerivation rec { + inherit version; + pname = "peertube"; + src = source; + + nativeBuildInputs = [ esbuild fixup_yarn_lock jq nodejs yarn ]; + + buildInputs = [ nodePackages.node-gyp-build youtube-dl ]; + + buildPhase = '' + # Build node modules + export HOME=$PWD + fixup_yarn_lock ~/yarn.lock + fixup_yarn_lock ~/server/tools/yarn.lock + fixup_yarn_lock ~/client/yarn.lock + yarn config --offline set yarn-offline-mirror ${yarnOfflineCacheServer} + yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress + cd ~/server/tools + yarn config --offline set yarn-offline-mirror ${yarnOfflineCacheTools} + yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress + cd ~/client + yarn config --offline set yarn-offline-mirror ${yarnOfflineCacheClient} + yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress + + patchShebangs ~/node_modules + patchShebangs ~/server/tools/node_modules + patchShebangs ~/client/node_modules + patchShebangs ~/scripts + + # Fix bcrypt node module + cd ~/node_modules/bcrypt + if [ "${bcrypt_version}" != "$(cat package.json | jq -r .version)" ]; then + echo "Mismatching version please update bcrypt in derivation" + exit + fi + mkdir -p ./lib/binding && tar -C ./lib/binding -xf ${bcrypt_lib} + + # Fix youtube-dl node module + cd ~/node_modules/youtube-dl + mkdir ./bin + ln -s ${youtube-dl}/bin/youtube-dl ./bin/youtube-dl + cat > ./bin/details <