Skip to content

Renaming default user #381

@blm768

Description

@blm768

I'm playing around with a basic DevOS configuration, and I'd like to rename the default user, but something seems to be hard-coded to refer to the nixos user. Here's what I've attempted so far:

  1. Start from commit 287cb82d.

  2. Run bud vm NixOS. The VM builds.

  3. Apply the following patch:

    diff --git a/flake.nix b/flake.nix
    index d87fdce..dfb458c 100644
    --- a/flake.nix
    +++ b/flake.nix
    @@ -123,7 +123,7 @@
                   users = digga.lib.rakeLeaves ./users;
                 };
                 suites = with profiles; rec {
    -              base = [ core users.nixos users.root ];
    +              base = [ core users.test users.root ];
                 };
               };
             };
    diff --git a/hosts/bootstrap.nix b/hosts/bootstrap.nix
    index d491855..04179ec 100644
    --- a/hosts/bootstrap.nix
    +++ b/hosts/bootstrap.nix
    @@ -8,7 +8,7 @@
         # profiles.networking
         profiles.core
         profiles.users.root # make sure to configure ssh keys
    -    profiles.users.nixos
    +    profiles.users.test
       ];
     
       boot.loader.systemd-boot.enable = true;
    diff --git a/users/nixos/default.nix b/users/test/default.nix
    similarity index 56%
    rename from users/nixos/default.nix
    rename to users/test/default.nix
    index 5c037fe..daed888 100644
    --- a/users/nixos/default.nix
    +++ b/users/test/default.nix
    @@ -1,10 +1,10 @@
     { hmUsers, ... }:
     {
    -  home-manager.users = { inherit (hmUsers) nixos; };
    +  home-manager.users = { inherit (hmUsers) test; };
     
    -  users.users.nixos = {
    +  users.users.test = {
         uid = 1000;
    -    password = "nixos";
    +    password = "test";
         description = "default";
         isNormalUser = true;
         extraGroups = [ "wheel" ];
  4. Now bud vm NixOS fails with the following:

    error: attribute 'test' missing
    
        at /nix/store/37v2bwx9ij1gnm226v7k3ydjm4knz0j2-source/users/test/default.nix:3:25:
    
             2| {
             3|   home-manager.users = { inherit (hmUsers) test; };
              |                         ^
             4|
    (use '--show-trace' to show detailed location information)
    

Reverting the change to the home-manager.users line produces a different error:

error:
       Failed assertions:
       - Exactly one of users.users.nixos.isSystemUser and users.users.nixos.isNormalUser must be set.
(use '--show-trace' to show detailed location information)

I got this to work with a previous version of the template, so if it's not immediately obvious what I'm missing, I can run a git bisect later when I have more time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions