0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-12 05:16:25 +03:00

nixos/syncthing: do not use nogroup

We were already creating a group for the user under which to run syncthing but
we were defaulting to running as `nogroup`.

Additionally, use `install` instead of multiple calls to mkdir/cp/chown.
This commit is contained in:
Peter Hoeg 2019-07-10 21:29:25 +08:00
parent beff2f8d75
commit 8317663b94

View file

@ -291,7 +291,7 @@ in {
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = "nogroup"; default = defaultUser;
description = '' description = ''
Syncthing will be run under this group (group will not be created if it doesn't exist. Syncthing will be run under this group (group will not be created if it doesn't exist.
This can be your user name). This can be your user name).
@ -403,18 +403,12 @@ in {
Group = cfg.group; Group = cfg.group;
ExecStartPre = mkIf (cfg.declarative.cert != null || cfg.declarative.key != null) ExecStartPre = mkIf (cfg.declarative.cert != null || cfg.declarative.key != null)
"+${pkgs.writers.writeBash "syncthing-copy-keys" '' "+${pkgs.writers.writeBash "syncthing-copy-keys" ''
mkdir -p ${cfg.configDir} install -dm700 -o ${cfg.user} -g ${cfg.group} ${cfg.configDir}
chown ${cfg.user}:${cfg.group} ${cfg.configDir}
chmod 700 ${cfg.configDir}
${optionalString (cfg.declarative.cert != null) '' ${optionalString (cfg.declarative.cert != null) ''
cp ${toString cfg.declarative.cert} ${cfg.configDir}/cert.pem install -Dm400 -o ${cfg.user} -g ${cfg.group} ${toString cfg.declarative.cert} ${cfg.configDir}/cert.pem
chown ${cfg.user}:${cfg.group} ${cfg.configDir}/cert.pem
chmod 400 ${cfg.configDir}/cert.pem
''} ''}
${optionalString (cfg.declarative.key != null) '' ${optionalString (cfg.declarative.key != null) ''
cp ${toString cfg.declarative.key} ${cfg.configDir}/key.pem install -Dm400 -o ${cfg.user} -g ${cfg.group} ${toString cfg.declarative.key} ${cfg.configDir}/key.pem
chown ${cfg.user}:${cfg.group} ${cfg.configDir}/key.pem
chmod 400 ${cfg.configDir}/key.pem
''} ''}
''}" ''}"
; ;