Skip to content

fix: correctly forward user class using fixedTo#380

Merged
vic merged 2 commits intomainfrom
HeitorAugustoLN-patch-1
Apr 5, 2026
Merged

fix: correctly forward user class using fixedTo#380
vic merged 2 commits intomainfrom
HeitorAugustoLN-patch-1

Conversation

@HeitorAugustoLN
Copy link
Copy Markdown
Collaborator

@HeitorAugustoLN HeitorAugustoLN commented Apr 5, 2026

Makes it possible to use the user class in includes, for example:

{ lib, ... }:
{
  _heitor.user =
    let
      username = "heitor";
    in
    {
      user.description = "Heitor Augusto";
      nixos.sops.secrets."${username}/password".neededForUsers = true;

      includes = [
        (
          { host, ... }:
          lib.optionalAttrs (host.class == "nixos") {
            user =
              { osConfig, ... }:
              {
                extraGroups = [
                  "networkmanager"
                  "wheel"
                ];

                hashedPasswordFile = osConfig.sops.secrets."${username}/password".path;
              };
          }
        )
      ];
    };
}

In current main, it fails:

[nixos@nixos:~/infra]$ nix flake check
warning: Git tree '/home/nixos/infra' is dirty
warning: ignoring untrusted substituter 'https://heitor.cachix.org', you are not a trusted user.
Run `man nix.conf` for more information on the `substituters` configuration option.
warning: ignoring the client-specified setting 'trusted-public-keys', because it is a restricted setting and you are not a trusted user
error:
       … while checking flake output 'nixosConfigurations'

       … while checking the NixOS configuration 'nixosConfigurations.axolotl'

       … while calling the 'head' builtin
         at /nix/store/xaknai40sz4yyy5658prwrwmfycj4xvm-source/lib/attrsets.nix:1712:13:
         1711|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1712|             head values
             |             ^
         1713|           else

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/xaknai40sz4yyy5658prwrwmfycj4xvm-source/nixos/modules/system/activation/top-level.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error:
       Failed assertions:
       - Neither the root account nor any wheel user has a password or SSH authorized key.
       You must set one to prevent being locked out of your system.
       If you really want to be locked out of your system, set users.allowNoPasswordLogin = true;
       However you are most probably better off by setting users.mutableUsers = true; and
       manually running passwd root to set the root password.

@HeitorAugustoLN HeitorAugustoLN force-pushed the HeitorAugustoLN-patch-1 branch from 7be2280 to 4247a6b Compare April 5, 2026 22:48
@HeitorAugustoLN HeitorAugustoLN changed the title fix user class in aspect includes fix(user): correctly forward user class using fixedTo Apr 5, 2026
@HeitorAugustoLN HeitorAugustoLN force-pushed the HeitorAugustoLN-patch-1 branch from 4247a6b to f8ca2e5 Compare April 5, 2026 22:49
@HeitorAugustoLN HeitorAugustoLN changed the title fix(user): correctly forward user class using fixedTo fix: correctly forward user class using fixedTo Apr 5, 2026
@vic
Copy link
Copy Markdown
Owner

vic commented Apr 5, 2026

Hey @HeitorAugustoLN, do we need a little test for this ?

@HeitorAugustoLN HeitorAugustoLN marked this pull request as ready for review April 5, 2026 23:00
@HeitorAugustoLN HeitorAugustoLN force-pushed the HeitorAugustoLN-patch-1 branch from 1967e27 to 360c50a Compare April 5, 2026 23:24
@vic vic added the approved allow all CI integration tests label Apr 5, 2026
@HeitorAugustoLN HeitorAugustoLN force-pushed the HeitorAugustoLN-patch-1 branch from 51d6ce3 to 5b0501f Compare April 5, 2026 23:29
@HeitorAugustoLN HeitorAugustoLN force-pushed the HeitorAugustoLN-patch-1 branch from 5b0501f to afade0a Compare April 5, 2026 23:31
@HeitorAugustoLN
Copy link
Copy Markdown
Collaborator Author

Hey @HeitorAugustoLN, do we need a little test for this ?

Yes, added a parametric includes test for every builtin custom class to make sure all of them works. Also rebased and removed merge commit

@vic vic merged commit d217883 into main Apr 5, 2026
15 checks passed
@vic vic deleted the HeitorAugustoLN-patch-1 branch April 5, 2026 23:43
@vic
Copy link
Copy Markdown
Owner

vic commented Apr 5, 2026

awesome, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants