refactor(vars): get list of colors from schemes
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-06-28 22:09:17 -04:00
parent 261efa8768
commit 724ced18f1
2 changed files with 10 additions and 6 deletions

View file

@ -3,7 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkOption types; inherit (lib) mkDefault mkOption types;
flakeDir = config.environment.variables.FLAKE; flakeDir = config.environment.variables.FLAKE;
cfg = config.vars; cfg = config.vars;
in { in {
@ -23,7 +23,7 @@ in {
}; };
promptMainColor = mkOption { promptMainColor = mkOption {
type = types.enum ["red" "green" "blue" "purple" "orange" "yellow" "cyan" "pink"]; type = types.enum (import ./prompt-schemes.nix {});
default = "purple"; default = "purple";
}; };
@ -32,7 +32,7 @@ in {
Colors used in starship prompt Colors used in starship prompt
''; '';
default = import ./prompt-schemes.nix cfg.promptMainColor; default = import ./prompt-schemes.nix {color = cfg.promptMainColor;};
readOnly = true; readOnly = true;
type = types.submodule { type = types.submodule {
@ -63,6 +63,6 @@ in {
}; };
config = { config = {
environment.variables.FLAKE = lib.mkDefault "/home/${cfg.mainUser}/.nix"; environment.variables.FLAKE = mkDefault "/home/${cfg.mainUser}/.nix";
}; };
} }

View file

@ -1,4 +1,6 @@
color: let {color ? null}: let
inherit (builtins) attrNames removeAttrs;
schemes = { schemes = {
"purple" = { "purple" = {
textColor = "#090c0c"; textColor = "#090c0c";
@ -74,4 +76,6 @@ color: let
}; };
}; };
in in
schemes.${color} if ! isNull color
then schemes.${color}
else attrNames (removeAttrs schemes ["color"])