X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fwebapps%2Fpeertube.nix;h=89dcc67a4517932381c711d76d325c2b087d3389;hb=2a5cde8d47d5c887067176555596cf8feb5c4d8b;hp=7c960764f98e8b674a24af34f3395609191dd5d4;hpb=81b9ff8980a9a235b8915b5779ebc1d2a738a9a3;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/webapps/peertube.nix b/modules/webapps/peertube.nix index 7c96076..89dcc67 100644 --- a/modules/webapps/peertube.nix +++ b/modules/webapps/peertube.nix @@ -39,6 +39,17 @@ in Peertube package to use. ''; }; + # Output variables + systemdStateDirectory = lib.mkOption { + type = lib.types.str; + # Use ReadWritePaths= instead if varDir is outside of /var/lib + default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir; + lib.strings.removePrefix "/var/lib/" cfg.dataDir; + description = '' + Adjusted Peertube data directory for systemd + ''; + readOnly = true; + }; }; config = lib.mkIf cfg.enable { @@ -68,6 +79,8 @@ in path = [ pkgs.nodejs pkgs.bashInteractive pkgs.ffmpeg pkgs.openssl ]; script = '' + install -m 0750 -d ${cfg.dataDir}/config + ln -sf ${cfg.configFile} ${cfg.dataDir}/config/production.yaml exec npm run start ''; @@ -75,6 +88,8 @@ in User = cfg.user; Group = cfg.group; WorkingDirectory = cfg.package; + StateDirectory = cfg.systemdStateDirectory; + StateDirectoryMode = 0750; PrivateTmp = true; ProtectHome = true; ProtectControlGroups = true; @@ -85,16 +100,6 @@ in unitConfig.RequiresMountsFor = cfg.dataDir; }; - - system.activationScripts.peertube = { - deps = [ "users" ]; - text = '' - install -m 0750 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} - install -m 0750 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/config - ln -sf ${cfg.configFile} ${cfg.dataDir}/config/production.yaml - ''; - }; - }; }