syncthing: add preStart script to create dataDir

This commit is contained in:
Domen Kožar 2014-04-04 10:46:19 +02:00
parent 7df1ce5088
commit f530ead0ba

View file

@ -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}
'';
};