From 5e2ec9fb8628136e7f9f618c68c0e42ab086b80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 23 Aug 2021 01:50:09 +0200 Subject: Refactor flakes using follows --- flakes/peertube/client.nix | 6 ++--- flakes/peertube/default.nix | 41 +++++++++++++++++++++++++++++++++ flakes/peertube/flake.lock | 8 +++---- flakes/peertube/flake.nix | 56 +++++++++------------------------------------ flakes/peertube/server.nix | 6 ++--- 5 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 flakes/peertube/default.nix (limited to 'flakes/peertube') diff --git a/flakes/peertube/client.nix b/flakes/peertube/client.nix index 06383a7..1501574 100644 --- a/flakes/peertube/client.nix +++ b/flakes/peertube/client.nix @@ -1,8 +1,8 @@ -{ yarnModulesConfig, mkYarnModules', server, sources, version, nodejs, stdenv }: +{ yarnModulesConfig, mkYarnModules', server, sources, nodejs, stdenv }: rec { modules = mkYarnModules' rec { pname = "peertube-client-yarn-modules"; - inherit version; + inherit (sources) version; name = "${pname}-${version}"; packageJSON = "${sources}/client/package.json"; yarnLock = "${sources}/client/yarn.lock"; @@ -10,7 +10,7 @@ rec { }; dist = stdenv.mkDerivation { pname = "peertube-client"; - inherit version; + inherit (sources) version; src = sources; buildPhase = '' ln -s ${server.modules}/node_modules . diff --git a/flakes/peertube/default.nix b/flakes/peertube/default.nix new file mode 100644 index 0000000..8ba0c5f --- /dev/null +++ b/flakes/peertube/default.nix @@ -0,0 +1,41 @@ +{ stdenv, lib, src, server, client }: +stdenv.mkDerivation rec { + inherit (src) version; + pname = "peertube"; + inherit src; + buildPhase = '' + ln -s ${server.modules}/node_modules . + rm -rf dist && cp -a ${server.dist}/dist dist + rm -rf client/dist && cp -a ${client.dist}/dist client/ + ''; + installPhase = '' + mkdir $out + cp -a * $out + ln -s /tmp $out/.cache + ''; + + meta = { + description = "A free software to take back control of your videos"; + + longDescription = '' + PeerTube aspires to be a decentralized and free/libre alternative to video + broadcasting services. + PeerTube is not meant to become a huge platform that would centralize + videos from all around the world. Rather, it is a network of + inter-connected small videos hosters. + Anyone with a modicum of technical skills can host a PeerTube server, aka + an instance. Each instance hosts its users and their videos. In this way, + every instance is created, moderated and maintained independently by + various administrators. + You can still watch from your account videos hosted by other instances + though if the administrator of your instance had previously connected it + with other instances. + ''; + + license = lib.licenses.agpl3Plus; + + homepage = "https://joinpeertube.org/"; + + platforms = lib.platforms.unix; + }; +} diff --git a/flakes/peertube/flake.lock b/flakes/peertube/flake.lock index b6fc1d0..6187115 100644 --- a/flakes/peertube/flake.lock +++ b/flakes/peertube/flake.lock @@ -18,11 +18,11 @@ "myuids": { "locked": { "dir": "flakes/myuids", - "lastModified": 1611091761, - "narHash": "sha256-fE3FBeUxVaMezKjEpepdQW9apOza+0AfBALFhaaD0VA=", + "lastModified": 1628207001, + "narHash": "sha256-7e12OfDv9zMOfqcAlsk1sZj2l3ZB03kcBdWUqhwVaWo=", "ref": "master", - "rev": "23f9fdf03a6673dbe334ae33be4f498cc4753191", - "revCount": 802, + "rev": "dfe02d8fd52e33c7d4e1a209cf486696100b88f3", + "revCount": 865, "type": "git", "url": "https://git.immae.eu/perso/Immae/Config/Nix.git" }, diff --git a/flakes/peertube/flake.nix b/flakes/peertube/flake.nix index 2a594c0..9a5c557 100644 --- a/flakes/peertube/flake.nix +++ b/flakes/peertube/flake.nix @@ -14,7 +14,6 @@ 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; }) ]; }; @@ -22,7 +21,7 @@ patchedSource = stdenv.mkDerivation { pname = "peertube"; - inherit version; + version = peertube.rev; src = peertube; phases = [ "unpackPhase" "patchPhase" "installPhase" ]; patches = [ ./fix_yarn_lock.patch ]; @@ -71,55 +70,16 @@ }); server = callPackage ./server.nix { - inherit version yarnModulesConfig mkYarnModules'; + inherit yarnModulesConfig mkYarnModules'; sources = patchedSource; }; client = callPackage ./client.nix { - inherit server version yarnModulesConfig mkYarnModules'; + inherit server yarnModulesConfig mkYarnModules'; sources = patchedSource; }; in rec { - packages.peertube = stdenv.mkDerivation rec { - inherit version; - pname = "peertube"; - src = patchedSource; - buildPhase = '' - ln -s ${server.modules}/node_modules . - rm -rf dist && cp -a ${server.dist}/dist dist - rm -rf client/dist && cp -a ${client.dist}/dist client/ - ''; - installPhase = '' - mkdir $out - cp -a * $out - ln -s /tmp $out/.cache - ''; - - meta = { - description = "A free software to take back control of your videos"; - - longDescription = '' - PeerTube aspires to be a decentralized and free/libre alternative to video - broadcasting services. - PeerTube is not meant to become a huge platform that would centralize - videos from all around the world. Rather, it is a network of - inter-connected small videos hosters. - Anyone with a modicum of technical skills can host a PeerTube server, aka - an instance. Each instance hosts its users and their videos. In this way, - every instance is created, moderated and maintained independently by - various administrators. - You can still watch from your account videos hosted by other instances - though if the administrator of your instance had previously connected it - with other instances. - ''; - - license = stdenv.lib.licenses.agpl3Plus; - - homepage = "https://joinpeertube.org/"; - - platforms = stdenv.lib.platforms.unix; - }; - }; + packages.peertube = callPackage ./. { inherit server client; src = patchedSource; }; defaultPackage = packages.peertube; legacyPackages.peertube = packages.peertube; checks = { @@ -196,7 +156,13 @@ }; }; } - ) // { + ) // rec { + overlays = { + peertube = final: prev: { + peertube = self.defaultPackage."${final.system}"; + }; + }; + overlay = overlays.peertube; nixosModule = { lib, pkgs, config, ... }: let name = "peertube"; diff --git a/flakes/peertube/server.nix b/flakes/peertube/server.nix index 1bba06d..26348cc 100644 --- a/flakes/peertube/server.nix +++ b/flakes/peertube/server.nix @@ -1,8 +1,8 @@ -{ yarnModulesConfig, mkYarnModules', sources, version, nodejs, stdenv }: +{ yarnModulesConfig, mkYarnModules', sources, nodejs, stdenv }: rec { modules = mkYarnModules' rec { pname = "peertube-server-yarn-modules"; - inherit version; + inherit (sources) version; name = "${pname}-${version}"; packageJSON = "${sources}/package.json"; yarnLock = "${sources}/yarn.lock"; @@ -10,7 +10,7 @@ rec { }; dist = stdenv.mkDerivation { pname = "peertube-server"; - inherit version; + inherit (sources) version; src = sources; buildPhase = '' ln -s ${modules}/node_modules . -- cgit v1.2.3