-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add standalone home-manager support #36
base: main
Are you sure you want to change the base?
Conversation
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, looks reasonable overall.
docs/folder-structure.md
Outdated
@@ -152,6 +153,65 @@ Flake outputs: | |||
|
|||
> Depending on the system type returned, the flake outputs will be the same as detailed for NixOS or Darwin above. | |||
|
|||
### `homes/<name>/(default.nix|home.nix)` |
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.
Does the <name>
map to a user name?
If yes, having those under a users/
structure might make sense.
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.
The name does map to a username. I don't know how I missed users/
. Thats much better than homes/
! Thanks
]; | ||
|
||
home.username = "myUser"; | ||
home.homeDirectory = "/home/myUser"; |
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.
if this maps to a user, the user
could also be passed as a specialArgs argument.
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.
I think that's a great idea, but I'm not really sure how to do it. Mind giving me a hand?
docs/folder-structure.md
Outdated
|
||
Flake outputs: | ||
|
||
* `homeConfigurations."<name>@<system>"` |
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.
In the current home-manager implementation, the @ sign is used for <user>@<hostname>
, which is handy if you want a different profile on a specific host (eg: a server profile with no GUI apps vs a desktop profile).
Do you have any ideas on how to handle that case?
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.
I'm not really sure how to handle this tbh.
A couple of ugly ideas off the top of my head:
- subfolders for machine architecture, removing the need for
user@architecture
user@hostname::architecture
- I don't know if there are conventions for hostnames, but I can see a machine out there having::
in the name. I can't think of a better separator.
Any suggestions?
8905803
to
1435c2f
Compare
I have a (kinda ghetto) alternative version I've been using in my own config with a similar expected directory layout to this PR ( homeConfigurations =
usersPath:
let
usersPathStr = toString usersPath;
userDirs = builtins.attrNames (
lib.filterAttrs (_: type: type == "directory") (builtins.readDir usersPathStr)
);
in
{
packages = lib.genAttrs (import inputs.systems) (system: {
homeConfigurations = lib.genAttrs userDirs (
name:
inputs.home-manager.lib.homeManagerConfiguration {
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
modules = [
"${usersPathStr}/${name}/home.nix"
];
extraSpecialArgs = {
inherit inputs system;
flake = inputs.self;
perSystem = lib.mapAttrs (
_: flake: flake.legacyPackages.${system} or { } // flake.packages.${system} or { }
) inputs;
};
}
);
});
}; and then in my flake.nix I have outputs =
inputs:
let
lib = inputs.nixpkgs.lib;
slib = import ./lib { inherit inputs; };
in
lib.recursiveUpdate (inputs.blueprint {
inherit inputs;
nixpkgs.config = {
allowUnfree = true;
};
}) (slib.homeConfigurations ./users); This results in the following:
|
Adds support for standalone home-manager configurations.
These configurations are discovered from
homes/<username>/(default.nix|home.nix)
, similarly to how systems are discovered fromhosts/<hostname>/(default.nix|configuration.nix|darwin-configuration.nix)
homeManagerConfiguration
callsThis issue was my attempt to add support in the way described by #35, however I wasn't able to do it exactly as I wanted. Home manager configs need system set to pass pkgs as an argument to HM modules. Instead of adding an option to specify the system of a particular home-manager profile, I used the existing
eachSystem
function to build profiles for each system specified by the user'ssystems
flake input.The home-manager CLI expects the flake outputs
homeConfigurations.<name>
nothomeConfigurations.<system>.<name>
. To get around this, I merged the nested attrsets so that the output becomeshomeConfigurations."<name>@<system>"
. An example command to build the profile would behome-manager build --flake .#"agaia@x86_64-linux"
.I don't love this solution TBH, but I wasn't sure of a good way for the user to specify. It crossed my mind to add a nested folder specifying the system (
<repo>/homes/<system>/<name>
), but I didn't like that either.If this HM issue ever gets taken up, it could add some clarity on what to do. nix-community/home-manager#2161_