git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit8317663b9427ef021e917bde6c6c9d6ff05e240c authorPeter Hoeg <peter@hoeg.com> dateWed 10 Jul 2019, 21:29 (7 years ago) parentbeff2f8
1 file changed+4−10
nixos/modules/services/networking/syncthing.nix+4−10
nixos/modules/services/networking/syncthing.nix+4−10
@@ -291,7 +291,7 @@ in {
291291
292292 group = mkOption {
293293 type = types.str;
294− default = "nogroup";
294+ default = defaultUser;
295295 description = ''
296296 Syncthing will be run under this group (group will not be created if it doesn't exist.
297297 This can be your user name).
@@ -403,18 +403,12 @@ in {
403403 Group = cfg.group;
404404 ExecStartPre = mkIf (cfg.declarative.cert != null || cfg.declarative.key != null)
405405 "+${pkgs.writers.writeBash "syncthing-copy-keys" ''
406− mkdir -p ${cfg.configDir}
407− chown ${cfg.user}:${cfg.group} ${cfg.configDir}
408− chmod 700 ${cfg.configDir}
406+ install -dm700 -o ${cfg.user} -g ${cfg.group} ${cfg.configDir}
409407 ${optionalString (cfg.declarative.cert != null) ''
410− cp ${toString cfg.declarative.cert} ${cfg.configDir}/cert.pem
411− chown ${cfg.user}:${cfg.group} ${cfg.configDir}/cert.pem
412− chmod 400 ${cfg.configDir}/cert.pem
408+ install -Dm400 -o ${cfg.user} -g ${cfg.group} ${toString cfg.declarative.cert} ${cfg.configDir}/cert.pem
413409 ''}
414410 ${optionalString (cfg.declarative.key != null) ''
415− cp ${toString cfg.declarative.key} ${cfg.configDir}/key.pem
416− chown ${cfg.user}:${cfg.group} ${cfg.configDir}/key.pem
417− chmod 400 ${cfg.configDir}/key.pem
411+ install -Dm400 -o ${cfg.user} -g ${cfg.group} ${toString cfg.declarative.key} ${cfg.configDir}/key.pem
418412 ''}
419413 ''}"
420414 ;