-
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
feat: standalone Home Manager configurations per host #54
Conversation
7c1216b
to
27e7783
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contrib, it seems to be going in the right direction overall
27e7783
to
ea53670
Compare
Changed some stuff.
|
037b583
to
af59222
Compare
Ready for review.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is great.
Last round of small feedback and then this is ready to be merged.
af59222
to
9e83a90
Compare
Finally got power back! Had an outage that lasted a few days, then had quite a backlog of stuff to do outside of work. Ready for review round 2 PR description has also been fully updated with the current overview. |
6a65eae
to
3ebea60
Compare
This commit adds support for standalone Home Manager configurations defined in a 'users' subdirectory of any host. Defining Home Manager configurations per-host gives users the flexibility to either write a fully custom config or delegate to a shared module using the established 'modules/home' directory. Configuration definitions can take two possible forms: 1. hosts/<hostname>/users/<username>.nix 2. hosts/<hostname>/users/<username>/home-configuration.nix If the host defines a NixOS or nix-darwin configuration, and the input 'home-manager' exists, then the Home Manager module for that host will be imported and all defined users will be added automatically. Additionally, the extraSpecialArgs is modified to include 'flake', 'inputs', and 'perSystem'. An error is thrown if the 'home-manager' input does not exist. Standalone configurations also have the 'home.username' and 'home.homeDirectories' options set using 'lib.mkDefault'. This allows it to be overridden by a user. If a 'users' directory exists for a given host, that host directory no longer needs to contain a host configuration file.
3ebea60
to
f251867
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this looks good-enough to be merged.
Tests are missing, but we don't have any tests so it's unfair to ask for some.
In the future we might also want to address a top-level users/ folder that includes UID mapping. But that can be added later and will benefit from the practical experience of having that merged in.
thanks @clo4 ! |
I did create some files to test these changes locally and I've been using it for my own configuration throughout the process, so I'm fully confident that it works as expected. I've never dealt with writing proper tests in Nix, so depending on how much time and energy I have over the coming days I might toy around with that. If anything good comes out of it I'll PR it too :) |
Looking forward to it, testing is one of my main weakspots as a software engineer 😅 Maybe we could just have an ./examples folder with a bunch of sub-flakes in there. It could double as an integration test and a way to demonstrate the various ways to use blueprint. |
Adds support for Home Manager configurations to Blueprint, both standalone and as a system configuration module.
Related to #36
Closes #35, closes #45
The idea is that Home Manager configurations are defined per-host, as opposed to per-user. This gives users the most flexibility: instead of being tied to a single configuration per username, users can choose to either define a totally unique configuration for a particular host, or use a module to define most of the common configuration and apply light changes on top of it.
The following import paths are supported:
hosts/{hostname}/users/{username}.nix
hosts/{hostname}/users/{username}/home-configuration.nix
NixOS or nix-darwin hosts
For hosts containing a system configuration, the Home Manager module and any users defined for that host will be automatically imported, along with setting
useGlobalPkgs
anduseUserPkgs
to true (default, can be overridden). This means, outside of very specific use cases, users will not need to change any home-manager options.Standalone configurations
To support the
home-manager
CLI, thehomeConfigurations
attribute is defined per-system underlegacyPackages
. Thepackages
attribute is intended to be a flat set of derivations, and the top-levelhomeConfigurations
cannot be used sincepkgs
must already be instantiated (which requires a system) to be used as an argument tohome-manager.lib.homeManagerConfiguration
. This can be changed in the future if thehome-manager
CLI becomes deprecated or supports a different output name.The
home.homeDirectory
andhome.username
options will be set automatically, as the username is defined in the path to the file and the homeDirectory can be inferred by the target system. Home Manager set these automatically prior to version 20.09, but this was removed to make evaluation pure.This PR also allows hosts to not define a system configuration if the directory contains a
users
subdirectory.