From f530ead0ba741bc588fd679297364885a3f421a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Fri, 4 Apr 2014 10:46:19 +0200 Subject: [PATCH] syncthing: add preStart script to create dataDir --- nixos/modules/services/networking/syncthing.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix index 345693fec767..8ca16730a94b 100644 --- a/nixos/modules/services/networking/syncthing.nix +++ b/nixos/modules/services/networking/syncthing.nix @@ -49,7 +49,7 @@ in ###### implementation - config = mkIf config.services.syncthing.enable { + config = mkIf cfg.enable { systemd.services.syncthing = { @@ -57,12 +57,17 @@ in after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; environment.STNORESTART = "placeholder"; # do not self-restart - environment.HOME = "${config.services.syncthing.dataDir}"; + environment.HOME = "${cfg.dataDir}"; serviceConfig = { - User = "${config.services.syncthing.user}"; - ExecStart = "${pkgs.syncthing}/bin/syncthing -home=${config.services.syncthing.dataDir}/.syncthing"; + User = "${cfg.user}"; + PermissionsStartOnly = true; Restart = "always"; + ExecStart = "${pkgs.syncthing}/bin/syncthing -home=${cfg.dataDir}/.syncthing"; }; + preStart = '' + mkdir -p ${cfg.dataDir} + chown ${cfg.user} ${cfg.dataDir} + ''; };