Skip to content

Commit

Permalink
feat: support target-wide user home
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehamilton committed May 20, 2024
1 parent 8d66125 commit 63a1abf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions snowfall-lib/home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
mkAliasAndWrapDefinitions
mkOption
types
hasInfix
hasSuffix
;

user-homes-root = snowfall-lib.fs.get-snowfall-file "homes";
Expand Down Expand Up @@ -95,7 +97,7 @@ in {
lib = home-lib;
in
assert assertMsg (user-inputs ? home-manager) "In order to create home-manager configurations, you must include `home-manager` as a flake input.";
assert assertMsg (user-metadata.host != "") "Snowfall Lib homes must be named with the format: user@system"; {
assert assertMsg ((user-metadata.host != "") || !(hasInfix "@" name)) "Snowfall Lib homes must be named with the format: user@system"; {
inherit channelName system;

output = "homeConfigurations";
Expand All @@ -108,7 +110,7 @@ in {
++ modules;

specialArgs = {
inherit name;
inherit name system;
inherit (user-metadata) user host;

format = "home";
Expand Down Expand Up @@ -294,9 +296,12 @@ in {
options,
pkgs,
host ? "",
system ? pkgs.system,
...
}: let
host-matches = created-user.specialArgs.host == host;
host-matches =
(created-user.specialArgs.host == host)
|| (created-user.specialArgs.host == "" && created-user.specialArgs.system == system);

# NOTE: To conform to the config structure of home-manager, we have to
# remap the options coming from `snowfallorg.user.<name>.home.config` since `mkAliasDefinitions`
Expand Down Expand Up @@ -342,7 +347,7 @@ in {
# However, not all specialArgs values can be set when using `_module.args`.
_module.args =
builtins.removeAttrs (users.users.${name}.specialArgs or {})
["options" "config" "lib" "pkgs" "specialArgs"];
["options" "config" "lib" "pkgs" "specialArgs" "host"];
};

home-manager = {
Expand Down

0 comments on commit 63a1abf

Please sign in to comment.