From dfa5452af5344596cffdae5a1d8181536a4141b1 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Sun, 26 Jul 2026 07:36:06 +1000 Subject: [PATCH] fix(common): set mutableUsers = false to fix password setup on disk images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a proxmox-* disk image is built, activation runs during the image build without a valid sops age key (the SSH host key doesn't exist yet), so root and nixos land in /etc/shadow with locked '!' entries. With the default mutableUsers = true, update-users-groups.pl preserves existing shadow entries for accounts that already exist, so hashedPasswordFile is silently ignored on every subsequent boot — passwords are never fixed. Setting mutableUsers = false forces update-users-groups.pl to apply hashedPasswordFile unconditionally on every activation. On first real boot the sops-decrypted hash is now written regardless of whether the account already existed in shadow from the image build. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_011uRcikkTp3D5VbXj2DwNpQ --- modules/common/configuration.nix | 42 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/modules/common/configuration.nix b/modules/common/configuration.nix index cb2a757..eba6347 100644 --- a/modules/common/configuration.nix +++ b/modules/common/configuration.nix @@ -61,24 +61,32 @@ !include ${config.sops.templates."nix-github-token.conf".path} ''; - #Set root password - users.users.root = { - hashedPasswordFile = config.sops.secrets."root-hashedPassword".path; - }; + users = { + # With mutableUsers = false, update-users-groups.pl enforces hashedPasswordFile + # on every activation regardless of whether the account already exists in + # /etc/shadow. The default (true) only applies hashedPasswordFile to newly- + # created accounts — which means a freshly-built proxmox disk image (where + # activation runs without a usable sops key, so both accounts land in shadow + # with ‘!’) will never have its passwords fixed by subsequent boots. + mutableUsers = false; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.${vars.primaryUser} = { - isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - packages = with pkgs; [ - tree - ]; - hashedPasswordFile = config.sops.secrets."nixos-hashedPassword".path; - openssh.authorizedKeys.keys = [ - vars.adminSshKey - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICMJhrfFayLBG+gWtO6oAvgambw5nWWgztiTFEaaaVRH debian@surface" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGygkCljN6uKpdJbHTOQtn8ZnH+wKXDLAwrDFbLrE/65 nixos@nixos" - ]; + users.root = { + hashedPasswordFile = config.sops.secrets."root-hashedPassword".path; + }; + + users.${vars.primaryUser} = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + tree + ]; + hashedPasswordFile = config.sops.secrets."nixos-hashedPassword".path; + openssh.authorizedKeys.keys = [ + vars.adminSshKey + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICMJhrfFayLBG+gWtO6oAvgambw5nWWgztiTFEaaaVRH debian@surface" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGygkCljN6uKpdJbHTOQtn8ZnH+wKXDLAwrDFbLrE/65 nixos@nixos" + ]; + }; };