chore: Update hosts/user-config.nix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
2025-12-17 16:16:40 -05:00
committed by Hunter Halloran
parent 32b61e3e20
commit 53b1eb58c1

View File

@@ -36,35 +36,33 @@ let
&& builtins.pathExists path;
# Extract ugaif.users options from external user.nix modules
externalUserOptions = lib.foldl' (
acc: item:
# First, build a cache of options per user from their external user.nix (if any).
externalUserModuleOptions = lib.genAttrs (lib.attrNames accounts) (
name:
let
name = item.name;
user = item.user;
user = accounts.${name};
externalPath = resolveExternalPath (user.external or null);
userNixPath = if externalPath != null then externalPath + "/user.nix" else null;
# Load the module and extract its ugaif.users options
moduleOptions =
if isValidPath userNixPath then
let
# Import and evaluate the module with minimal args
outerModule = import userNixPath { inherit inputs; };
evaluatedModule = outerModule {
config = { };
inherit lib pkgs;
osConfig = null;
};
# Extract just the ugaif.users.<name> options
ugaifUsers = evaluatedModule.ugaif.users or { };
userOptions = ugaifUsers.${name} or { };
in
userOptions
else
{ };
in
if moduleOptions != { } then acc // { ${name} = moduleOptions; } else acc
) { } (lib.mapAttrsToList (name: user: { inherit name user; }) accounts);
if isValidPath userNixPath then
let
# Import and evaluate the module with minimal args
outerModule = import userNixPath { inherit inputs; };
evaluatedModule = outerModule {
config = { };
inherit lib pkgs;
osConfig = null;
};
# Extract just the ugaif.users.<name> options
ugaifUsers = evaluatedModule.ugaif.users or { };
in
ugaifUsers.${name} or { }
else
{ }
);
# externalUserOptions only contains users that actually have options defined
externalUserOptions = lib.filterAttrs (_: moduleOptions: moduleOptions != { }) externalUserModuleOptions;
# Submodule defining the structure of a user account
userSubmodule = lib.types.submodule {
@@ -154,7 +152,6 @@ let
};
};
};
in
{