Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
|
2174468b85 |
3 changed files with 171 additions and 0 deletions
|
@ -32,6 +32,8 @@ let
|
|||
--prefix "LD_LIBRARY_PATH" : "${pkgs.lib.makeLibraryPath wrapLibraries}"
|
||||
'';
|
||||
});
|
||||
|
||||
peertube = callPackage ./peertube { nodejs = pkgs.nodejs-12_x; };
|
||||
};
|
||||
|
||||
in pkgs.extend(_: _: newpkgs)
|
||||
|
|
141
pkgs/peertube/default.nix
Normal file
141
pkgs/peertube/default.nix
Normal file
|
@ -0,0 +1,141 @@
|
|||
{ stdenv, yarn2nix-moretea, lib, nodePackages, fetchFromGitHub, fetchurl, youtube-dl, jq, nodejs }:
|
||||
|
||||
let
|
||||
inherit (yarn2nix-moretea) mkYarnPackage defaultYarnFlags;
|
||||
in rec {
|
||||
mkYarnModules = args: (yarn2nix-moretea.mkYarnModules args).overrideAttrs(old: {
|
||||
buildPhase = builtins.replaceStrings [" ./package.json"] [" /dev/null; cp deps/*/package.json ."] old.buildPhase;
|
||||
});
|
||||
|
||||
source = stdenv.mkDerivation {
|
||||
name = "peertube-src";
|
||||
src = fetchFromGitHub {
|
||||
owner = "Chocobozzz";
|
||||
repo = "peertube";
|
||||
rev = "v3.0.1";
|
||||
sha256 = "0zrrhc5kml7mqxafmr8yggiakjh3a33wvn2m1i6ij112nkjyv1bc";
|
||||
};
|
||||
|
||||
phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ];
|
||||
patches = [ ./fix-yarnlock.patch ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -a . $out
|
||||
'';
|
||||
|
||||
fixupPhase = ''
|
||||
patchShebangs $out/scripts
|
||||
'';
|
||||
};
|
||||
|
||||
nodeHeaders = fetchurl {
|
||||
url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
|
||||
sha256 = "18nsc6qc3f367vk63bm3wwmcw6lwi8jqxgv025jnv9mc539zx4iy";
|
||||
};
|
||||
|
||||
yarnModulesConfig = {
|
||||
bcrypt = {
|
||||
buildInputs = [ nodePackages.node-pre-gyp ];
|
||||
postInstall = let
|
||||
bcrypt_version = "5.0.0";
|
||||
bcrypt_lib = fetchurl {
|
||||
url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v${bcrypt_version}/bcrypt_lib-v${bcrypt_version}-napi-v3-linux-x64-glibc.tar.gz";
|
||||
sha256 = "0j3p2px1xb17sw3gpm8l4apljajxxfflal1yy552mhpzhi21wccn";
|
||||
};
|
||||
in
|
||||
''
|
||||
if [ "${bcrypt_version}" != "$(cat package.json | ${jq}/bin/jq -r .version)" ]; then
|
||||
echo "Mismatching version please update bcrypt in derivation"
|
||||
false
|
||||
fi
|
||||
mkdir -p lib/binding && tar -C lib/binding -xf ${bcrypt_lib}
|
||||
patchShebangs ../node-pre-gyp
|
||||
npm run install
|
||||
'';
|
||||
};
|
||||
utf-8-validate = {
|
||||
buildInputs = [ nodePackages.node-gyp-build ];
|
||||
};
|
||||
youtube-dl = {
|
||||
postInstall = ''
|
||||
mkdir bin
|
||||
ln -s ${youtube-dl}/bin/youtube-dl bin/youtube-dl
|
||||
cat > bin/details <<EOF
|
||||
{"version":"${youtube-dl.version}","path":null,"exec":"youtube-dl"}
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
serverModules = mkYarnModules rec {
|
||||
pname = "peertube-server-yarn-modules";
|
||||
version = "3.0.1";
|
||||
name = "${pname}-${version}";
|
||||
packageJSON = "${source}/package.json";
|
||||
yarnLock = "${source}/yarn.lock";
|
||||
pkgConfig = yarnModulesConfig;
|
||||
};
|
||||
|
||||
clientModules = mkYarnModules rec {
|
||||
pname = "peertube-client-yarn-modules";
|
||||
version = "3.0.1";
|
||||
name = "${pname}-${version}";
|
||||
packageJSON = "${source}/client/package.json";
|
||||
yarnLock = "${source}/client/yarn.lock";
|
||||
pkgConfig = yarnModulesConfig;
|
||||
};
|
||||
|
||||
serverModulesProd = serverModules.overrideAttrs (_: {
|
||||
yarnFlags = defaultYarnFlags ++ [ "--production" ];
|
||||
});
|
||||
|
||||
server = stdenv.mkDerivation {
|
||||
pname = "peertube-server";
|
||||
version = "3.0.1";
|
||||
src = source;
|
||||
nativeBuildInputs = [ nodePackages.npm ];
|
||||
buildPhase = ''
|
||||
ln -s ${serverModules}/node_modules ./
|
||||
rm -rf ./dist
|
||||
npm run build:server
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -a dist $out
|
||||
'';
|
||||
};
|
||||
|
||||
client = stdenv.mkDerivation {
|
||||
pname = "peertube-client";
|
||||
version = "3.0.1";
|
||||
src = source;
|
||||
buildPhase = ''
|
||||
ln -s ${serverModules}/node_modules .
|
||||
cp -a ${clientModules}/node_modules client/
|
||||
chmod -R +w client/node_modules
|
||||
npm run build:client
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -a client/dist $out
|
||||
'';
|
||||
buildInputs = [ nodejs ];
|
||||
};
|
||||
|
||||
package = stdenv.mkDerivation {
|
||||
pname = "peertube";
|
||||
version = "3.0.1";
|
||||
src = source;
|
||||
buildPhase = ''
|
||||
ln -s ${serverModulesProd}/node_modules .
|
||||
rm -rf dist && cp -a ${server}/dist dist
|
||||
rm -rf client/dist && cp -a ${client}/dist client/
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -a * $out
|
||||
ln -s /tmp $out/.cache
|
||||
'';
|
||||
};
|
||||
}
|
28
pkgs/peertube/fix-yarnlock.patch
Normal file
28
pkgs/peertube/fix-yarnlock.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
diff --git a/client/yarn.lock b/client/yarn.lock
|
||||
index d27cdaec8..26706a9fc 100644
|
||||
--- a/client/yarn.lock
|
||||
+++ b/client/yarn.lock
|
||||
@@ -5703,7 +5703,8 @@ http-errors@~1.7.2:
|
||||
|
||||
"http-node@github:feross/http-node#webtorrent":
|
||||
version "1.2.0"
|
||||
- resolved "https://codeload.github.com/feross/http-node/tar.gz/342ef8624495343ffd050bd0808b3750cf0e3974"
|
||||
+ resolved "https://codeload.github.com/feross/http-node/tar.gz/342ef8624495343ffd050bd0808b3750cf0e3974#33fa312d37f0000b17acdb1a5086565400419a13"
|
||||
+ integrity sha1-M/oxLTfwAAsXrNsaUIZWVABBmhM=
|
||||
dependencies:
|
||||
chrome-net "^3.3.3"
|
||||
freelist "^1.0.3"
|
||||
diff --git a/yarn.lock b/yarn.lock
|
||||
index 61a2ea05e..c742276c7 100644
|
||||
--- a/yarn.lock
|
||||
+++ b/yarn.lock
|
||||
@@ -3873,7 +3873,8 @@ http-errors@~1.7.2:
|
||||
|
||||
"http-node@github:feross/http-node#webtorrent":
|
||||
version "1.2.0"
|
||||
- resolved "https://codeload.github.com/feross/http-node/tar.gz/342ef8624495343ffd050bd0808b3750cf0e3974"
|
||||
+ resolved "https://codeload.github.com/feross/http-node/tar.gz/342ef8624495343ffd050bd0808b3750cf0e3974#33fa312d37f0000b17acdb1a5086565400419a13"
|
||||
+ integrity sha1-M/oxLTfwAAsXrNsaUIZWVABBmhM=
|
||||
dependencies:
|
||||
chrome-net "^3.3.3"
|
||||
freelist "^1.0.3"
|
Loading…
Reference in a new issue