From db8161ea6ca04ea6be0f2cc3ff779ceb61d473d2 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 17 Sep 2024 18:31:24 +0800 Subject: [PATCH] users/foo-dogsquared/programs/custom-homepage: add themes option --- .../modules/programs/custom-homepage.nix | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix b/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix index 6f0e0876..dcc1034b 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix @@ -5,6 +5,7 @@ let cfg = userCfg.programs.custom-homepage; settingsFormat = pkgs.formats.toml { }; + themesSettingsFormat = pkgs.formats.yaml { }; in { options.users.foo-dogsquared.programs.custom-homepage = { @@ -33,6 +34,51 @@ in ''; }; + themes = lib.mkOption { + type = with lib.types; attrsOf path; + description = '' + Set of [Tinted Theming Base16 + palettes](https://github.com/tinted-theming) to be exported to the + homepage. + + ::: {.note} + As such, they are assumed to be all YAML files. + ::: + ''; + default = { }; + example = lib.literalExpression '' + { + _dark = ./files/base16/bark-on-a-tree.yml; + _light = ./files/base16/albino-bark-on-a-tree.yml; + + catpuccin-mocha = (pkgs.formats.yaml { }).generate "catpuccin-mocha-base16" { + system = "base16"; + name = "Catppuccin Mocha"; + author = "https://github.com/catppuccin/catppuccin"; + variant = "dark"; + palette = { + base00 = "1e1e2e"; + base01 = "181825"; + base02 = "313244"; + base03 = "45475a"; + base04 = "585b70"; + base05 = "cdd6f4"; + base06 = "f5e0dc"; + base07 = "b4befe"; + base08 = "f38ba8"; + base09 = "fab387"; + base0A = "f9e2af"; + base0B = "a6e3a1"; + base0C = "94e2d5"; + base0D = "89b4fa"; + base0E = "cba6f7"; + base0F = "f2cdcd"; + }; + }; + } + ''; + }; + package = lib.mkOption { type = lib.types.package; description = '' @@ -60,10 +106,16 @@ in ${acc} install -Dm0644 ${v} './data/foodogsquared-homepage/links/${n}.toml' '') "" data; + + installThemes = lib.foldlAttrs (acc: n: v: '' + ${acc} + install -Dm0644 ${v} './data/foodogsquared-homepage/themes/${n}}.yaml + '') "" cfg.themes; in cfg.package.overrideAttrs (prevAttrs: { preBuild = (prevAttrs.preBuild or "") + '' ${installDataDir} + ${installThemes} ''; }); };