Add custom kubernetes module base

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-29 12:44:05 +00:00
parent 51ef8d6ac9
commit 3c1cfbceb8
14 changed files with 1286 additions and 546 deletions

View File

@@ -37,154 +37,11 @@ let
"workspaces"
"zk-prefixer"
];
toCssName = path: lib.strings.removeSuffix ".css" (builtins.baseNameOf path);
in
{
options.programs.obsidian =
with lib;
with types;
let
corePluginsOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to enable the plugin.";
};
name = mkOption {
type = enum corePlugins;
description = "The plugin.";
};
options = mkOption {
type = attrsOf anything;
description = "Plugin options to include.";
default = { };
};
};
};
communityPluginsOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to enable the plugin.";
};
pkg = mkOption {
type = package;
description = "The plugin package.";
};
options = mkOption {
type = attrsOf anything;
description = "Options to include in the plugin's `data.json`.";
default = { };
};
};
};
checkCssPath = path: lib.filesystem.pathIsRegularFile path && lib.strings.hasSuffix ".css" path;
cssSnippetsOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to enable the snippet.";
};
name = mkOption {
type = str;
defaultText = literalExpression "lib.strings.removeSuffix \".css\" (builtins.baseNameOf source)";
description = "Name of the snippet.";
};
source = mkOption {
type = nullOr (addCheck path checkCssPath);
description = "Path of the source file.";
default = null;
};
text = mkOption {
type = nullOr str;
description = "Text of the file.";
default = null;
};
};
config.name = mkDefault (toCssName config.source);
};
themesOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to set the theme as active.";
};
pkg = mkOption {
type = package;
description = "The theme package.";
};
};
};
hotkeysOptions =
{ config, ... }:
{
options = {
modifiers = mkOption {
type = listOf str;
description = "The hotkey modifiers.";
default = [ ];
};
key = mkOption {
type = str;
description = "The hotkey.";
};
};
};
extraFilesOptions =
{ name, config, ... }:
{
options = {
source = mkOption {
type = nullOr path;
description = "Path of the source file or directory.";
default = null;
};
text = mkOption {
type = nullOr str;
description = "Text of the file.";
default = null;
};
target = mkOption {
type = str;
defaultText = literalExpression "name";
description = "Path to target relative to the vault's directory.";
};
};
config.target = mkDefault name;
};
in
{
enable = mkEnableOption "obsidian";
package = mkPackageOption pkgs "obsidian" { };
@@ -290,43 +147,196 @@ in
default = cfg.sharedSettings.appearance;
};
corePlugins = mkOption {
description = "Core plugins to activate.";
type = listOf (coercedTo (enum corePlugins) (p: { name = p; }) (submodule corePluginsOptions));
default = cfg.sharedSettings.corePlugins;
};
corePlugins =
let
corePluginsOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to enable the plugin.";
};
communityPlugins = mkOption {
description = "Community plugins to install and activate.";
type = listOf (coercedTo package (p: { pkg = p; }) (submodule communityPluginsOptions));
default = cfg.sharedSettings.communityPlugins;
};
name = mkOption {
type = enum corePlugins;
description = "The plugin.";
};
cssSnippets = mkOption {
description = "CSS snippets to install.";
type = listOf (
coercedTo (addCheck path checkCssPath) (p: { source = p; }) (submodule cssSnippetsOptions)
);
default = cfg.sharedSettings.cssSnippets;
};
options = mkOption {
type = attrsOf anything;
description = "Plugin options to include.";
default = { };
};
};
};
in
mkOption {
description = "Core plugins to activate.";
type = listOf (coercedTo (enum corePlugins) (p: { name = p; }) (submodule corePluginsOptions));
default = cfg.sharedSettings.corePlugins;
};
themes = mkOption {
description = "Themes to install.";
type = listOf (coercedTo package (p: { pkg = p; }) (submodule themesOptions));
default = cfg.sharedSettings.themes;
};
communityPlugins =
let
communityPluginsOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to enable the plugin.";
};
hotkeys = mkOption {
description = "Hotkeys to configure.";
type = attrsOf (listOf (submodule hotkeysOptions));
default = cfg.sharedSettings.hotkeys;
};
pkg = mkOption {
type = package;
description = "The plugin package.";
};
extraFiles = mkOption {
description = "Extra files to link to the vault directory.";
type = attrsOf (submodule extraFilesOptions);
default = cfg.sharedSettings.extraFiles;
};
options = mkOption {
type = attrsOf anything;
description = "Options to include in the plugin's `data.json`.";
default = { };
};
};
};
in
mkOption {
description = "Community plugins to install and activate.";
type = listOf (coercedTo package (p: { pkg = p; }) (submodule communityPluginsOptions));
default = cfg.sharedSettings.communityPlugins;
};
cssSnippets =
let
checkCssPath = path: lib.filesystem.pathIsRegularFile path && lib.strings.hasSuffix ".css" path;
toCssName = path: lib.strings.removeSuffix ".css" (builtins.baseNameOf path);
cssSnippetsOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to enable the snippet.";
};
name = mkOption {
type = str;
defaultText = literalExpression "lib.strings.removeSuffix \".css\" (builtins.baseNameOf source)";
description = "Name of the snippet.";
};
source = mkOption {
type = nullOr (addCheck path checkCssPath);
description = "Path of the source file.";
default = null;
};
text = mkOption {
type = nullOr str;
description = "Text of the file.";
default = null;
};
};
config.name = mkDefault (toCssName config.source);
};
in
mkOption {
description = "CSS snippets to install.";
type = listOf (
coercedTo (addCheck path checkCssPath) (p: { source = p; }) (submodule cssSnippetsOptions)
);
default = cfg.sharedSettings.cssSnippets;
};
themes =
let
themesOptions =
{ config, ... }:
{
options = {
enable = mkOption {
type = bool;
default = true;
description = "Whether to set the theme as active.";
};
pkg = mkOption {
type = package;
description = "The theme package.";
};
};
};
in
mkOption {
description = "Themes to install.";
type = listOf (coercedTo package (p: { pkg = p; }) (submodule themesOptions));
default = cfg.sharedSettings.themes;
};
hotkeys =
let
hotkeysOptions =
{ config, ... }:
{
options = {
modifiers = mkOption {
type = listOf str;
description = "The hotkey modifiers.";
default = [ ];
};
key = mkOption {
type = str;
description = "The hotkey.";
};
};
};
in
mkOption {
description = "Hotkeys to configure.";
type = attrsOf (listOf (submodule hotkeysOptions));
default = cfg.sharedSettings.hotkeys;
};
extraFiles =
let
extraFilesOptions =
{ name, config, ... }:
{
options = {
source = mkOption {
type = nullOr path;
description = "Path of the source file or directory.";
default = null;
};
text = mkOption {
type = nullOr str;
description = "Text of the file.";
default = null;
};
target = mkOption {
type = str;
defaultText = literalExpression "name";
description = "Path to target relative to the vault's directory.";
};
};
config.target = mkDefault name;
};
in
mkOption {
description = "Extra files to link to the vault directory.";
type = attrsOf (submodule extraFilesOptions);
default = cfg.sharedSettings.extraFiles;
};
};
};