Skip to content

Consider adding osConfig to extraSpecialArgs for standalone home manager configurations #69

Open
@smkuehnhold

Description

@smkuehnhold

Is your feature request related to a problem? Please describe.

Module-based home manager configurations will have access to an extra extraSpecialArg called osConfig which will alias the hosts' nixosConfiguration/nix-darwin configuration. This option is typically unavailable (set to null) by default in standalone configs however because home manager does not have built-in knowledge of the host system. Since blueprint explicitly maps users to hosts, I see no reason why it couldn't provide this missing functionality to standalone configurations.

It also might cause confusion if a blueprint user creates a new user which depends on osConfig and then later decides to move to standalone home manager. In this case, I think the hm config will not evaluate in standalone due to osConfig being null.

Image

Describe the solution you'd like

Add osConfig to extraSpecialArgs when the hm config is intended to be used in standalone. osConfig should reference the users host config.

Describe alternatives you've considered

You could hard-code each user to depend on flake.outputs.nixosConfigurations.<host>, but that does not seem ideal. No idea if there is a more elegant solution that is already accessible.

Additional context

You might want to consider investigating if there are any other differences in behaviors between module-based and standalone that can be papered over with blueprint

Example config that uses osConfig

{ pkgs, osConfig, ... }:

{
  home.packages = [ pkgs.atool pkgs.httpie ];
  programs.bash.enable = true;

  home.file."test".text = osConfig.system.stateVersion;

  # The state version is required and should stay at the version you
  # originally installed.
  home.stateVersion = "24.11";
}

Module-based build

> nixos-rebuild build --flake .#
building the system configuration...

Standalone build

> home-manager build --flake .
       ...

       … while selecting an attribute
         at /nix/store/hash-source/hosts/host/users/user/home-configuration.nix:7:27:
            6|
            7|   home.file."test".text = osConfig.system.stateVersion;
             |                           ^
            8|

       error: expected a set but found null: null

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions