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

Improve Home Manager support: profiles/suites, modules, extern, flake outputs #119

Closed
Pacman99 opened this issue Feb 12, 2021 · 4 comments
Closed
Labels
APIv1 related to 1.0 api stabilization enhancement New feature or request

Comments

@Pacman99
Copy link
Member

Pacman99 commented Feb 12, 2021

Is your feature request related to a problem? Please describe.
Currently home-manager is second class to system configurations and it is missing many of the amazing features that the nixos configurations benefit from.

Describe the solution you'd like
There should be a users/modules folder that gets wired and exported in the flake just like the root modules folder. Suites should have a user suite attrset for user profiles(which should also get imported). Extern should have a specialArgs attribute for home-manager, it could be called userSpecialArgs. And unstable should have an attribute for home-manager modules pulled from master.

Additional context
I am fairly certain that this will require some features in home-manager. I filed a pull request to add extraModules and extraSpecialArgs to the home-manager module here.
And unstable features requires disabledModules to work, which is currently broken in the home-manager module, so this issue needs to be fixed.

This means that this feature can't be added for a while, since it would have to wait until the next nixos & home-manager release(may or june probably).

Also at some point nixflk should probably export homeConfigurations again and drop the legacyPackages.hmActivation packages. The latter was mainly to help debugging, but I realized that the only reason homeConfigurations had issues with nix build was because homeConfigurations was a nested set.

So it should probably be exported as something like: homeConfigurations.host-user and that will let it work if the home-manager command ever gets a --flake option.

And the way the configurations and modules should be exported is still to be determined: nix-community/home-manager#1783.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Pacman99
Copy link
Member Author

I wrote some code to implement some of this based on that pull request to home-manager, you can see it here: https://github.com/nrdxp/nixflk/compare/core...Pacman99:first-user?expand=1.

But I don't want to submit a pull request yet, since it won't have any chance of being merged for a while.

@nrdxp
Copy link
Collaborator

nrdxp commented Feb 13, 2021

I was working on something similar just these last few days, as I was away from my main machine and used it as an excuse to try and integrate my user with home-manager. As it is, it can be done quite easily, though manually, by linking /etc files to their proper place in XDG_CONFIG_DIR, at least for zsh and the develop profile, it mostly worked pretty well, by also pulling in the sessionVariables and manual fixes, I was also able to get xmonad to work mearly by importing it's module directly from nixos.

Perhaps we should try to encourage an effort to provide an upstream compatability layer for existing nixos modules so their api is identical to a home-manager version that may need manual implementation, but when presented to the user, works in the same fashion. Either way, more work is needed in this direction so thank you for opening this issue.

@Pacman99
Copy link
Member Author

I was working on something similar just these last few days, as I was away from my main machine and used it as an excuse to try and integrate my user with home-manager. As it is, it can be done quite easily, though manually, by linking /etc files to their proper place in XDG_CONFIG_DIR, at least for zsh and the develop profile, it mostly worked pretty well, by also pulling in the sessionVariables and manual fixes, I was also able to get xmonad to work mearly by importing it's module directly from nixos.

Wow thats impressive. I'm not sure how to do that myself.

Perhaps we should try to encourage an effort to provide an upstream compatability layer for existing nixos modules so their api is identical to a home-manager version that may need manual implementation, but when presented to the user, works in the same fashion. Either way, more work is needed in this direction so thank you for opening this issue.

This would be really cool! And I think in the long run it would be a good goal.

I was more going for something a bit simpler where we just provide the same nixflk features that you setup for nixos configs for home-manager. So userSuites, userModules, etc. If you look at the branch I posted on the previous comment I basically just copied the same code for system and added a user attrset or attribute.

I know my current home-manager profiles could really benefit from suites as theres a lot of code sprawled around. I even implemented something similar to suites before you even added it, but having it included in nixflk as a feature would be really useful.

@nrdxp nrdxp pinned this issue Feb 17, 2021
@nrdxp nrdxp added the enhancement New feature or request label Feb 17, 2021
@nrdxp nrdxp unpinned this issue Feb 17, 2021
bors bot added a commit that referenced this issue Mar 23, 2021
156: Improve Home Manager support: profiles/suites, modules, extern, flake outputs r=Pacman99 a=Pacman99

A really simple method of implementing #119. 

This relies on a feature that I added in home-manager master for module options of extraSpecialArgs and sharedModules, nix-community/home-manager#1793. I could try and get that backported to 20.09. But I thought I'd get some feedback on these changes first.

Co-authored-by: Pacman99 <[email protected]>
@blaggacao blaggacao added the APIv1 related to 1.0 api stabilization label Apr 11, 2021
@Pacman99
Copy link
Member Author

closed by #156

Pacman99 pushed a commit that referenced this issue Feb 23, 2022
Type-check such configs as modules ("moduleType") rather than as
functions evaluating to attribute sets ("functionTo attrs").  This
ensures that they get invoked with all expected module arguments
("pkgs", "lib", etc.).

Update ./examples/hmOnly so that the testuser config references the pkgs
module arg, thus testing that the switch to moduleType works as
intended.

Closes #119
Pacman99 pushed a commit that referenced this issue Feb 26, 2022
Type-check such configs as modules ("moduleType") rather than as
functions evaluating to attribute sets ("functionTo attrs").  This
ensures that they get invoked with all expected module arguments
("pkgs", "lib", etc.).

Update ./examples/hmOnly so that the testuser config references the pkgs
module arg, thus testing that the switch to moduleType works as
intended.

Closes #119
Pacman99 pushed a commit that referenced this issue Feb 26, 2022
120: Ensure home-manager portable user configurations are called with expected module args r=Pacman99 a=tomeon

Type-check `home-manager` portable user configurations as modules (`moduleType`) rather than as functions evaluating to attribute sets (`functionTo attrs`).  This ensures that they get invoked with all expected module arguments (`pkgs`, `lib`, etc.).

Also update `./examples/hmOnly` so that the `testuser` configuration references the `pkgs` module arg, thus testing that the switch to `moduleType` works as intended.

Closes #119

Co-authored-by: Matt Schreiber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APIv1 related to 1.0 api stabilization enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants