From 4ec435d2fab8606f85d14a0002dbc7ac86440348 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 13 Jul 2025 12:17:46 +1000 Subject: [PATCH] users: fix eval when used to manage `root` --- clanServices/users/default.nix | 9 +++++---- clanServices/users/tests/vm/default.nix | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clanServices/users/default.nix b/clanServices/users/default.nix index bd15cc178..f40be3d1c 100644 --- a/clanServices/users/default.nix +++ b/clanServices/users/default.nix @@ -11,7 +11,7 @@ roles.default = { interface = - { lib, ... }: + { config, lib, ... }: { options = { user = lib.mkOption { @@ -28,8 +28,8 @@ Effects: - - *enabled* (`true`) - Prompt for a passwort during the machine installation or update workflow. - - *disabled* (`false`) - Generate a passwort during the machine installation or update workflow. + - *enabled* (`true`) - Prompt for a password during the machine installation or update workflow. + - *disabled* (`false`) - Generate a password during the machine installation or update workflow. The password can be shown in two steps: @@ -39,7 +39,8 @@ }; regularUser = lib.mkOption { type = lib.types.bool; - default = true; + default = config.user != "root"; + defaultText = lib.literalExpression "config.user != \"root\""; example = false; description = '' Whether the user should be a regular user or a system user. diff --git a/clanServices/users/tests/vm/default.nix b/clanServices/users/tests/vm/default.nix index 147fecc8a..d9781a448 100644 --- a/clanServices/users/tests/vm/default.nix +++ b/clanServices/users/tests/vm/default.nix @@ -13,8 +13,6 @@ roles.default.machines."server".settings = { user = "root"; prompt = false; - # Important: 'root' must not be a regular user. See: https://github.com/NixOS/nixpkgs/issues/424404 - regularUser = false; }; }; user-password-test = {