home-environment: style cleanup

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman
2025-12-04 23:29:10 -06:00
parent f16bfa59e3
commit 6bcb2395ab

View File

@@ -2,7 +2,6 @@
# For OS-specific configuration, please edit nixos/default.nix or nix-darwin/default.nix instead. # For OS-specific configuration, please edit nixos/default.nix or nix-darwin/default.nix instead.
{ {
options,
config, config,
lib, lib,
pkgs, pkgs,
@@ -48,23 +47,29 @@ let
++ cfg.sharedModules; ++ cfg.sharedModules;
config = { config = {
submoduleSupport.enable = true; submoduleSupport = {
submoduleSupport.externalPackageInstall = cfg.useUserPackages; enable = true;
externalPackageInstall = cfg.useUserPackages;
};
home.username = config.users.users.${name}.name; home = {
home.homeDirectory = config.users.users.${name}.home; username = config.users.users.${name}.name;
home.uid = mkIf (options.users.users.${name}.uid.isDefined or false) config.users.users.${name}.uid; homeDirectory = config.users.users.${name}.home;
uid = mkIf (options.users.users.${name}.uid.isDefined or false) config.users.users.${name}.uid;
};
# Forward `nix.enable` from the OS configuration. The nix = {
# conditional is to check whether nix-darwin is new enough # Forward `nix.enable` from the OS configuration. The
# to have the `nix.enable` option; it was previously a # conditional is to check whether nix-darwin is new enough
# `mkRemovedOptionModule` error, which we can crudely detect # to have the `nix.enable` option; it was previously a
# by `visible` being set to `false`. # `mkRemovedOptionModule` error, which we can crudely detect
nix.enable = mkIf (options.nix.enable.visible or true) config.nix.enable; # by `visible` being set to `false`.
enable = mkIf (options.nix.enable.visible or true) config.nix.enable;
# Make activation script use same version of Nix as system as a whole. # Make activation script use same version of Nix as system as a whole.
# This avoids problems with Nix not being in PATH. # This avoids problems with Nix not being in PATH.
nix.package = config.nix.package; inherit (config.nix) package;
};
}; };
} }
) )
@@ -161,30 +166,28 @@ in
}; };
}; };
config = ( config = lib.mkMerge [
lib.mkMerge [ # Fix potential recursion when configuring home-manager users based on values in users.users #594
# Fix potential recursion when configuring home-manager users based on values in users.users #594 (mkIf (cfg.useUserPackages && cfg.users != { }) {
(mkIf (cfg.useUserPackages && cfg.users != { }) { users.users = lib.mapAttrs (_username: usercfg: { packages = [ usercfg.home.path ]; }) cfg.users;
users.users = (lib.mapAttrs (_username: usercfg: { packages = [ usercfg.home.path ]; }) cfg.users); environment.pathsToLink = [ "/etc/profile.d" ];
environment.pathsToLink = [ "/etc/profile.d" ]; })
}) (mkIf (cfg.users != { }) {
(mkIf (cfg.users != { }) { warnings = lib.flatten (
warnings = lib.flatten ( flip lib.mapAttrsToList cfg.users (
flip lib.mapAttrsToList cfg.users ( user: config: flip map config.warnings (warning: "${user} profile: ${warning}")
user: config: flip map config.warnings (warning: "${user} profile: ${warning}") )
) );
);
assertions = lib.flatten ( assertions = lib.flatten (
flip lib.mapAttrsToList cfg.users ( flip lib.mapAttrsToList cfg.users (
user: config: user: config:
flip map config.assertions (assertion: { flip map config.assertions (assertion: {
inherit (assertion) assertion; inherit (assertion) assertion;
message = "${user} profile: ${assertion.message}"; message = "${user} profile: ${assertion.message}";
}) })
) )
); );
}) })
] ];
);
} }