mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 06:59:45 +01:00
htop: use types.coercedTo
This commit is contained in:
parent
be432c8654
commit
1d24e96074
1 changed files with 21 additions and 25 deletions
|
@ -87,7 +87,10 @@ let
|
||||||
"CPU(4)" = 1;
|
"CPU(4)" = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
singleMeterType = types.either (types.enum (attrNames meters)) (types.submodule {
|
singleMeterType = types.coercedTo
|
||||||
|
(types.enum (attrNames meters))
|
||||||
|
(m: { kind = m; mode = meters.${m}; })
|
||||||
|
(types.submodule {
|
||||||
options = {
|
options = {
|
||||||
kind = mkOption {
|
kind = mkOption {
|
||||||
type = types.enum (attrNames meters);
|
type = types.enum (attrNames meters);
|
||||||
|
@ -103,13 +106,6 @@ let
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
# Converts the meter to an attribute set if it isn't already
|
|
||||||
meterStandard = m: if builtins.isString m then {
|
|
||||||
kind = m;
|
|
||||||
mode = meters.${m};
|
|
||||||
} else m;
|
|
||||||
|
|
||||||
|
|
||||||
meterType = types.submodule {
|
meterType = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
left = mkOption {
|
left = mkOption {
|
||||||
|
@ -295,10 +291,10 @@ in
|
||||||
home.packages = [ pkgs.htop ];
|
home.packages = [ pkgs.htop ];
|
||||||
|
|
||||||
home.file.".config/htop/htoprc".text = let
|
home.file.".config/htop/htoprc".text = let
|
||||||
leftMeters = map (m: (meterStandard m).kind) cfg.meters.left;
|
leftMeters = map (m: m.kind) cfg.meters.left;
|
||||||
leftModes = map (m: (meterStandard m).mode) cfg.meters.left;
|
leftModes = map (m: m.mode) cfg.meters.left;
|
||||||
rightMeters = map (m: (meterStandard m).kind) cfg.meters.right;
|
rightMeters = map (m: m.kind) cfg.meters.right;
|
||||||
rightModes = map (m: (meterStandard m).mode) cfg.meters.right;
|
rightModes = map (m: m.mode) cfg.meters.right;
|
||||||
in ''
|
in ''
|
||||||
# This file is regenerated by home-manager
|
# This file is regenerated by home-manager
|
||||||
# when options are changed in the config
|
# when options are changed in the config
|
||||||
|
|
Loading…
Reference in a new issue