Fix inheritance of user config
This commit is contained in:
parent
ec1368950e
commit
2af3a6de6f
|
@ -8,22 +8,6 @@
|
|||
cfg = config.valhalla;
|
||||
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 (
|
||||
{ ... }: {
|
||||
options = {
|
||||
|
@ -39,9 +23,11 @@
|
|||
};
|
||||
};
|
||||
});
|
||||
|
||||
mkUserType = { options }: (
|
||||
types.submodule (
|
||||
in {
|
||||
options = {
|
||||
valhalla = {
|
||||
users = mkOption {
|
||||
type = types.attrsOf (types.submodule (
|
||||
{ ... }: {
|
||||
options = {
|
||||
displayName = mkOption {
|
||||
|
@ -63,14 +49,34 @@
|
|||
};
|
||||
|
||||
git = (import ./git/options.nix) { inherit lib; };
|
||||
} // options;
|
||||
};
|
||||
}));
|
||||
|
||||
userType = mkUserType {
|
||||
options = linuxOptions;
|
||||
description = "The users to create on the machine.";
|
||||
default = {};
|
||||
};
|
||||
|
||||
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 = {
|
||||
microsoftAccount = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -78,34 +84,15 @@
|
|||
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 = {
|
||||
valhalla.windows.users = (lib.attrsets.concatMapAttrs (
|
||||
valhalla.windows.users = lib.mkForce (lib.attrsets.concatMapAttrs (
|
||||
name: options: {
|
||||
${capitalize name} = (lib.attrsets.concatMapAttrs (
|
||||
name: value:
|
||||
if builtins.elem name (builtins.attrNames linuxOptions)
|
||||
then {}
|
||||
else {
|
||||
${name} = value;
|
||||
}
|
||||
) options) // {
|
||||
${capitalize name} = options // {
|
||||
groups = [];
|
||||
};
|
||||
}) cfg.users);
|
||||
|
|
|
@ -9,7 +9,7 @@ begin
|
|||
|
||||
function userConfig -V dir -a name
|
||||
source "$dir/../../Scripts/config.fish"
|
||||
set -l key "valhalla.users.$name.rclone.configurations"
|
||||
set -l key "valhalla.linux.users.$name.rclone.configurations"
|
||||
set -l configs (getConfig "$key" --apply "builtins.attrNames" --json)
|
||||
|
||||
if [ (echo "$configs" | jq "length") -gt 0 ]
|
||||
|
|
Loading…
Reference in a new issue