X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=flakes%2Fpeertube%2Fflake.nix;h=e8153ebd7ab860e49f3ffbbe1ca6f7f90e6cd7f3;hb=1a64deeb894dc95e2645a75771732c6cc53a79ad;hp=2a594c0ea8be099325532059b96d5de56aba91c8;hpb=3d11eafc9c516321901908338befe4c04b58f3aa;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/flakes/peertube/flake.nix b/flakes/peertube/flake.nix index 2a594c0..e8153eb 100644 --- a/flakes/peertube/flake.nix +++ b/flakes/peertube/flake.nix @@ -1,9 +1,7 @@ { 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"; + url = "path:../myuids"; }; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixpkgs.url = "github:NixOS/nixpkgs"; @@ -14,7 +12,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 +19,7 @@ patchedSource = stdenv.mkDerivation { pname = "peertube"; - inherit version; + version = peertube.rev; src = peertube; phases = [ "unpackPhase" "patchPhase" "installPhase" ]; patches = [ ./fix_yarn_lock.patch ]; @@ -71,55 +68,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,14 +154,20 @@ }; }; } - ) // { + ) // rec { + overlays = { + peertube = final: prev: { + peertube = self.defaultPackage."${final.system}"; + }; + }; + overlay = overlays.peertube; nixosModule = { lib, pkgs, config, ... }: let name = "peertube"; - cfg = config.services.peertube; + cfg = config.immaeServices.peertube; in { - options.services.peertube = { + options.immaeServices.peertube = { enable = lib.mkEnableOption "Enable Peertube’s service"; user = lib.mkOption { type = lib.types.str; @@ -230,7 +194,7 @@ }; package = lib.mkOption { type = lib.types.package; - default = self.defaultPackage."${pkgs.system}"; + default = pkgs.peertube; description = '' Peertube package to use. ''; @@ -249,6 +213,7 @@ }; config = lib.mkIf cfg.enable { + nixpkgs.overlays = [ self.overlay ]; users.users = lib.optionalAttrs (cfg.user == name) { "${name}" = { uid = myuids.lib.uids.peertube; @@ -272,6 +237,8 @@ environment.NODE_CONFIG_DIR = "${cfg.dataDir}/config"; environment.NODE_ENV = "production"; + environment.NPM_CONFIG_LOGS_DIR = "${cfg.dataDir}/npm_logs"; + environment.NPM_CONFIG_CACHE = "${cfg.dataDir}/npm_cache"; environment.HOME = cfg.package; path = [ pkgs.nodejs pkgs.yarn pkgs.bashInteractive pkgs.ffmpeg pkgs.openssl ];