Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
smkuehnhold opened this issue Feb 4, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@smkuehnhold
Copy link

smkuehnhold commented Feb 4, 2025

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
@smkuehnhold smkuehnhold added the enhancement New feature or request label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant