diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-15 02:07:43 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-15 02:16:04 +0200 |
commit | a323d146b7be3bc066b4ec74db72888ea32792fb (patch) | |
tree | f05ed60f89df9d0546560c4aff93afa567122628 /nixos/modules | |
parent | 1a75958be52f5c2f062ace0935c1a2d43c8f7f55 (diff) | |
download | nixlib-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')
-rw-r--r-- | nixos/modules/config/users-groups.nix | 31 | ||||
-rw-r--r-- | nixos/modules/installer/tools/nixos-generate-config.pl | 6 | ||||
-rw-r--r-- | nixos/modules/profiles/demo.nix | 7 |
3 files changed, 30 insertions, 14 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; + }) + ]; }; diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 66a8152a3a6c..c507f7f979fa 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -490,12 +490,8 @@ $bootLoaderConfig # Define a user account. Don't forget to set a password with ‘passwd’. # users.extraUsers.guest = { - # name = "guest"; - # group = "users"; + # isNormalUser = true; # uid = 1000; - # createHome = true; - # home = "/home/guest"; - # shell = "/run/current-system/sw/bin/bash"; # }; } diff --git a/nixos/modules/profiles/demo.nix b/nixos/modules/profiles/demo.nix index 605cc6aad1de..ef6fd77b5f8d 100644 --- a/nixos/modules/profiles/demo.nix +++ b/nixos/modules/profiles/demo.nix @@ -4,12 +4,9 @@ imports = [ ./graphical.nix ]; users.extraUsers.demo = - { description = "Demo user account"; - group = "users"; + { isNormalUser = true; + description = "Demo user account"; extraGroups = [ "wheel" ]; - home = "/home/demo"; - createHome = true; - useDefaultShell = true; password = "demo"; uid = 1000; }; |