Add options for enabling programs individually

This commit is contained in:
Manuel Thalmann 2024-10-13 20:14:54 +02:00
parent bdc02756eb
commit bd7d8f8080
4 changed files with 104 additions and 80 deletions

View file

@ -1,9 +1,10 @@
{ lib, ... }: { lib, ... }:
let let
inherit (lib) mkOption types; inherit (lib) mkEnableOption mkOption types;
gitOption = {
enable = mkEnableOption "git";
gitType = types.submodule ({ ... }: {
options = {
defaultBranch = mkOption { defaultBranch = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
description = "The name of the default branch in newly created repositories."; description = "The name of the default branch in newly created repositories.";
@ -30,13 +31,6 @@ let
default = { }; default = { };
}; };
}; };
});
gitOption = mkOption {
type = gitType;
description = "The git related options.";
default = { };
};
in { in {
options = { options = {
valhalla = { valhalla = {

View file

@ -19,21 +19,40 @@ let
}; };
}; };
}); });
in {
options = { commonOptions = {
valhalla.windows.users = mkOption { enable = mkEnableOption "Nextcloud client";
type = types.attrsOf (types.submodule ( };
{ ... }: {
options = { userOptions = {
programs.nextcloud = {
folderSyncs = mkOption { folderSyncs = mkOption {
type = types.listOf syncType; type = types.listOf syncType;
description = "The folders to synchronize."; description = "The folders to synchronize";
default = [ ]; default = [ ];
}; };
}; };
in {
options = {
valhalla = {
programs.nextcloud = commonOptions;
users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
programs.nextcloud = commonOptions;
};
}));
};
windows.users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
programs.nextcloud = userOptions;
}; };
})); }));
}; };
}; };
};
} }

View file

@ -1,6 +1,6 @@
{ lib, ... }: { lib, ... }:
let let
inherit (lib) mkOption types; inherit (lib) mkEnableOption mkOption types;
themeType = types.submodule ( themeType = types.submodule (
{ config, ... }: { { config, ... }: {
@ -18,9 +18,11 @@ let
}; };
}); });
ompType = types.submodule ( commonOptions = {
{ config, ... }: { enable = mkEnableOption "Oh My Posh";
options = { };
userOptions = commonOptions // {
theme = mkOption { theme = mkOption {
type = types.nullOr (types.either types.str themeType); type = types.nullOr (types.either types.str themeType);
description = "The default theme."; description = "The default theme.";
@ -33,20 +35,19 @@ let
default = [ ]; default = [ ];
}; };
}; };
});
in { in {
options = { options = {
valhalla.users = mkOption { valhalla = {
programs.oh-my-posh = commonOptions;
users = mkOption {
type = types.attrsOf (types.submodule ( type = types.attrsOf (types.submodule (
{ ... }: { { ... }: {
options = { options = {
programs.oh-my-posh = mkOption { programs.oh-my-posh = userOptions;
type = ompType;
description = "The Oh My Posh configuration to apply.";
default = { };
};
}; };
})); }));
}; };
}; };
};
} }

View file

@ -1,6 +1,6 @@
{ lib, ... }: { lib, ... }:
let let
inherit (lib) mkOption types; inherit (lib) mkEnableOption mkOption types;
syncType = types.submodule ( syncType = types.submodule (
{ ... }: { { ... }: {
@ -12,26 +12,36 @@ let
cacheDuration = mkOption { cacheDuration = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
description = "The amount of time to keep cached files."; description = "The amount of time to keep files in the cache.";
default = null; default = null;
}; };
}; };
}); });
in {
options = { commonOptions = {
valhalla.linux.users = mkOption { enable = mkEnableOption "rclone";
type = types.attrsOf (types.submodule ( };
{ ... }: {
options = { userOptions = commonOptions // {
programs.rclone = {
configurations = mkOption { configurations = mkOption {
type = types.attrsOf syncType; type = types.attrsOf syncType;
description = "The configurations of the rclone mounts."; description = "The configurations of the rclone mounts.";
default = { }; default = { };
}; };
}; };
in {
options = {
valhalla.linux = {
programs.rclone = commonOptions;
users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
programs.rclone = userOptions;
}; };
})); }));
}; };
}; };
};
} }