1 { ldap ? false, sendmail ? false, light ? null, syden ? false, runCommand, libsass
2 , lib, stdenv, rsync, fetchzip, youtube-dl, fetchurl, mylibs, python, nodejs, nodePackages, yarn2nix-moretea }:
4 nodeHeaders = fetchurl {
5 url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
6 sha256 = "12415ss4fxxafp3w8rxp2jbb16y0d7f01b7wv72nmy3cwiqxqkhn";
8 source = mylibs.fetchedGithub ./peertube.json;
9 patchedSource = stdenv.mkDerivation (source // rec {
10 phases = [ "unpackPhase" "patchPhase" "installPhase" ];
11 patches = [ ./yarn_fix_http_node.patch ]
12 ++ lib.optionals ldap [ ./ldap.patch ]
13 ++ lib.optionals sendmail [ ./sendmail.patch ]
14 ++ lib.optionals syden [ ./syden.patch ];
16 # Peertube supports several languages, but they take a very long
17 # time to build. The build script accepts --light which builds
18 # only English, and --light-fr which only builds English + French.
19 # This small hack permits to builds only English + A chosen
20 # language depending on the value of "light"
21 # Default (null) is to build every language
22 lightFix = if light == true || light == null then "" else ''
23 sed -i -e "s/fr-FR/${light}/g" -e "s/--light-fr/--light-language/" $out/scripts/build/client.sh
31 serverPatchedPackage = runCommand "server-package" {} ''
33 cp ${patchedSource}/package.json $out/
34 cp ${patchedSource}/yarn.lock $out/
36 clientPatchedPackage = runCommand "client-package" {} ''
38 cp ${patchedSource}/client/package.json $out/
39 cp ${patchedSource}/client/yarn.lock $out/
44 buildInputs = [ nodePackages.node-pre-gyp ];
46 node_module_version = "72";
47 bcrypt_lib = fetchurl {
48 url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v${node_module_version}-linux-x64-glibc.tar.gz";
49 sha256 = "0kpm9j0yc4lqsafldfsql3m72rr1fapljlb6ddxvy3zi13rb7ppx";
53 if [ "$(node -e "console.log(process.versions.modules)")" != "${node_module_version}" ]; then
54 echo "mismatching version with nodejs please update bcrypt derivation"
57 mkdir lib && tar -C lib -xf ${bcrypt_lib}
58 patchShebangs ../node-pre-gyp
63 buildInputs = [ python nodePackages.node-gyp ];
65 npx node-gyp rebuild --tarball=${nodeHeaders}
69 buildInputs = [ libsass python ];
72 node scripts/build.js --tarball=${nodeHeaders}
77 buildInputs = [ python nodePackages.node-gyp ];
81 url = "https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linux-x64.tar.gz";
82 sha256 = "0xqv61g6s6rkvc31zq9a3bf8rp56ijnpw0xhr91hc88asqprd5yh";
87 tar -C vendor -xf ${tarball}
88 patchShebangs ../prebuild-install
89 npx node install/libvips
90 npx node install/dll-copy
91 npx prebuild-install || npx node-gyp rebuild --tarball=${nodeHeaders}
95 buildInputs = [ nodePackages.node-gyp-build ];
100 ln -s ${youtube-dl}/bin/youtube-dl bin/youtube-dl
101 cat > bin/details <<EOF
102 {"version":"${youtube-dl.version}","path":null,"exec":"youtube-dl"}
107 serverYarnModulesArg = rec {
108 pname = "peertube-server-yarn-modules";
109 version = source.version;
110 name = "${pname}-${version}";
111 packageJSON = "${serverPatchedPackage}/package.json";
112 yarnLock = "${serverPatchedPackage}/yarn.lock";
113 yarnNix = ./server-yarn-packages.nix;
114 pkgConfig = yarnModulesConfig;
116 clientYarnModulesArg = rec {
117 pname = "peertube-client-yarn-modules";
118 version = source.version;
119 name = "${pname}-${version}";
120 packageJSON = "${clientPatchedPackage}/package.json";
121 yarnLock = "${clientPatchedPackage}/yarn.lock";
122 yarnNix = ./client-yarn-packages.nix;
123 pkgConfig = yarnModulesConfig;
125 yarnModulesNoWorkspace = args: (yarn2nix-moretea.mkYarnModules args).overrideAttrs(old: {
126 buildPhase = builtins.replaceStrings [" ./package.json"] [" /dev/null; cp deps/*/package.json ."] old.buildPhase;
129 patchedPackages = stdenv.mkDerivation (source // rec {
130 patches = if ldap then [ ./ldap.patch ] else [ ./yarn_fix_http_node.patch ];
133 cp package.json yarn.lock $out/
136 serverYarnModules = yarnModulesNoWorkspace serverYarnModulesArg;
137 serverYarnModulesProd = yarnModulesNoWorkspace (serverYarnModulesArg // { yarnFlags = yarn2nix-moretea.defaultYarnFlags ++ [ "--production" ]; });
138 clientYarnModules = yarnModulesNoWorkspace clientYarnModulesArg;
140 server = stdenv.mkDerivation ({
141 pname = "peertube-server";
142 version = source.version;
145 ln -s ${serverYarnModules}/node_modules .
152 buildInputs = [ nodejs serverYarnModules ];
155 client = stdenv.mkDerivation ({
156 pname = "peertube-client";
157 version = source.version;
160 lightArg = if light == null then "" else if light == true then "--light" else "--light-language";
162 ln -s ${serverYarnModules}/node_modules .
163 cp -a ${clientYarnModules}/node_modules client/
164 chmod +w client/node_modules
166 npm run build:client -- ${lightArg}
170 cp -a client/dist $out
172 buildInputs = [ nodejs clientYarnModules ];
175 package = stdenv.mkDerivation rec {
176 version = source.version;
180 ln -s ${serverYarnModulesProd}/node_modules .
181 ln -s ${clientYarnModules}/node_modules client/
182 rm -rf dist && cp -a ${server}/dist dist
183 rm -rf client/dist && cp -a ${client}/dist client/
188 ln -s /tmp $out/.cache
192 description = "A free software to take back control of your videos";
195 PeerTube aspires to be a decentralized and free/libre alternative to video
196 broadcasting services.
197 PeerTube is not meant to become a huge platform that would centralize
198 videos from all around the world. Rather, it is a network of
199 inter-connected small videos hosters.
200 Anyone with a modicum of technical skills can host a PeerTube server, aka
201 an instance. Each instance hosts its users and their videos. In this way,
202 every instance is created, moderated and maintained independently by
203 various administrators.
204 You can still watch from your account videos hosted by other instances
205 though if the administrator of your instance had previously connected it
206 with other instances.
209 license = stdenv.lib.licenses.agpl3Plus;
211 homepage = "https://joinpeertube.org/";
213 platforms = stdenv.lib.platforms.linux; # not sure here
214 maintainers = with stdenv.lib.maintainers; [ matthiasbeyer immae ];