fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.4 KiB64 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.btop;
8
9  finalConfig = let
10    toKeyValue = generators.toKeyValue {
11      mkKeyValue = generators.mkKeyValueDefault {
12        mkValueString = v:
13          with builtins;
14          if isBool v then
15            (if v then "True" else "False")
16          else if isString v then
17            ''"${v}"''
18          else
19            toString v;
20      } " = ";
21    };
22  in ''
23    ${toKeyValue cfg.settings}
24    ${optionalString (cfg.extraConfig != "") cfg.extraConfig}
25  '';
26
27in {
28  meta.maintainers = [ hm.maintainers.GaetanLepage ];
29
30  options.programs.btop = {
31    enable = mkEnableOption "btop";
32
33    package = mkPackageOption pkgs "btop" { };
34
35    settings = mkOption {
36      type = with types; attrsOf (oneOf [ bool float int str ]);
37      default = { };
38      example = {
39        color_theme = "Default";
40        theme_background = false;
41      };
42      description = ''
43        Options to add to {file}`btop.conf` file.
44        See <https://github.com/aristocratos/btop#configurability>
45        for options.
46      '';
47    };
48
49    extraConfig = mkOption {
50      type = types.lines;
51      default = "";
52      description = ''
53        Extra lines added to the {file}`btop.conf` file.
54      '';
55    };
56  };
57
58  config = mkIf cfg.enable {
59    home.packages = [ cfg.package ];
60
61    xdg.configFile."btop/btop.conf" =
62      mkIf (cfg.settings != { }) { text = finalConfig; };
63  };
64}