From e4553546cce35e8bd33916e194cbcf7c8c648c8a Mon Sep 17 00:00:00 2001 From: Bart Bakker Date: Thu, 29 Jul 2021 14:34:08 +0200 Subject: [PATCH] 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'. --- modules/programs/htop.nix | 55 ++----------------- tests/modules/programs/htop/default.nix | 2 +- ...efault-settings.nix => empty-settings.nix} | 2 +- 3 files changed, 6 insertions(+), 53 deletions(-) rename tests/modules/programs/htop/{default-settings.nix => empty-settings.nix} (69%) diff --git a/modules/programs/htop.nix b/modules/programs/htop.nix index 8688e6bca..a6cf4865a 100644 --- a/modules/programs/htop.nix +++ b/modules/programs/htop.nix @@ -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); + }; }; } diff --git a/tests/modules/programs/htop/default.nix b/tests/modules/programs/htop/default.nix index 53653285e..dbe4641f6 100644 --- a/tests/modules/programs/htop/default.nix +++ b/tests/modules/programs/htop/default.nix @@ -1,4 +1,4 @@ { - htop-default-settings = ./default-settings.nix; + htop-empty-settings = ./empty-settings.nix; htop-example-settings = ./example-settings.nix; } diff --git a/tests/modules/programs/htop/default-settings.nix b/tests/modules/programs/htop/empty-settings.nix similarity index 69% rename from tests/modules/programs/htop/default-settings.nix rename to tests/modules/programs/htop/empty-settings.nix index f67e58276..8454e9a5b 100644 --- a/tests/modules/programs/htop/default-settings.nix +++ b/tests/modules/programs/htop/empty-settings.nix @@ -7,7 +7,7 @@ with lib; programs.htop.enable = true; nmt.script = '' - assertFileExists home-files/.config/htop/htoprc + assertPathNotExists home-files/.config/htop ''; }; }