Add colorSchemes option to konsole module (#183)

This commit is contained in:
blitter 2024-06-03 21:42:05 +02:00 committed by GitHub
parent 7c816ab287
commit 82da66c417
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,13 @@
let
inherit (import ../../lib/types.nix { inherit lib; }) basicSettingsType;
# used as shown in the example in the library docs:
# https://ryantm.github.io/nixpkgs/functions/library/attrsets/#function-library-lib.attrsets.mapAttrs-prime
createColorSchemes = lib.attrsets.mapAttrs' (name: value: lib.attrsets.nameValuePair
("konsole/${name}.colorscheme")
( { enable = true; source = value; })
);
cfg = config.programs.konsole;
profilesSubmodule = {
options = {
@ -18,7 +25,9 @@ let
example = "Catppuccin-Mocha";
description = ''
Color scheme the profile will use. You can check the files you can
use in ~/.local/share/konsole or /run/current-system/share/konsole
use in ~/.local/share/konsole or /run/current-system/share/konsole.
You might also add a custom color scheme using
`programs.konsole.customColorSchemes`.
'';
};
command = lib.mkOption {
@ -92,6 +101,15 @@ in
'';
};
customColorSchemes = lib.mkOption {
type = with lib.types; attrsOf path;
default = {};
description = ''
Custom color schemes to be added to the installation. The key is their name.
Choose them in any profile with `profiles.<profile>.colorScheme = <name>`;
'';
};
extraConfig = lib.mkOption {
type = with lib.types; nullOr (attrsOf (attrsOf (basicSettingsType)));
default = null;
@ -116,9 +134,10 @@ in
)
];
xdg.dataFile = lib.mkIf (cfg.profiles != { })
(
lib.mkMerge ([
xdg.dataFile = lib.mkMerge [
(lib.mkIf (cfg.profiles != { })
(
lib.mkMerge ([
(
lib.mkMerge (
lib.mapAttrsToList
@ -157,7 +176,10 @@ in
cfg.profiles
)
)
])
);
])
)
)
(createColorSchemes cfg.customColorSchemes)
];
};
}