17 bcryptHostPlatformAttrs = {
21 hash = "sha256-C5N6VgFtXPLLjZt0ZdRTX095njRIT+12ONuUaBBj7fQ=";
26 hash = "sha256-TerDujO+IkSRnHYlSbAKSP9IS7AT7XnQJsZ8D8pCoGc=";
31 hash = "sha256-gphOONWujbeCCr6dkmMRJP94Dhp1Jvp2yt+g7n1HTv0=";
34 arch = "darwin-arm64";
36 hash = "sha256-JMnELVUxoU1C57Tzue3Sg6OfDFAjfCnzgDit0BWzmlo=";
39 bcryptAttrs = bcryptHostPlatformAttrs."${stdenv.hostPlatform.system}" or
40 (throw "Unsupported architecture: ${stdenv.hostPlatform.system}");
41 bcryptVersion = "5.1.1";
42 bcryptLib = fetchurl {
43 url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v${bcryptVersion}/bcrypt_lib-v${bcryptVersion}-napi-v3-${bcryptAttrs.arch}-${bcryptAttrs.libc}.tar.gz";
44 inherit (bcryptAttrs) hash;
47 stdenv.mkDerivation rec {
51 src = fetchFromGitHub {
55 hash = "sha256-FxXIvibwdRcv8OaTQEXiM6CvWOIptfQXDQ1/PW910wg=";
58 yarnOfflineCacheServer = fetchYarnDeps {
59 yarnLock = "${src}/yarn.lock";
60 hash = "sha256-RJX92EgEIXWB1wNFRl8FvseOqBT+7m6gs+pMyoodruk=";
63 yarnOfflineCacheClient = fetchYarnDeps {
64 yarnLock = "${src}/client/yarn.lock";
65 hash = "sha256-vr9xn5NXwiUS59Kgl8olCtkMgxnI1TKQzibKbb8RNXA=";
68 yarnOfflineCacheAppsCli = fetchYarnDeps {
69 yarnLock = "${src}/apps/peertube-cli/yarn.lock";
70 hash = "sha256-xsB71bnaPn/9/f1KHyU3TTwx+Q+1dLjWmNK2aVJgoRY=";
73 yarnOfflineCacheAppsRunner = fetchYarnDeps {
74 yarnLock = "${src}/apps/peertube-runner/yarn.lock";
75 hash = "sha256-9w3aLuiLs7SU00YwuE0ixfiD77gCakXT4YeRpfsgGz0=";
78 outputs = [ "out" "cli" "runner" ];
80 nativeBuildInputs = [ brotli fixup-yarn-lock jq which yarn fd ];
82 buildInputs = [ nodejs ];
87 fixup-yarn-lock ~/yarn.lock
88 fixup-yarn-lock ~/client/yarn.lock
89 fixup-yarn-lock ~/apps/peertube-cli/yarn.lock
90 fixup-yarn-lock ~/apps/peertube-runner/yarn.lock
91 yarn config --offline set yarn-offline-mirror $yarnOfflineCacheServer
92 yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
94 yarn config --offline set yarn-offline-mirror $yarnOfflineCacheClient
95 yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
96 cd ~/apps/peertube-cli
97 yarn config --offline set yarn-offline-mirror $yarnOfflineCacheAppsCli
98 yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
99 cd ~/apps/peertube-runner
100 yarn config --offline set yarn-offline-mirror $yarnOfflineCacheAppsRunner
101 yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
103 patchShebangs ~/{node_modules,client/node_modules,/apps/peertube-cli/node_modules,apps/peertube-runner/node_modules,scripts}
105 # Fix bcrypt node module
106 cd ~/node_modules/bcrypt
107 if [ "${bcryptVersion}" != "$(cat package.json | jq -r .version)" ]; then
108 echo "Mismatching version please update bcrypt in derivation"
111 mkdir -p ./lib/binding && tar -C ./lib/binding -xf ${bcryptLib}
113 # Return to home directory
116 # Build PeerTube server
119 # Build PeerTube client
123 npm run build:peertube-cli
124 patchShebangs ~/apps/peertube-cli/dist/peertube.js
126 # Build PeerTube runner
127 npm run build:peertube-runner
128 patchShebangs ~/apps/peertube-runner/dist/peertube-runner.js
130 # Clean up declaration files
132 ~/packages/core-utils/dist/ \
133 ~/packages/ffmpeg/dist/ \
134 ~/packages/models/dist/ \
135 ~/packages/node-utils/dist/ \
136 ~/packages/server-commands/dist/ \
137 ~/packages/typescript-utils/dist/ \
138 \( -name '*.d.ts' -o -name '*.d.ts.map' \) -type f -delete
144 mv ~/node_modules $out/node_modules
146 mv ~/client/{dist,node_modules,package.json,yarn.lock} $out/client
147 mkdir -p $out/packages/{core-utils,ffmpeg,models,node-utils,server-commands,typescript-utils}
148 mv ~/packages/core-utils/{dist,package.json} $out/packages/core-utils
149 mv ~/packages/ffmpeg/{dist,package.json} $out/packages/ffmpeg
150 mv ~/packages/models/{dist,package.json} $out/packages/models
151 mv ~/packages/node-utils/{dist,package.json} $out/packages/node-utils
152 mv ~/packages/server-commands/{dist,package.json} $out/packages/server-commands
153 mv ~/packages/typescript-utils/{dist,package.json} $out/packages/typescript-utils
154 mv ~/{config,support,CREDITS.md,FAQ.md,LICENSE,README.md,package.json,yarn.lock} $out
157 mv ~/apps/peertube-cli/{dist,node_modules,package.json,yarn.lock} $cli
158 ln -s $cli/dist/peertube.js $cli/bin/peertube-cli
161 mv ~/apps/peertube-runner/{dist,node_modules,package.json,yarn.lock} $runner
162 ln -s $runner/dist/peertube-runner.js $runner/bin/peertube-runner
164 # Create static gzip and brotli files
165 fd -e css -e eot -e html -e js -e json -e svg -e webmanifest -e xlf \
166 --type file --search-path $out/client/dist --threads $NIX_BUILD_CORES \
167 --exec gzip -9 -n -c {} > {}.gz \;\
168 --exec brotli --best -f {} -o {}.br
171 passthru.tests.peertube = nixosTests.peertube;
174 description = "Free software to take back control of your videos";
176 PeerTube aspires to be a decentralized and free/libre alternative to video
177 broadcasting services.
178 PeerTube is not meant to become a huge platform that would centralize
179 videos from all around the world. Rather, it is a network of
180 inter-connected small videos hosters.
181 Anyone with a modicum of technical skills can host a PeerTube server, aka
182 an instance. Each instance hosts its users and their videos. In this way,
183 every instance is created, moderated and maintained independently by
184 various administrators.
185 You can still watch from your account videos hosted by other instances
186 though if the administrator of your instance had previously connected it
187 with other instances.
189 license = licenses.agpl3Plus;
190 homepage = "https://joinpeertube.org/";
191 platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
192 maintainers = with maintainers; [ immae izorkin stevenroose ];