-
Notifications
You must be signed in to change notification settings - Fork 9
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
Comments
That's kind of cursed, but it's an interesting idea. Seems like a powerful feature that blueprint could expose in a simple way, and the asymmetry you showed between building a system and building its home configuration right now isn't lovely. But it also feels like it could be a footgun for build speed if you reference Do you have a particular use-case for this in mind? How did this idea pop up? Does this unblock something for you? I want to get an understanding of how this could be used. I don't have a tonne of time free over the next few days, so feel free to ping me if I've forgotten about this :P |
Probably the best use case I have currently is if I need to enable a program/service at the system level, but reference the package at the user level. Since packages are configurable at the nixos-module level, the most correct way to do this is to reference the nixos config itself. One place I do this in my own setup is with noisetorch. It needs to be enabled at the system level, but I only want some users to run it by default. So I have a hm-module which creates a user service which references However none of this really precludes me from moving back to module-based home-manager. It's just personal preference basically. I'm just not really fond of calling sudo anytime I want to add a package to my user environment. And my setups aren't so complicated that eval time has become a concern. So keep that in mind. |
Not yet convinced that passing Couldn't one still use non-standalone home-manager configs in the NixOS config if both are tightly coupled?
For that alone, |
I could, but it's just my preference not to. The ability to edit/activate user configs without dealing with privileges/sudo is a much nicer experience IMO.
It's probably not too bad at my scale tbh. More of a convenience. I could see that being annoying though to someone with similar preferences and more hosts. Also, I understand my use case is probably pretty niche, so I'm not going to push very hard. I'd appreciate however if it (or some similar feature) came around at some point, even if it gave a warning about how it impacts eval times. If you maintainers aren't interested in doing that at this moment, feel free to close this issue. |
It ends up being a rather elegant patch at least! I still don't know where on the spectrum of ideas this lies, but I've made a test branch you can use to test it out: diff --git a/lib/default.nix b/lib/default.nix
index 5b84b36..e8cf77b 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -215,12 +215,15 @@ let
mkHomeConfiguration =
{
username,
+ hostname,
modulePath,
pkgs,
}:
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
- extraSpecialArgs = specialArgs;
+ extraSpecialArgs = specialArgs // {
+ osConfig = hosts.${hostname}.value.config or { };
+ };
modules = [
perSystemModule
modulePath
@@ -261,7 +264,7 @@ let
homeConfigurations = lib.mapAttrs (
_name: homeData:
mkHomeConfiguration {
- inherit (homeData) modulePath username;
+ inherit (homeData) modulePath username hostname;
inherit pkgs;
}
) homesFlat; Referencing Could make the hostname a module argument, which would also give users the power to build |
Appreciate you looking into this 🙂, but we have a subtle difference! If the idea was to match homeManager behavior as much as possible, I think what you'd want is
Not sure how that would impact downstream, but it definitely makes my original idea seem more dangerous.
This would be more than sufficient for my needs! |
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.
Describe the solution you'd like
Add
osConfig
toextraSpecialArgs
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
Module-based build
Standalone build
The text was updated successfully, but these errors were encountered: