-
Notifications
You must be signed in to change notification settings - Fork 29
feat: home configurations without hostname #77
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,6 +173,26 @@ let | |
| in | ||
| lib.optional (builtins.hasAttr hostname homesNested) module; | ||
|
|
||
| homesGeneric = | ||
| let | ||
| getEntryPath = | ||
| _username: userEntry: | ||
| if builtins.pathExists (userEntry.path + "/home-configuration.nix") then | ||
| userEntry.path + "/home-configuration.nix" | ||
| else | ||
| # If we decide to add users/<username>.nix, it's as simple as | ||
| # testing `if userEntry.type == "regular"` | ||
| null; | ||
|
|
||
| mkUsers = | ||
| userEntries: | ||
| let | ||
| users = lib.mapAttrs getEntryPath userEntries; | ||
| in | ||
| lib.filterAttrs (_name: value: value != null) users; | ||
| in | ||
| importDir (src + "/users") mkUsers; | ||
|
|
||
| # Attribute set mapping hostname (defined in hosts/) to a set of home | ||
| # configurations (modules) for that host. If a host has no home | ||
| # configuration, it will be omitted from the set. Likewise, if the user | ||
|
|
@@ -258,13 +278,17 @@ let | |
| eachSystem ( | ||
| { pkgs, ... }: | ||
| { | ||
| homeConfigurations = lib.mapAttrs ( | ||
| _name: homeData: | ||
| mkHomeConfiguration { | ||
| inherit (homeData) modulePath username; | ||
| inherit pkgs; | ||
| } | ||
| ) homesFlat; | ||
| homeConfigurations = | ||
| lib.mapAttrs ( | ||
| _name: homeData: | ||
| mkHomeConfiguration { | ||
| inherit (homeData) modulePath username; | ||
| inherit pkgs; | ||
| } | ||
| ) homesFlat | ||
| // lib.mapAttrs ( | ||
| username: modulePath: mkHomeConfiguration { inherit pkgs username modulePath; } | ||
| ) homesGeneric; | ||
| } | ||
| ); | ||
|
|
||
|
|
@@ -468,7 +492,7 @@ let | |
| # nix3 CLI output (`packages` output expects flat attrset) | ||
| # FIXME: Find another way to make this work without introducing legacyPackages. | ||
| # May involve changing upstream home-manager. | ||
| legacyPackages = lib.optionalAttrs (homesNested != { }) standaloneHomeConfigurations; | ||
| legacyPackages = standaloneHomeConfigurations; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iiuc, we only introduce this to have nested attributes because the home-manager cli doesn't understand flattened ones? If that's correct I think it'd be preferable to drop this here before it sees too much use and prioritize an upstream fix. What do you think? (I know it's already in main, i just hadn't seen it before and took the change as there's already this PR touching it ;)) |
||
|
|
||
| darwinConfigurations = lib.mapAttrs (_: x: x.value) (hostsByCategory.darwinConfigurations or { }); | ||
| nixosConfigurations = lib.mapAttrs (_: x: x.value) (hostsByCategory.nixosConfigurations or { }); | ||
|
|
||
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 wonder if
/homeswould map more naturally for the end-users. It would also allow users to have multiple home configurations (eg:homes/terminalandhomes/desktop).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 opposed to this.
usersis analogous tohosts/*/usersso it was an obvious first choice, but it also makes sense because HM will pick the output name based on$USER. @jzbor since you'll be using this yourself, do you have any input?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.
Hey!
My 2cents to the _question:
/homes/USERNAMEseems better suited, as you both wrote (, because HM will pick up the output name).