From d957b98c33d1d73dd4e0821163175c98c8748dc2 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 23 Aug 2024 19:39:18 +0200 Subject: [PATCH] Allow configuring `oh-my-posh` --- lib/modules/packages/oh-my-posh.nix | 60 +++++++++++++++++++++++++++++ lib/modules/valhalla.nix | 1 + 2 files changed, 61 insertions(+) create mode 100644 lib/modules/packages/oh-my-posh.nix diff --git a/lib/modules/packages/oh-my-posh.nix b/lib/modules/packages/oh-my-posh.nix new file mode 100644 index 00000000..3d850944 --- /dev/null +++ b/lib/modules/packages/oh-my-posh.nix @@ -0,0 +1,60 @@ +{ lib, ... }: + let + inherit (lib) + mkOption + types + ; + + themeType = types.submodule ( + { config, ... }: { + options = { + path = mkOption { + type = types.nullOr types.path; + description = "The path to the oh-my-posh theme to use."; + default = null; + }; + + name = mkOption { + type = types.nullOr types.str; + description = "The name of the theme."; + default = if (config.path != null) + then + lib.strings.removeSuffix ".omp" (lib.strings.removeSuffix ".json" (builtins.baseNameOf config.path)) + else + null; + }; + }; + }); + + ompType = types.submodule ( + { config, ... }: { + options = { + theme = mkOption { + type = types.either types.str themeType; + description = "The default theme."; + default = {}; + }; + + additionalThemes = mkOption { + type = types.listOf themeType; + description = "A set of additional themes to install."; + default = []; + }; + }; + }); + in { + options = { + valhalla.users = mkOption { + type = types.attrsOf (types.submodule ( + { ... }: { + options = { + oh-my-posh = mkOption { + type = ompType; + description = "The Oh My Posh configuration to apply."; + default = {}; + }; + }; + })); + }; + }; + } \ No newline at end of file diff --git a/lib/modules/valhalla.nix b/lib/modules/valhalla.nix index 33322f24..4e36b50c 100644 --- a/lib/modules/valhalla.nix +++ b/lib/modules/valhalla.nix @@ -7,6 +7,7 @@ in { imports = [ ./packages/git.nix + ./packages/oh-my-posh.nix ./packages/rclone.nix ./hardware.nix ./i18n.nix