feat: support target-wide user home

This commit is contained in:
Jake Hamilton 2024-03-04 10:23:31 -08:00
parent 8d6612527a
commit 63a1abf65b
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68

View file

@ -24,6 +24,8 @@
mkAliasAndWrapDefinitions mkAliasAndWrapDefinitions
mkOption mkOption
types types
hasInfix
hasSuffix
; ;
user-homes-root = snowfall-lib.fs.get-snowfall-file "homes"; user-homes-root = snowfall-lib.fs.get-snowfall-file "homes";
@ -95,7 +97,7 @@ in {
lib = home-lib; lib = home-lib;
in 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-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; inherit channelName system;
output = "homeConfigurations"; output = "homeConfigurations";
@ -108,7 +110,7 @@ in {
++ modules; ++ modules;
specialArgs = { specialArgs = {
inherit name; inherit name system;
inherit (user-metadata) user host; inherit (user-metadata) user host;
format = "home"; format = "home";
@ -294,9 +296,12 @@ in {
options, options,
pkgs, pkgs,
host ? "", host ? "",
system ? pkgs.system,
... ...
}: let }: 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 # 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` # remap the options coming from `snowfallorg.user.<name>.home.config` since `mkAliasDefinitions`
@ -342,7 +347,7 @@ in {
# However, not all specialArgs values can be set when using `_module.args`. # However, not all specialArgs values can be set when using `_module.args`.
_module.args = _module.args =
builtins.removeAttrs (users.users.${name}.specialArgs or {}) builtins.removeAttrs (users.users.${name}.specialArgs or {})
["options" "config" "lib" "pkgs" "specialArgs"]; ["options" "config" "lib" "pkgs" "specialArgs" "host"];
}; };
home-manager = { home-manager = {