2022-08-17 18:16:01 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.btop;
|
|
|
|
|
|
|
|
finalConfig = let
|
|
|
|
toKeyValue = generators.toKeyValue {
|
|
|
|
mkKeyValue = generators.mkKeyValueDefault {
|
|
|
|
mkValueString = v:
|
|
|
|
with builtins;
|
|
|
|
if isBool v then
|
|
|
|
(if v then "True" else "False")
|
|
|
|
else if isString v then
|
|
|
|
''"${v}"''
|
|
|
|
else
|
|
|
|
toString v;
|
|
|
|
} " = ";
|
|
|
|
};
|
|
|
|
in ''
|
|
|
|
${toKeyValue cfg.settings}
|
|
|
|
${optionalString (cfg.extraConfig != "") cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ hm.maintainers.GaetanLepage ];
|
|
|
|
|
|
|
|
options.programs.btop = {
|
2023-07-01 01:30:13 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "btop");
|
2022-08-17 18:16:01 +02:00
|
|
|
|
2023-07-01 11:41:32 +02:00
|
|
|
package = mkPackageOptionMD pkgs "btop" { };
|
2022-08-17 18:16:01 +02:00
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = with types; attrsOf (oneOf [ bool float int str ]);
|
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
color_theme = "Default";
|
|
|
|
theme_background = false;
|
|
|
|
};
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Options to add to {file}`btop.conf` file.
|
|
|
|
See <https://github.com/aristocratos/btop#configurability>
|
2022-08-17 18:16:01 +02:00
|
|
|
for options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Extra lines added to the {file}`btop.conf` file.
|
2022-08-17 18:16:01 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xdg.configFile."btop/btop.conf" =
|
|
|
|
mkIf (cfg.settings != { }) { text = finalConfig; };
|
|
|
|
};
|
|
|
|
}
|