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,41 +1,35 @@
{ lib, ... }: { lib, ... }:
let let
inherit (lib) mkOption types; inherit (lib) mkEnableOption mkOption types;
gitType = types.submodule ({ ... }: { gitOption = {
options = { enable = mkEnableOption "git";
defaultBranch = mkOption {
defaultBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the default branch in newly created repositories.";
default = null;
};
flow = {
mainBranch = 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 stable branch in git flow.";
default = null; default = null;
}; };
flow = { devBranch = mkOption {
mainBranch = mkOption { type = types.nullOr types.str;
type = types.nullOr types.str; description = "The name of the development branch in git flow.";
description = "The name of the stable branch in git flow."; default = null;
default = null;
};
devBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the development branch in git flow.";
default = null;
};
};
aliases = mkOption {
type = types.attrsOf types.str;
description = "The git command aliases to install.";
default = { };
}; };
}; };
});
gitOption = mkOption { aliases = mkOption {
type = gitType; type = types.attrsOf types.str;
description = "The git related options."; description = "The git command aliases to install.";
default = { }; default = { };
};
}; };
in { in {
options = { options = {

View file

@ -19,21 +19,40 @@ let
}; };
}; };
}); });
commonOptions = {
enable = mkEnableOption "Nextcloud client";
};
userOptions = {
folderSyncs = mkOption {
type = types.listOf syncType;
description = "The folders to synchronize";
default = [ ];
};
};
in { in {
options = { options = {
valhalla.windows.users = mkOption { valhalla = {
type = types.attrsOf (types.submodule ( programs.nextcloud = commonOptions;
{ ... }: {
options = { users = mkOption {
programs.nextcloud = { type = types.attrsOf (types.submodule (
folderSyncs = mkOption { { ... }: {
type = types.listOf syncType; options = {
description = "The folders to synchronize."; programs.nextcloud = commonOptions;
default = [ ];
};
}; };
}; }));
})); };
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,35 +18,36 @@ let
}; };
}); });
ompType = types.submodule ( commonOptions = {
{ config, ... }: { enable = mkEnableOption "Oh My Posh";
options = { };
theme = mkOption {
type = types.nullOr (types.either types.str themeType);
description = "The default theme.";
default = null;
};
additionalThemes = mkOption { userOptions = commonOptions // {
type = types.listOf themeType; theme = mkOption {
description = "A set of additional themes to install."; type = types.nullOr (types.either types.str themeType);
default = [ ]; description = "The default theme.";
}; default = null;
}; };
});
additionalThemes = mkOption {
type = types.listOf themeType;
description = "A set of additional themes to install.";
default = [ ];
};
};
in { in {
options = { options = {
valhalla.users = mkOption { valhalla = {
type = types.attrsOf (types.submodule ( programs.oh-my-posh = commonOptions;
{ ... }: {
options = { users = mkOption {
programs.oh-my-posh = mkOption { type = types.attrsOf (types.submodule (
type = ompType; { ... }: {
description = "The Oh My Posh configuration to apply."; options = {
default = { }; programs.oh-my-posh = userOptions;
}; };
}; }));
})); };
}; };
}; };
} }

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;
}; };
}; };
}); });
commonOptions = {
enable = mkEnableOption "rclone";
};
userOptions = commonOptions // {
configurations = mkOption {
type = types.attrsOf syncType;
description = "The configurations of the rclone mounts.";
default = { };
};
};
in { in {
options = { options = {
valhalla.linux.users = mkOption { valhalla.linux = {
type = types.attrsOf (types.submodule ( programs.rclone = commonOptions;
{ ... }: {
options = { users = mkOption {
programs.rclone = { type = types.attrsOf (types.submodule (
configurations = mkOption { { ... }: {
type = types.attrsOf syncType; options = {
description = "The configurations of the rclone mounts."; programs.rclone = userOptions;
default = { };
};
}; };
}; }));
})); };
}; };
}; };
} }