Skip to content

Not possible to define context-aware aspects at top-level den.aspects. #92

@vic

Description

@vic

Discussed in #91

Originally posted by michaelBelsanti November 14, 2025
I'm having trouble using the user context in the way demonstrated by the autologin module in the user template.

This is a simplified version of what I'm doing:

{ den, ... }
{
  den.hosts.x86_64-linux.hades.users.quasi = { };
  den.aspects.quasi.includes = [ den.aspects.nushell ];
  den.aspects.nushell =
    { user, ... }:
    {
      nixos =
        { pkgs, ... }:
        {
          environment.systemPackages = [ pkgs.nushell ];
          users.users.${user.userName}.shell = pkgs.bashInteractive;
        };
      homeManager = {
        programs.bash.initExtra = ''
          # https://discourse.nixos.org/t/nushell-as-default-shell/68609/17
          # Some programs launch interactive shells and pretend
          # to use them; such programs always expect a form of POSIX
          # shell.
          #
          # If you don't use programs like that, you can just skip
          # this conditional.
          if ! [ "$TERM" = "dumb" ]; then
            exec nu
          fi
        '';
      };
  };
}

Building hades I end up with this:

error:
       … while calling the 'head' builtin
         at /nix/store/3fis83br4c3xkqh3457ji3w37gihzk6s-source/lib/attrsets.nix:1696:13:
         1695|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1696|             head values
             |             ^
         1697|           else

       … while evaluating the attribute 'value'
         at /nix/store/3fis83br4c3xkqh3457ji3w37gihzk6s-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

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

       error: attribute 'user' missing
       at /nix/store/55z53i8nflvx4y9662rc0b6xb9y43b66-source/lib/modules.nix:685:33:
          684|             "noting that argument `${name}` is not externally provided, so querying `_module.args` instead, requiring `config`"
          685|             config._module.args.${name}
             |                                 ^
          686|           )

I'm sure I'm messing something up with the dependency system, but to me, it looks pretty much the same as the autologin example in the template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions