From 5af8d43b9ee0543ff212e5c51fb0e750a2b83955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 11 May 2019 01:14:51 +0200 Subject: Use sockets for etherpad-lite --- modules/webapps/etherpad-lite.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'modules/webapps') diff --git a/modules/webapps/etherpad-lite.nix b/modules/webapps/etherpad-lite.nix index 3e951c5..7f0e2ed 100644 --- a/modules/webapps/etherpad-lite.nix +++ b/modules/webapps/etherpad-lite.nix @@ -26,6 +26,13 @@ in The directory where Etherpad lite stores its data. ''; }; + socketsDir = lib.mkOption { + type = lib.types.path; + default = "/run/${name}"; + description = '' + The directory where Etherpad lite stores its sockets. + ''; + }; configFile = lib.mkOption { type = lib.types.path; description = '' @@ -77,6 +84,26 @@ in ''; 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 Etherpad lite sockets directory for systemd + ''; + readOnly = true; + }; + sockets = lib.mkOption { + type = lib.types.attrsOf lib.types.path; + default = { + node = "${cfg.socketsDir}/etherpad-lite.sock"; + }; + readOnly = true; + description = '' + Etherpad lite sockets + ''; + }; }; config = lib.mkIf cfg.enable { @@ -98,6 +125,12 @@ in --settings ${cfg.configFile} ''; + postStart = '' + while [ ! -S ${cfg.sockets.node} ]; do + sleep 0.5 + done + chmod a+w ${cfg.sockets.node} + ''; serviceConfig = { DynamicUser = true; User = cfg.user; @@ -112,6 +145,7 @@ in Restart = "always"; Type = "simple"; TimeoutSec = 60; + RuntimeDirectory = cfg.systemdRuntimeDirectory; StateDirectory= cfg.systemdStateDirectory; ExecStartPre = [ "+${pkgs.coreutils}/bin/install -d -m 0755 -o ${cfg.user} -g ${cfg.group} ${cfg.dataDir}/ep_initialized" -- cgit v1.2.3