40 lines
1.0 KiB
Nix
40 lines
1.0 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep typeOf;
|
|
cfg = config.programs.culr;
|
|
in {
|
|
options.programs.culr = {
|
|
enable = mkEnableOption "culr";
|
|
pattern = mkOption {
|
|
type = with types; either str (listOf int);
|
|
default = [];
|
|
description = "colourising pattern";
|
|
};
|
|
palette = mkOption {
|
|
type = with types; listOf str;
|
|
default = [];
|
|
description = "palette to use in comma separated RGB hex eg. #0f0f0f";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
environment.systemPackages = let inherit (pkgs) culr; in [culr];
|
|
environment.sessionVariables = {
|
|
CULR_PATTERN = let
|
|
serialise = {
|
|
list = list: concatStringsSep ";" list;
|
|
string = s: s;
|
|
};
|
|
in
|
|
mkIf (cfg.pattern != "" && cfg.pattern != [])
|
|
(serialise.${typeOf cfg.pattern}
|
|
cfg.pattern);
|
|
CULR_PALETTE = mkIf (cfg.palette != []) (concatStringsSep ";" cfg.palette);
|
|
};
|
|
};
|
|
}
|