From: Ismaël Bouya Date: Tue, 15 Dec 2020 01:05:19 +0000 (+0100) Subject: Write peertube flake X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=ded643e14096a7cb166c78dd961cf68fb4ddb0cf Write peertube flake --- diff --git a/flakes/peertube/client.nix b/flakes/peertube/client.nix new file mode 100644 index 0000000..06383a7 --- /dev/null +++ b/flakes/peertube/client.nix @@ -0,0 +1,28 @@ +{ yarnModulesConfig, mkYarnModules', server, sources, version, nodejs, stdenv }: +rec { + modules = mkYarnModules' rec { + pname = "peertube-client-yarn-modules"; + inherit version; + name = "${pname}-${version}"; + packageJSON = "${sources}/client/package.json"; + yarnLock = "${sources}/client/yarn.lock"; + pkgConfig = yarnModulesConfig; + }; + dist = stdenv.mkDerivation { + pname = "peertube-client"; + inherit version; + src = sources; + buildPhase = '' + ln -s ${server.modules}/node_modules . + cp -a ${modules}/node_modules client/ + chmod -R +w client/node_modules + patchShebangs . + npm run build:client + ''; + installPhase = '' + mkdir $out + cp -a client/dist $out + ''; + buildInputs = [ nodejs ]; + }; +} diff --git a/flakes/peertube/fix_yarn_lock.patch b/flakes/peertube/fix_yarn_lock.patch new file mode 100644 index 0000000..241e31a --- /dev/null +++ b/flakes/peertube/fix_yarn_lock.patch @@ -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" diff --git a/flakes/peertube/flake.lock b/flakes/peertube/flake.lock new file mode 100644 index 0000000..b6fc1d0 --- /dev/null +++ b/flakes/peertube/flake.lock @@ -0,0 +1,78 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1610051610, + "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "myuids": { + "locked": { + "dir": "flakes/myuids", + "lastModified": 1611091761, + "narHash": "sha256-fE3FBeUxVaMezKjEpepdQW9apOza+0AfBALFhaaD0VA=", + "ref": "master", + "rev": "23f9fdf03a6673dbe334ae33be4f498cc4753191", + "revCount": 802, + "type": "git", + "url": "https://git.immae.eu/perso/Immae/Config/Nix.git" + }, + "original": { + "dir": "flakes/myuids", + "type": "git", + "url": "https://git.immae.eu/perso/Immae/Config/Nix.git" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1611097871, + "narHash": "sha256-Q6bUkno5JNt0OoyXThFDrKArFBp/GryvJhwEgVzGSuk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "31f5dd3f3655fbedac19f64f77844aa5ed79501c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "peertube": { + "flake": false, + "locked": { + "lastModified": 1610436329, + "narHash": "sha256-bIXt5bQiBBlNDFXYzcdQA8qp4nse5epUx/XQOguDOX8=", + "owner": "Chocobozzz", + "repo": "PeerTube", + "rev": "69e0e678beb7f1a3b6753eeff585a14f9a61ea86", + "type": "github" + }, + "original": { + "owner": "Chocobozzz", + "ref": "v3.0.1", + "repo": "PeerTube", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "myuids": "myuids", + "nixpkgs": "nixpkgs", + "peertube": "peertube" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flakes/peertube/flake.nix b/flakes/peertube/flake.nix new file mode 100644 index 0000000..df6ef4a --- /dev/null +++ b/flakes/peertube/flake.nix @@ -0,0 +1,306 @@ +{ + description = "A free software to take back control of your videos"; + inputs.myuids = { + url = "https://git.immae.eu/perso/Immae/Config/Nix.git"; + type = "git"; + dir = "flakes/myuids"; + }; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + inputs.peertube = { + url = "github:Chocobozzz/PeerTube/v3.0.1"; + flake = false; + }; + + outputs = { self, myuids, nixpkgs, peertube, flake-utils }: flake-utils.lib.eachSystem ["x86_64-linux"] (system: + let + version = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.peertube.locked.rev; + pkgs = import nixpkgs { inherit system; overlays = [ + (self: super: { nodejs = self.nodejs-12_x; }) + ]; }; + inherit (pkgs) callPackage stdenv jq youtube-dl fetchurl nodePackages yarn2nix-moretea; + + patchedSource = stdenv.mkDerivation { + pname = "peertube"; + inherit version; + src = peertube; + phases = [ "unpackPhase" "patchPhase" "installPhase" ]; + patches = [ ./fix_yarn_lock.patch ]; + installPhase = '' + mkdir $out + cp -a . $out/ + ''; + }; + 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 <