diff --git a/nixos/doc/manual/configuration.xml b/nixos/doc/manual/configuration.xml
index ce7ccf6cc5ec..110d1a00eeb3 100644
--- a/nixos/doc/manual/configuration.xml
+++ b/nixos/doc/manual/configuration.xml
@@ -1033,11 +1033,9 @@ states that a user account named alice shall exist:
users.extraUsers.alice =
- { createHome = true;
- home = "/home/alice";
+ { isNormalUser = true;
description = "Alice Foobar";
extraGroups = [ "wheel" "networkmanager" ];
- useDefaultShell = true;
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
};
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 to
+ users, to
+ true, to
+ /home/username,
+ to true,
+ and to
+ false.
+ '';
+ };
+
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;
};
diff --git a/nixos/tests/common/user-account.nix b/nixos/tests/common/user-account.nix
index 0239a3c4d08a..aa3a0b82bcde 100644
--- a/nixos/tests/common/user-account.nix
+++ b/nixos/tests/common/user-account.nix
@@ -1,11 +1,9 @@
{ pkgs, ... }:
{ users.extraUsers = pkgs.lib.singleton
- { name = "alice";
+ { isNormalUser = true;
+ name = "alice";
description = "Alice Foobar";
- home = "/home/alice";
- createHome = true;
- useDefaultShell = true;
password = "foobar";
uid = 1000;
};