Fix inheritance of user config

This commit is contained in:
Manuel Thalmann 2024-08-23 18:28:20 +02:00
parent 79992bbcb8
commit 2246f5d0db

View file

@ -8,22 +8,6 @@
cfg = config.valhalla; cfg = config.valhalla;
capitalize = (import ../text.nix { inherit lib; }).capitalize; capitalize = (import ../text.nix { inherit lib; }).capitalize;
linuxOptions = {
defaultShell = mkOption {
type = types.nullOr types.str;
description = "The default shell of the user.";
default = null;
};
rclone = {
configurations = mkOption {
type = types.attrsOf syncType;
description = "The configurations of the rclone mounts.";
default = {};
};
};
};
syncType = types.submodule ( syncType = types.submodule (
{ ... }: { { ... }: {
options = { options = {
@ -39,9 +23,11 @@
}; };
}; };
}); });
in {
mkUserType = { options }: ( options = {
types.submodule ( valhalla = {
users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: { { ... }: {
options = { options = {
displayName = mkOption { displayName = mkOption {
@ -63,14 +49,34 @@
}; };
git = (import ./git/options.nix) { inherit lib; }; git = (import ./git/options.nix) { inherit lib; };
} // options; };
})); }));
description = "The users to create on the machine.";
userType = mkUserType { default = {};
options = linuxOptions;
}; };
winUserType = mkUserType { linux.users = mkOption {
type = types.attrsOf (types.submodule {
options = {
defaultShell = mkOption {
type = types.nullOr types.str;
description = "The default shell of the user.";
default = null;
};
rclone = {
configurations = mkOption {
type = types.attrsOf syncType;
description = "The configurations of the rclone mounts.";
default = {};
};
};
};
});
};
windows.users = mkOption {
type = types.attrsOf (types.submodule {
options = { options = {
microsoftAccount = mkOption { microsoftAccount = mkOption {
type = types.bool; type = types.bool;
@ -78,34 +84,15 @@
default = false; default = false;
}; };
}; };
}; });
in {
options = {
valhalla = {
users = mkOption {
type = types.attrsOf userType;
description = "The users to create on the machine.";
default = {};
};
windows.users = mkOption {
type = types.attrsOf winUserType;
description = "The users to create on the Windows machine.";
}; };
}; };
}; };
config = { config = {
valhalla.windows.users = (lib.attrsets.concatMapAttrs ( valhalla.windows.users = lib.mkForce (lib.attrsets.concatMapAttrs (
name: options: { name: options: {
${capitalize name} = (lib.attrsets.concatMapAttrs ( ${capitalize name} = options // {
name: value:
if builtins.elem name (builtins.attrNames linuxOptions)
then {}
else {
${name} = value;
}
) options) // {
groups = []; groups = [];
}; };
}) cfg.users); }) cfg.users);