From def1e23be848848400d1d097d4f044e3c401f9dd Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:02:32 +0200 Subject: treewide: remove lib.mdDoc --- modules/users/user.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 60592fc..4e3f1c9 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -6,7 +6,7 @@ with lib; options = { name = mkOption { type = types.str; - description = lib.mdDoc '' + description = '' The name of the user account. If undefined, the name of the attribute set will be used. ''; @@ -16,7 +16,7 @@ with lib; type = types.str; default = ""; example = "Alice Q. User"; - description = lib.mdDoc '' + description = '' A short description of the user account, typically the user's full name. ''; @@ -24,19 +24,19 @@ with lib; uid = mkOption { type = types.int; - description = lib.mdDoc "The user's UID."; + description = "The user's UID."; }; gid = mkOption { type = types.int; default = 20; - description = lib.mdDoc "The user's primary group."; + description = "The user's primary group."; }; isHidden = mkOption { type = types.bool; default = true; - description = lib.mdDoc "Whether to make the user account hidden."; + description = "Whether to make the user account hidden."; }; # extraGroups = mkOption { @@ -48,27 +48,27 @@ with lib; home = mkOption { type = types.path; default = "/var/empty"; - description = lib.mdDoc "The user's home directory."; + description = "The user's home directory."; }; createHome = mkOption { type = types.bool; default = false; - description = lib.mdDoc "Create the home directory when creating the user."; + description = "Create the home directory when creating the user."; }; shell = mkOption { type = types.either types.shellPackage types.path; default = "/sbin/nologin"; example = literalExpression "pkgs.bashInteractive"; - description = lib.mdDoc "The user's shell."; + description = "The user's shell."; }; packages = mkOption { type = types.listOf types.package; default = []; example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]"; - description = lib.mdDoc '' + description = '' The set of packages that should be made availabe to the user. This is in contrast to {option}`environment.systemPackages`, which adds packages to all users. -- cgit v1.2.3 From 5b873c48ace1ee08186d88288cf4f565202c0f28 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sat, 19 Oct 2024 16:13:33 +1100 Subject: users: set `default` for `users.users..name` --- modules/users/user.nix | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 4e3f1c9..363c300 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -1,11 +1,12 @@ { name, lib, ... }: -with lib; - { - options = { + options = let + inherit (lib) literalExpression mkOption types; + in { name = mkOption { type = types.str; + default = name; description = '' The name of the user account. If undefined, the name of the attribute set will be used. @@ -75,10 +76,4 @@ with lib; ''; }; }; - - config = { - - name = mkDefault name; - - }; } -- cgit v1.2.3 From 11c777c7198f4cfcd55fe81646e503c58ceb9f4a Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 22 Oct 2024 10:24:06 +1100 Subject: users: change default `description` to `null` --- modules/users/user.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 363c300..1a8e877 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -14,12 +14,18 @@ }; description = mkOption { - type = types.str; - default = ""; + type = types.nullOr types.nonEmptyStr; + default = null; example = "Alice Q. User"; description = '' A short description of the user account, typically the user's full name. + + This defaults to `null` which means, on creation, `sysadminctl` + will pick the description which is usually always {option}`name`. + + Using an empty name is not supported and breaks macOS like + making the user not appear in Directory Utility. ''; }; -- cgit v1.2.3 From 0a686597faa81831e027505b149dd77b2524ab18 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 22 Oct 2024 19:49:13 +1100 Subject: users: don't allow `name` to be empty --- modules/users/user.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 1a8e877..a0c8aab 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -5,7 +5,7 @@ inherit (lib) literalExpression mkOption types; in { name = mkOption { - type = types.str; + type = types.nonEmptyStr; default = name; description = '' The name of the user account. If undefined, the name of the -- cgit v1.2.3 From bd161d61d6f322e1c16543b67b1dbd13934e763c Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 24 Oct 2024 23:19:27 +1100 Subject: users: allow `home` to be managed by macOS --- modules/users/user.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index a0c8aab..b9c9799 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -53,9 +53,17 @@ # }; home = mkOption { - type = types.path; - default = "/var/empty"; - description = "The user's home directory."; + type = types.nullOr types.path; + default = null; + description = '' + The user's home directory. This defaults to `null`. + + When this is set to `null`, the value is managed by macOS instead of + `nix-darwin`. This means if the user has not been created yet, + `sysadminctl` will be called without the `-home` flag which means the + user will have a default home directory of `/Users/` which will + be created by `sysadminctl`. + ''; }; createHome = mkOption { -- cgit v1.2.3 From 3712ff78ccacd65c819435a310fe8b1a8a2de2ee Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sat, 26 Oct 2024 11:35:34 +1100 Subject: users: change default shell to `/usr/bin/false` to match macOS --- modules/users/user.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index b9c9799..281b7e6 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -74,7 +74,7 @@ shell = mkOption { type = types.either types.shellPackage types.path; - default = "/sbin/nologin"; + default = "/usr/bin/false"; example = literalExpression "pkgs.bashInteractive"; description = "The user's shell."; }; -- cgit v1.2.3 From dc6f754fe5d3b0d1ee6b033495c87ec3199a7f68 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Fri, 25 Oct 2024 01:16:19 +1100 Subject: users: allow `shell` to be managed by macOS --- modules/users/user.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 281b7e6..72ae07b 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -73,10 +73,17 @@ }; shell = mkOption { - type = types.either types.shellPackage types.path; - default = "/usr/bin/false"; + type = types.nullOr (types.either types.shellPackage types.path); + default = null; example = literalExpression "pkgs.bashInteractive"; - description = "The user's shell."; + description = '' + The user's shell. This defaults to `null`. + + When this is set to `null`, if the user has not been created yet, + they will be created with the shell `/usr/bin/false` to prevent + interactive login. If the user already exists, the value is + considered managed by macOS and `nix-darwin` will not change it. + ''; }; packages = mkOption { -- cgit v1.2.3 From f380194f3dac82e63dc72db160490dcb58208534 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Mon, 28 Oct 2024 10:30:02 +1100 Subject: users: create users with home directory `/var/empty` by default --- modules/users/user.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 72ae07b..9689e05 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -58,11 +58,9 @@ description = '' The user's home directory. This defaults to `null`. - When this is set to `null`, the value is managed by macOS instead of - `nix-darwin`. This means if the user has not been created yet, - `sysadminctl` will be called without the `-home` flag which means the - user will have a default home directory of `/Users/` which will - be created by `sysadminctl`. + When this is set to `null`, if the user has not been created yet, + they will be created with the home directory `/var/empty` to match + the old default. ''; }; -- cgit v1.2.3 From 5eb88645f74396d4b80fdf736ddd63afbe8320d5 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Mon, 11 Nov 2024 00:08:42 +1100 Subject: users: assert that `programs..enable = true;` for users' shells Backport of https://github.com/NixOS/nixpkgs/pull/211603 and https://github.com/NixOS/nixpkgs/commit/093f354a1777e462bd80398c4fc624c4d383dc68 --- modules/users/user.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/users/user.nix') diff --git a/modules/users/user.nix b/modules/users/user.nix index 9689e05..5256ac3 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -84,6 +84,17 @@ ''; }; + ignoreShellProgramCheck = mkOption { + type = types.bool; + default = false; + description = '' + By default, nix-darwin will check that programs.SHELL.enable is set to + true if the user has a custom shell specified. If that behavior isn't + required and there are custom overrides in place to make sure that the + shell is functional, set this to true. + ''; + }; + packages = mkOption { type = types.listOf types.package; default = []; -- cgit v1.2.3