1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-09 18:26:54 +00:00
home-manager/modules/programs/btop.nix

60 lines
1.5 KiB
Nix
Raw Normal View History

2022-08-17 18:16:01 +02:00
{ config, lib, pkgs, ... }:
let
cfg = config.programs.btop;
finalConfig = let
2025-01-30 12:51:21 -06:00
toKeyValue = lib.generators.toKeyValue {
mkKeyValue = lib.generators.mkKeyValueDefault {
2022-08-17 18:16:01 +02:00
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}
2025-01-30 12:51:21 -06:00
${lib.optionalString (cfg.extraConfig != "") cfg.extraConfig}
2022-08-17 18:16:01 +02:00
'';
in {
2025-01-30 12:28:56 -06:00
meta.maintainers = with lib.maintainers; [ GaetanLepage khaneliman ];
2022-08-17 18:16:01 +02:00
options.programs.btop = {
2025-01-30 12:51:21 -06:00
enable = lib.mkEnableOption "btop";
2022-08-17 18:16:01 +02:00
2025-01-30 12:51:21 -06:00
package = lib.mkPackageOption pkgs "btop" { };
2022-08-17 18:16:01 +02:00
2025-01-30 12:51:21 -06:00
settings = lib.mkOption {
type = with lib.types; attrsOf (oneOf [ bool float int str ]);
2022-08-17 18:16:01 +02:00
default = { };
example = {
color_theme = "Default";
theme_background = false;
};
description = ''
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.
'';
};
2025-01-30 12:51:21 -06:00
extraConfig = lib.mkOption {
type = lib.types.lines;
2022-08-17 18:16:01 +02:00
default = "";
description = ''
Extra lines added to the {file}`btop.conf` file.
2022-08-17 18:16:01 +02:00
'';
};
};
2025-01-30 12:51:21 -06:00
config = lib.mkIf cfg.enable {
2022-08-17 18:16:01 +02:00
home.packages = [ cfg.package ];
xdg.configFile."btop/btop.conf" =
2025-01-30 12:51:21 -06:00
lib.mkIf (cfg.settings != { }) { text = finalConfig; };
2022-08-17 18:16:01 +02:00
};
}