summary refs log tree commit diff
path: root/nixos/modules/config/users-groups.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-15 02:07:43 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-15 02:16:04 +0200
commita323d146b7be3bc066b4ec74db72888ea32792fb (patch)
treef05ed60f89df9d0546560c4aff93afa567122628 /nixos/modules/config/users-groups.nix
parent1a75958be52f5c2f062ace0935c1a2d43c8f7f55 (diff)
downloadnixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.tar
nixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.tar.gz
nixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.tar.bz2
nixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.tar.lz
nixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.tar.xz
nixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.tar.zst
nixlib-a323d146b7be3bc066b4ec74db72888ea32792fb.zip
Add user attribute isNormalUser
This is shorthand for setting group, createHome, home, useDefaultShell
and isSystemUser.
Diffstat (limited to 'nixos/modules/config/users-groups.nix')
-rw-r--r--nixos/modules/config/users-groups.nix31
1 files changed, 27 insertions, 4 deletions
diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix
index 75d1b6f7ff48..f32138a814dd 100644
--- a/nixos/modules/config/users-groups.nix
+++ b/nixos/modules/config/users-groups.nix
@@ -70,6 +70,21 @@ let
         '';
       };
 
+      isNormalUser = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Indicates whether this is an account for a “real” user. This
+          automatically sets <option>group</option> to
+          <literal>users</literal>, <option>createHome</option> to
+          <literal>true</literal>, <option>home</option> to
+          <filename>/home/<replaceable>username</replaceable></filename>,
+          <option>useDefaultShell</option> to <literal>true</literal>,
+          and <option>isSystemUser</option> to
+          <literal>false</literal>.
+        '';
+      };
+
       group = mkOption {
         type = types.str;
         default = "nogroup";
@@ -148,10 +163,18 @@ let
       };
     };
 
-    config = {
-      name = mkDefault name;
-      shell = mkIf config.useDefaultShell (mkDefault cfg.defaultUserShell);
-    };
+    config = mkMerge
+      [ { name = mkDefault name;
+          shell = mkIf config.useDefaultShell (mkDefault cfg.defaultUserShell);
+        }
+        (mkIf config.isNormalUser {
+          group = mkDefault "users";
+          createHome = mkDefault true;
+          home = mkDefault "/home/${name}";
+          useDefaultShell = mkDefault true;
+          isSystemUser = mkDefault false;
+        })
+      ];
 
   };