X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fwebapps%2Fmediagoblin.nix;h=78bbef6fadd139d48e97be7e4ba0efa85044f25f;hb=53fa9f9e7d87835d6137a029fe80b3195e635797;hp=0232aab2efa0e510ecc3c8b71ae9e5845cf979ea;hpb=658822fb4a42be89b2ea47e111532513c4556d87;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/webapps/mediagoblin.nix b/modules/webapps/mediagoblin.nix index 0232aab..78bbef6 100644 --- a/modules/webapps/mediagoblin.nix +++ b/modules/webapps/mediagoblin.nix @@ -107,6 +107,26 @@ in ''; readOnly = true; }; + 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 Mediagoblin data directory for systemd + ''; + readOnly = true; + }; + systemdRuntimeDirectory = lib.mkOption { + type = lib.types.str; + # Use ReadWritePaths= instead if socketsDir is outside of /run + default = assert lib.strings.hasPrefix "/run/" cfg.socketsDir; + lib.strings.removePrefix "/run/" cfg.socketsDir; + description = '' + Adjusted Mediagoblin sockets directory for systemd + ''; + readOnly = true; + }; sockets = lib.mkOption { type = lib.types.attrsOf lib.types.path; default = { @@ -163,6 +183,10 @@ in ${paste_local} stop ''; preStart = '' + if [ -d ${cfg.dataDir}/plugin_static/ ]; then + rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth + ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth + fi ./bin/gmg -cf ${cfg.configFile} dbupdate ''; @@ -173,6 +197,8 @@ in TimeoutSec = 15; Type = "simple"; WorkingDirectory = cfg.workdir; + RuntimeDirectory = cfg.systemdRuntimeDirectory; + StateDirectory= cfg.systemdStateDirectory; PIDFile = cfg.pids.paster; }; @@ -200,23 +226,12 @@ in TimeoutSec = 60; Type = "simple"; WorkingDirectory = cfg.workdir; + RuntimeDirectory = cfg.systemdRuntimeDirectory; + StateDirectory= cfg.systemdStateDirectory; PIDFile = cfg.pids.celery; }; unitConfig.RequiresMountsFor = cfg.dataDir; }; - - system.activationScripts.mediagoblin = { - deps = [ "users" ]; - text = '' - install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.socketsDir} - install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} - if [ -d ${cfg.dataDir}/plugin_static/ ]; then - rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth - ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth - fi - ''; - }; - }; }