htop: let htop program use its default settings

Don't generate the `htoprc` when using default settings to use the defaults of
the htop program.

Rename the test for this case to 'empty-settings'.
This commit is contained in:
Bart Bakker 2021-07-29 14:34:08 +02:00 committed by Robert Helgesson
parent 7226c2db46
commit e4553546cc
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
3 changed files with 6 additions and 53 deletions

View File

@ -96,55 +96,7 @@ in {
settings = mkOption {
type = types.attrs;
default = {
account_guest_in_cpu_meter = false;
color_scheme = 0;
cpu_count_from_zero = false;
delay = 15;
detailed_cpu_time = false;
enable_mouse = true;
fields = with fields; [
PID
USER
PRIORITY
NICE
M_SIZE
M_RESIDENT
M_SHARE
STATE
PERCENT_CPU
PERCENT_MEM
TIME
COMM
];
header_margin = true;
hide_kernel_threads = true;
hide_threads = false;
hide_userland_threads = false;
highlight_base_name = false;
highlight_megabytes = true;
highlight_threads = true;
shadow_other_users = false;
show_cpu_frequency = false;
show_cpu_usage = false;
show_program_path = true;
show_thread_names = false;
sort_direction = 1;
sort_key = fields.PERCENT_CPU;
tree_view = false;
update_process_names = false;
vim_mode = false;
} // (leftMeters [
(bar "AllCPUs2")
(bar "Memory")
(bar "Swap")
(text "Zram")
]) // (rightMeters [
(text "Tasks")
(text "LoadAverage")
(text "Uptime")
(text "Systemd")
]);
default = { };
example = literalExample ''
{
color_scheme = 6;
@ -193,7 +145,8 @@ in {
home.packages = [ pkgs.htop ];
xdg.configFile."htop/htoprc".text =
concatStringsSep "\n" (mapAttrsToList formatOption cfg.settings);
xdg.configFile."htop/htoprc" = mkIf (cfg.settings != { }) {
text = concatStringsSep "\n" (mapAttrsToList formatOption cfg.settings);
};
};
}

View File

@ -1,4 +1,4 @@
{
htop-default-settings = ./default-settings.nix;
htop-empty-settings = ./empty-settings.nix;
htop-example-settings = ./example-settings.nix;
}

View File

@ -7,7 +7,7 @@ with lib;
programs.htop.enable = true;
nmt.script = ''
assertFileExists home-files/.config/htop/htoprc
assertPathNotExists home-files/.config/htop
'';
};
}