2022-10-03 08:55:55 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, callPackage
|
|
|
|
, fetchurl
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildGoModule
|
|
|
|
, fetchYarnDeps
|
|
|
|
, nixosTests
|
|
|
|
, fixup_yarn_lock
|
|
|
|
, jq
|
|
|
|
, nodejs
|
|
|
|
, which
|
|
|
|
, yarn
|
2021-04-13 10:09:54 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
arch =
|
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then "linux-x64"
|
|
|
|
else throw "Unsupported architecture: ${stdenv.hostPlatform.system}";
|
|
|
|
|
2022-09-26 15:12:59 +00:00
|
|
|
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";
|
2022-10-03 08:55:55 +00:00
|
|
|
hash = "sha256-3R3dBZyPansTuM77Nmm3f7BbTDkDdiT2HQIrti2Ottc=";
|
2022-09-26 15:12:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "peertube";
|
2022-10-03 08:55:55 +00:00
|
|
|
version = "4.3.0";
|
2021-04-13 10:09:54 +00:00
|
|
|
|
2022-09-26 15:12:59 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-04-13 10:09:54 +00:00
|
|
|
owner = "Chocobozzz";
|
|
|
|
repo = "PeerTube";
|
|
|
|
rev = "v${version}";
|
2022-10-03 08:55:55 +00:00
|
|
|
hash = "sha256-1QpJtonn/mWGcTv2mSeGKAHwPAqOV6VBAYFZH1/jAH8=";
|
2021-04-13 10:09:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnOfflineCacheServer = fetchYarnDeps {
|
2022-09-26 15:12:59 +00:00
|
|
|
yarnLock = "${src}/yarn.lock";
|
2022-10-03 08:55:55 +00:00
|
|
|
hash = "sha256-BimtZpU3aZepvlMfhJ/u0trk1rUsGlzjYk2G90fstII=";
|
2021-04-13 10:09:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnOfflineCacheTools = fetchYarnDeps {
|
2022-09-26 15:12:59 +00:00
|
|
|
yarnLock = "${src}/server/tools/yarn.lock";
|
2022-10-03 08:55:55 +00:00
|
|
|
hash = "sha256-maPR8OCiuNlle0JQIkZSgAqW+BrSxPwVm6CkxIrIg5k=";
|
2021-04-13 10:09:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnOfflineCacheClient = fetchYarnDeps {
|
2022-09-26 15:12:59 +00:00
|
|
|
yarnLock = "${src}/client/yarn.lock";
|
2022-10-03 08:55:55 +00:00
|
|
|
hash = "sha256-IKMu+gQa+d30+yXjHCu/oQOQXL6kTN9WxDI/Y5IL1E8=";
|
2021-04-13 10:09:54 +00:00
|
|
|
};
|
|
|
|
|
2022-10-03 08:55:55 +00:00
|
|
|
nativeBuildInputs = [ fixup_yarn_lock jq nodejs which yarn ];
|
2021-04-13 10:09:54 +00:00
|
|
|
|
|
|
|
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
|
2022-09-26 15:12:59 +00:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCacheServer
|
2021-04-13 10:09:54 +00:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
|
|
|
|
cd ~/server/tools
|
2022-09-26 15:12:59 +00:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCacheTools
|
2021-04-13 10:09:54 +00:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
|
|
|
|
cd ~/client
|
2022-09-26 15:12:59 +00:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCacheClient
|
2021-04-13 10:09:54 +00:00
|
|
|
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}
|
|
|
|
|
2022-01-09 07:15:09 +00:00
|
|
|
# Return to home directory
|
|
|
|
cd ~
|
2021-04-13 10:09:54 +00:00
|
|
|
|
|
|
|
# Build PeerTube server
|
2022-03-09 17:36:00 +00:00
|
|
|
npm run tsc -- --build ./tsconfig.json
|
|
|
|
npm run resolve-tspaths:server
|
|
|
|
cp -r "./server/static" "./server/assets" "./dist/server"
|
|
|
|
cp -r "./server/lib/emails" "./dist/server/lib"
|
2021-04-13 10:09:54 +00:00
|
|
|
|
|
|
|
# Build PeerTube tools
|
2022-03-09 17:36:00 +00:00
|
|
|
cp -r "./server/tools/node_modules" "./dist/server/tools"
|
2021-04-13 10:09:54 +00:00
|
|
|
npm run tsc -- --build ./server/tools/tsconfig.json
|
2022-10-03 08:55:55 +00:00
|
|
|
npm run resolve-tspaths:server
|
2021-04-13 10:09:54 +00:00
|
|
|
|
|
|
|
# Build PeerTube client
|
|
|
|
npm run build:client
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/dist
|
|
|
|
mv ~/dist $out
|
|
|
|
mv ~/node_modules $out/node_modules
|
|
|
|
mv ~/server/tools/node_modules $out/dist/server/tools/node_modules
|
|
|
|
mkdir $out/client
|
|
|
|
mv ~/client/{dist,node_modules,package.json,yarn.lock} $out/client
|
|
|
|
mv ~/{config,scripts,support,CREDITS.md,FAQ.md,LICENSE,README.md,package.json,tsconfig.json,yarn.lock} $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.tests.peertube = nixosTests.peertube;
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A free software to take back control of your videos";
|
|
|
|
longDescription = ''
|
|
|
|
PeerTube aspires to be a decentralized and free/libre alternative to video
|
|
|
|
broadcasting services.
|
|
|
|
PeerTube is not meant to become a huge platform that would centralize
|
|
|
|
videos from all around the world. Rather, it is a network of
|
|
|
|
inter-connected small videos hosters.
|
|
|
|
Anyone with a modicum of technical skills can host a PeerTube server, aka
|
|
|
|
an instance. Each instance hosts its users and their videos. In this way,
|
|
|
|
every instance is created, moderated and maintained independently by
|
|
|
|
various administrators.
|
|
|
|
You can still watch from your account videos hosted by other instances
|
|
|
|
though if the administrator of your instance had previously connected it
|
|
|
|
with other instances.
|
|
|
|
'';
|
|
|
|
license = licenses.agpl3Plus;
|
|
|
|
homepage = "https://joinpeertube.org/";
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = with maintainers; [ immae izorkin matthiasbeyer mohe2015 stevenroose ];
|
|
|
|
};
|
|
|
|
}
|