Update hosts/user-config.nix
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -36,37 +36,37 @@ let
|
|||||||
&& builtins.pathExists path;
|
&& builtins.pathExists path;
|
||||||
|
|
||||||
# Extract ugaif.users options from external user.nix modules
|
# Extract ugaif.users options from external user.nix modules
|
||||||
externalUserOptions = lib.foldl' (
|
# First, build a cache of options per user from their external user.nix (if any).
|
||||||
acc: item:
|
externalUserModuleOptions = lib.genAttrs (lib.attrNames accounts) (
|
||||||
|
name:
|
||||||
let
|
let
|
||||||
name = item.name;
|
user = accounts.${name};
|
||||||
user = item.user;
|
|
||||||
externalPath = resolveExternalPath (user.external or null);
|
externalPath = resolveExternalPath (user.external or null);
|
||||||
userNixPath = if externalPath != null then externalPath + "/user.nix" else 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
|
in
|
||||||
if moduleOptions != { } then acc // { ${name} = moduleOptions; } else acc
|
if isValidPath userNixPath then
|
||||||
) { } (lib.mapAttrsToList (name: user: { inherit name user; }) accounts);
|
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
|
# Submodule defining the structure of a user account
|
||||||
|
userSubmodule = lib.types.submodule {
|
||||||
|
options = {
|
||||||
userSubmodule = lib.types.submodule {
|
userSubmodule = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
isNormalUser = lib.mkOption {
|
isNormalUser = lib.mkOption {
|
||||||
|
|||||||
Reference in New Issue
Block a user