users/foo-dogsquared/programs/custom-homepage: add themes option

This commit is contained in:
Gabriel Arazas 2024-09-17 18:31:24 +08:00
parent 95ee01bbae
commit db8161ea6c
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360

View File

@ -5,6 +5,7 @@ let
cfg = userCfg.programs.custom-homepage; cfg = userCfg.programs.custom-homepage;
settingsFormat = pkgs.formats.toml { }; settingsFormat = pkgs.formats.toml { };
themesSettingsFormat = pkgs.formats.yaml { };
in in
{ {
options.users.foo-dogsquared.programs.custom-homepage = { 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 { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
description = '' description = ''
@ -60,10 +106,16 @@ in
${acc} ${acc}
install -Dm0644 ${v} './data/foodogsquared-homepage/links/${n}.toml' install -Dm0644 ${v} './data/foodogsquared-homepage/links/${n}.toml'
'') "" data; '') "" data;
installThemes = lib.foldlAttrs (acc: n: v: ''
${acc}
install -Dm0644 ${v} './data/foodogsquared-homepage/themes/${n}}.yaml
'') "" cfg.themes;
in in
cfg.package.overrideAttrs (prevAttrs: { cfg.package.overrideAttrs (prevAttrs: {
preBuild = (prevAttrs.preBuild or "") + '' preBuild = (prevAttrs.preBuild or "") + ''
${installDataDir} ${installDataDir}
${installThemes}
''; '';
}); });
}; };