about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAlexey Shmalko <rasen.dubi@gmail.com>2019-07-29 21:56:12 +0300
committerAlexey Shmalko <rasen.dubi@gmail.com>2019-07-29 21:56:12 +0300
commite50539f7b5a50e57c5807617abe089d467d60f7a (patch)
tree2997824b7813deb3101def1d1c036a9581286b1c /nixos
parentaaf2ecd801c3fed8a0e69bf1416710fde164ec1d (diff)
downloadnixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.tar
nixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.tar.gz
nixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.tar.bz2
nixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.tar.lz
nixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.tar.xz
nixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.tar.zst
nixlib-e50539f7b5a50e57c5807617abe089d467d60f7a.zip
syncthing: create default group if not overridden
The following configuration generates a systemd unit that doesn't
start.
```nix
{
  services.syncthing = {
    enable = true;
    user = "my-user";
  };
}
```

It fails with
```
systemd[1]: Started Syncthing service.
systemd[6745]: syncthing.service: Failed to determine group credentials: No such process
systemd[6745]: syncthing.service: Failed at step GROUP spawning /nix/store/n1ydz3i08nqp1ajc50ycy1zribmphqc9-syncthing-1.1.4-bin/bin/syncthing: No such process
systemd[1]: syncthing.service: Main process exited, code=exited, status=216/GROUP
systemd[1]: syncthing.service: Failed with result 'exit-code'.
```

This is due to the fact that `syncthing` group (default) is not
created if the user is overridden.

Add a separate check for setting up the default group, so that
user/group are created independently.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/syncthing.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
index 8148139c3a81..126f5b7b527b 100644
--- a/nixos/modules/services/networking/syncthing.nix
+++ b/nixos/modules/services/networking/syncthing.nix
@@ -372,16 +372,18 @@ in {
 
     systemd.packages = [ pkgs.syncthing ];
 
-    users = mkIf (cfg.systemService && cfg.user == defaultUser) {
-      users."${defaultUser}" =
+    users.users = mkIf (cfg.systemService && cfg.user == defaultUser) {
+      "${defaultUser}" =
         { group = cfg.group;
           home  = cfg.dataDir;
           createHome = true;
           uid = config.ids.uids.syncthing;
           description = "Syncthing daemon user";
         };
+    };
 
-      groups."${defaultUser}".gid =
+    users.groups = mkIf (cfg.systemService && cfg.group == defaultUser) {
+      "${defaultUser}".gid =
         config.ids.gids.syncthing;
     };