mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
btop: add module
This commit is contained in:
parent
960c009ce0
commit
de079ec371
10 changed files with 140 additions and 0 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -83,6 +83,9 @@ Makefile @thiagokokada
|
|||
|
||||
/modules/programs/broot.nix @aheaume
|
||||
|
||||
/modules/programs/btop.nix @GaetanLepage
|
||||
/tests/modules/programs/btop.nix @GaetanLepage
|
||||
|
||||
/modules/programs/dircolors.nix @JustinLovinger
|
||||
|
||||
/modules/programs/direnv.nix @rycee
|
||||
|
|
|
@ -153,6 +153,12 @@
|
|||
githubId = 53856373;
|
||||
name = "Jens Krewald";
|
||||
};
|
||||
GaetanLepage = {
|
||||
email = "gaetan@glepage.com";
|
||||
github = "GaetanLepage";
|
||||
githubId = 33058747;
|
||||
name = "Gaetan Lepage";
|
||||
};
|
||||
maximsmol = {
|
||||
email = "maximsmol@gmail.com";
|
||||
github = "maximsmol";
|
||||
|
|
|
@ -661,6 +661,13 @@ in
|
|||
A new module is available: 'services.pueue'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2022-09-05T12:33:11+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.btop'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ let
|
|||
./programs/bottom.nix
|
||||
./programs/broot.nix
|
||||
./programs/browserpass.nix
|
||||
./programs/btop.nix
|
||||
./programs/chromium.nix
|
||||
./programs/command-not-found/command-not-found.nix
|
||||
./programs/dircolors.nix
|
||||
|
|
64
modules/programs/btop.nix
Normal file
64
modules/programs/btop.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{ 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 = {
|
||||
enable = mkEnableOption "btop";
|
||||
|
||||
package = mkPackageOption pkgs "btop" { };
|
||||
|
||||
settings = mkOption {
|
||||
type = with types; attrsOf (oneOf [ bool float int str ]);
|
||||
default = { };
|
||||
example = {
|
||||
color_theme = "Default";
|
||||
theme_background = false;
|
||||
};
|
||||
description = ''
|
||||
Options to add to <filename>btop.conf</filename> file.
|
||||
See <link xlink:href="https://github.com/aristocratos/btop#configurability"/>
|
||||
for options.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra lines added to the <filename>btop.conf</filename> file.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile."btop/btop.conf" =
|
||||
mkIf (cfg.settings != { }) { text = finalConfig; };
|
||||
};
|
||||
}
|
|
@ -64,6 +64,7 @@ import nmt {
|
|||
./modules/programs/bottom
|
||||
./modules/programs/broot
|
||||
./modules/programs/browserpass
|
||||
./modules/programs/btop
|
||||
./modules/programs/dircolors
|
||||
./modules/programs/direnv
|
||||
./modules/programs/emacs
|
||||
|
|
4
tests/modules/programs/btop/default.nix
Normal file
4
tests/modules/programs/btop/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
btop-example-settings = ./example-settings.nix;
|
||||
btop-empty-settings = ./empty-settings.nix;
|
||||
}
|
11
tests/modules/programs/btop/empty-settings.nix
Normal file
11
tests/modules/programs/btop/empty-settings.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.btop.enable = true;
|
||||
|
||||
test.stubs.btop = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/btop
|
||||
'';
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
disks_filter = "exclude=/foo/bar"
|
||||
io_graph_combined = True
|
||||
io_graph_speeds = ""
|
||||
log_level = "DEBUG"
|
||||
show_io_stat = False
|
||||
update_ms = 1000
|
||||
|
||||
clock_format = "%H:%M"
|
||||
|
34
tests/modules/programs/btop/example-settings.nix
Normal file
34
tests/modules/programs/btop/example-settings.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.btop = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
|
||||
settings = {
|
||||
# Integer
|
||||
update_ms = 1000;
|
||||
|
||||
# Boolean
|
||||
show_io_stat = false;
|
||||
io_graph_combined = true;
|
||||
|
||||
# String
|
||||
disks_filter = "exclude=/foo/bar";
|
||||
log_level = "DEBUG";
|
||||
|
||||
# Empty string
|
||||
io_graph_speeds = "";
|
||||
};
|
||||
|
||||
extraConfig = ''
|
||||
clock_format = "%H:%M"
|
||||
'';
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/btop/btop.conf \
|
||||
${./example-settings-expected.conf}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue