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 = "1prvrcvbyal39k9axfwjixs4wfgs1m8xy4prsl0kq0s0n7r7nxzj";
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 bcrypt_lib = fetchurl {
47 url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v64-linux-x64-glibc.tar.gz";
48 sha256 = "0gbq4grhp5wl0f9yqb4y43kjfh8nivfd6y0nkv1x6gfvs2v23wb0";
52 mkdir lib && tar -C lib -xf ${bcrypt_lib}
53 patchShebangs ../node-pre-gyp
58 buildInputs = [ python nodePackages.node-gyp ];
60 npx node-gyp rebuild --tarball=${nodeHeaders}
64 buildInputs = [ libsass python ];
67 node scripts/build.js --tarball=${nodeHeaders}
72 buildInputs = [ python nodePackages.node-gyp ];
76 url = "https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linux-x64.tar.gz";
77 sha256 = "0xqv61g6s6rkvc31zq9a3bf8rp56ijnpw0xhr91hc88asqprd5yh";
82 tar -C vendor -xf ${tarball}
83 patchShebangs ../prebuild-install
84 npx node install/libvips
85 npx node install/dll-copy
86 npx prebuild-install || npx node-gyp rebuild --tarball=${nodeHeaders}
90 buildInputs = [ nodePackages.node-gyp-build ];
95 ln -s ${youtube-dl}/bin/youtube-dl bin/youtube-dl
96 cat > bin/details <<EOF
97 {"version":"${youtube-dl.version}","path":null,"exec":"youtube-dl"}
102 serverYarnModulesArg = rec {
103 pname = "peertube-server-yarn-modules";
104 version = source.version;
105 name = "${pname}-${version}";
106 packageJSON = "${serverPatchedPackage}/package.json";
107 yarnLock = "${serverPatchedPackage}/yarn.lock";
108 yarnNix = ./server-yarn-packages.nix;
109 pkgConfig = yarnModulesConfig;
111 clientYarnModulesArg = rec {
112 pname = "peertube-client-yarn-modules";
113 version = source.version;
114 name = "${pname}-${version}";
115 packageJSON = "${clientPatchedPackage}/package.json";
116 yarnLock = "${clientPatchedPackage}/yarn.lock";
117 yarnNix = ./client-yarn-packages.nix;
118 pkgConfig = yarnModulesConfig;
120 yarnModulesNoWorkspace = args: (yarn2nix-moretea.mkYarnModules args).overrideAttrs(old: {
121 buildPhase = builtins.replaceStrings [" ./package.json"] [" /dev/null; cp deps/*/package.json ."] old.buildPhase;
124 patchedPackages = stdenv.mkDerivation (source // rec {
125 patches = if ldap then [ ./ldap.patch ] else [ ./yarn_fix_http_node.patch ];
128 cp package.json yarn.lock $out/
131 serverYarnModules = yarnModulesNoWorkspace serverYarnModulesArg;
132 serverYarnModulesProd = yarnModulesNoWorkspace (serverYarnModulesArg // { yarnFlags = yarn2nix-moretea.defaultYarnFlags ++ [ "--production" ]; });
133 clientYarnModules = yarnModulesNoWorkspace clientYarnModulesArg;
135 server = stdenv.mkDerivation ({
136 pname = "peertube-server";
137 version = source.version;
140 ln -s ${serverYarnModules}/node_modules .
147 buildInputs = [ nodejs serverYarnModules ];
150 client = stdenv.mkDerivation ({
151 pname = "peertube-client";
152 version = source.version;
155 lightArg = if light == null then "" else if light == true then "--light" else "--light-language";
157 ln -s ${serverYarnModules}/node_modules .
158 cp -a ${clientYarnModules}/node_modules client/
159 chmod +w client/node_modules
161 npm run build:client -- ${lightArg}
165 cp -a client/dist $out
167 buildInputs = [ nodejs clientYarnModules ];
170 package = stdenv.mkDerivation rec {
171 version = source.version;
175 ln -s ${serverYarnModulesProd}/node_modules .
176 ln -s ${clientYarnModules}/node_modules client/
177 rm -rf dist && cp -a ${server}/dist dist
178 rm -rf client/dist && cp -a ${client}/dist client/
183 ln -s /tmp $out/.cache
187 description = "A free software to take back control of your videos";
190 PeerTube aspires to be a decentralized and free/libre alternative to video
191 broadcasting services.
192 PeerTube is not meant to become a huge platform that would centralize
193 videos from all around the world. Rather, it is a network of
194 inter-connected small videos hosters.
195 Anyone with a modicum of technical skills can host a PeerTube server, aka
196 an instance. Each instance hosts its users and their videos. In this way,
197 every instance is created, moderated and maintained independently by
198 various administrators.
199 You can still watch from your account videos hosted by other instances
200 though if the administrator of your instance had previously connected it
201 with other instances.
204 license = stdenv.lib.licenses.agpl3Plus;
206 homepage = "https://joinpeertube.org/";
208 platforms = stdenv.lib.platforms.linux; # not sure here
209 maintainers = with stdenv.lib.maintainers; [ matthiasbeyer immae ];