2022-10-05 08:27:09 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, callPackage
|
|
|
|
, fetchurl
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchYarnDeps
|
|
|
|
, nixosTests
|
|
|
|
, brotli
|
2023-11-22 22:51:22 +01:00
|
|
|
, prefetch-yarn-deps
|
2022-10-05 08:27:09 +02:00
|
|
|
, jq
|
|
|
|
, nodejs
|
|
|
|
, which
|
|
|
|
, yarn
|
2021-04-13 12:09:54 +02:00
|
|
|
}:
|
|
|
|
let
|
2022-10-05 08:27:09 +02:00
|
|
|
bcryptHostPlatformAttrs = {
|
|
|
|
x86_64-linux = {
|
|
|
|
arch = "linux-x64";
|
|
|
|
libc = "glibc";
|
|
|
|
hash = "sha256-I1ceMi7h6flvKBmMIU1qjAU1S6z5MzguHDul3g1zMKw=";
|
|
|
|
};
|
|
|
|
aarch64-linux = {
|
|
|
|
arch = "linux-arm64";
|
|
|
|
libc = "glibc";
|
|
|
|
hash = "sha256-q8BR7kILYV8i8ozDkpcuKarf4s1TgRqOrUeLqjdWEQ0=";
|
|
|
|
};
|
|
|
|
x86_64-darwin = {
|
|
|
|
arch = "darwin-x64";
|
|
|
|
libc = "unknown";
|
|
|
|
hash = "sha256-ONnXtRxcYFuFz+rmVTg+yEKe6J/vfKahX2i6k8dQStg=";
|
|
|
|
};
|
|
|
|
aarch64-darwin = {
|
|
|
|
arch = "darwin-arm64";
|
|
|
|
libc = "unknown";
|
|
|
|
hash = "sha256-VesAcT/IF2cvJVncJoqZcAvFxw32SN70C60GLU2kmVI=";
|
|
|
|
};
|
2022-09-26 17:12:59 +02:00
|
|
|
};
|
2022-10-05 08:27:09 +02:00
|
|
|
bcryptAttrs = bcryptHostPlatformAttrs."${stdenv.hostPlatform.system}" or
|
|
|
|
(throw "Unsupported architecture: ${stdenv.hostPlatform.system}");
|
|
|
|
bcryptVersion = "5.1.0";
|
|
|
|
bcryptLib = fetchurl {
|
|
|
|
url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v${bcryptVersion}/bcrypt_lib-v${bcryptVersion}-napi-v3-${bcryptAttrs.arch}-${bcryptAttrs.libc}.tar.gz";
|
|
|
|
inherit (bcryptAttrs) hash;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2022-09-26 17:12:59 +02:00
|
|
|
pname = "peertube";
|
2023-09-29 18:49:48 +02:00
|
|
|
version = "5.2.1";
|
2021-04-13 12:09:54 +02:00
|
|
|
|
2022-09-26 17:12:59 +02:00
|
|
|
src = fetchFromGitHub {
|
2021-04-13 12:09:54 +02:00
|
|
|
owner = "Chocobozzz";
|
|
|
|
repo = "PeerTube";
|
|
|
|
rev = "v${version}";
|
2023-09-29 18:49:48 +02:00
|
|
|
hash = "sha256-8JzU0JVb+JQCNiro8hPHBwkofNTUy90YkSCzTOoB+/A=";
|
2021-04-13 12:09:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnOfflineCacheServer = fetchYarnDeps {
|
2022-09-26 17:12:59 +02:00
|
|
|
yarnLock = "${src}/yarn.lock";
|
2023-09-29 18:49:48 +02:00
|
|
|
hash = "sha256-pzXH6hdDf8O6Kr12Xw0jRcnPRD2TrDGdiEfxVr3KmwY=";
|
2021-04-13 12:09:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnOfflineCacheTools = fetchYarnDeps {
|
2022-09-26 17:12:59 +02:00
|
|
|
yarnLock = "${src}/server/tools/yarn.lock";
|
2022-10-03 10:55:55 +02:00
|
|
|
hash = "sha256-maPR8OCiuNlle0JQIkZSgAqW+BrSxPwVm6CkxIrIg5k=";
|
2021-04-13 12:09:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnOfflineCacheClient = fetchYarnDeps {
|
2022-09-26 17:12:59 +02:00
|
|
|
yarnLock = "${src}/client/yarn.lock";
|
2023-09-29 18:49:48 +02:00
|
|
|
hash = "sha256-Ejzk/VEx7YtJpsrkHcXAZnJ+yRx1VhBJGpqquHYULNU=";
|
2021-04-13 12:09:54 +02:00
|
|
|
};
|
|
|
|
|
2023-11-22 22:51:22 +01:00
|
|
|
nativeBuildInputs = [ brotli prefetch-yarn-deps jq nodejs which yarn ];
|
2021-04-13 12:09:54 +02:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# Build node modules
|
|
|
|
export HOME=$PWD
|
2023-11-22 22:51:22 +01:00
|
|
|
fixup-yarn-lock ~/yarn.lock
|
|
|
|
fixup-yarn-lock ~/server/tools/yarn.lock
|
|
|
|
fixup-yarn-lock ~/client/yarn.lock
|
2022-09-26 17:12:59 +02:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCacheServer
|
2021-04-13 12:09:54 +02:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
|
|
|
|
cd ~/server/tools
|
2022-09-26 17:12:59 +02:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCacheTools
|
2021-04-13 12:09:54 +02:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
|
|
|
|
cd ~/client
|
2022-09-26 17:12:59 +02:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCacheClient
|
2021-04-13 12:09:54 +02: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
|
2022-10-05 08:27:09 +02:00
|
|
|
if [ "${bcryptVersion}" != "$(cat package.json | jq -r .version)" ]; then
|
2021-04-13 12:09:54 +02:00
|
|
|
echo "Mismatching version please update bcrypt in derivation"
|
|
|
|
exit
|
|
|
|
fi
|
2022-10-05 08:27:09 +02:00
|
|
|
mkdir -p ./lib/binding && tar -C ./lib/binding -xf ${bcryptLib}
|
2021-04-13 12:09:54 +02:00
|
|
|
|
2022-01-09 08:15:09 +01:00
|
|
|
# Return to home directory
|
|
|
|
cd ~
|
2021-04-13 12:09:54 +02:00
|
|
|
|
|
|
|
# Build PeerTube server
|
2022-03-09 18:36:00 +01: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 12:09:54 +02:00
|
|
|
|
|
|
|
# Build PeerTube tools
|
2022-03-09 18:36:00 +01:00
|
|
|
cp -r "./server/tools/node_modules" "./dist/server/tools"
|
2021-04-13 12:09:54 +02:00
|
|
|
npm run tsc -- --build ./server/tools/tsconfig.json
|
2022-10-03 10:55:55 +02:00
|
|
|
npm run resolve-tspaths:server
|
2021-04-13 12:09:54 +02: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
|
2022-09-13 14:52:40 +02:00
|
|
|
|
|
|
|
# Create static gzip and brotli files
|
|
|
|
find $out/client/dist -type f -regextype posix-extended -iregex '.*\.(css|eot|html|js|json|svg|webmanifest|xlf)' | while read file; do
|
|
|
|
gzip -9 -n -c $file > $file.gz
|
|
|
|
brotli --best -f $file -o $file.br
|
|
|
|
done
|
2021-04-13 12:09:54 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
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/";
|
2022-10-05 08:27:09 +02:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2023-05-09 11:22:44 +02:00
|
|
|
maintainers = with maintainers; [ immae izorkin mohe2015 stevenroose ];
|
2021-04-13 12:09:54 +02:00
|
|
|
};
|
|
|
|
}
|