htop: fix order or header_columns setting (#2435)
When `header_columns` is in settings it must appear before any of the `column_meters_*` options. Fixes 2426.
This commit is contained in:
parent
275f955db9
commit
7523252f97
|
@ -170,9 +170,18 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
before = optionalAttrs (cfg.settings ? header_layout) {
|
||||
inherit (cfg.settings) header_layout;
|
||||
};
|
||||
|
||||
settings = defaults // (removeAttrs cfg.settings (attrNames before));
|
||||
|
||||
formatOptions = mapAttrsToList formatOption;
|
||||
|
||||
in mkIf (cfg.settings != { }) {
|
||||
text = concatStringsSep "\n"
|
||||
(mapAttrsToList formatOption (defaults // cfg.settings)) + "\n";
|
||||
text =
|
||||
concatStringsSep "\n" (formatOptions before ++ formatOptions settings)
|
||||
+ "\n";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
htop-empty-settings = ./empty-settings.nix;
|
||||
htop-example-settings = ./example-settings.nix;
|
||||
settings-without-fields = ./settings-without-fields.nix;
|
||||
htop-header_layout = ./header_layout.nix;
|
||||
htop-settings-without-fields = ./settings-without-fields.nix;
|
||||
}
|
||||
|
|
37
tests/modules/programs/htop/header_layout.nix
Normal file
37
tests/modules/programs/htop/header_layout.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = with config.lib.htop; {
|
||||
programs.htop.enable = true;
|
||||
programs.htop.settings = {
|
||||
header_layout = "two_50_50";
|
||||
column_meters_0 = [ "AllCPUs2" "Memory" "Swap" "Zram" ];
|
||||
column_meters_modes_0 = [ modes.Bar modes.Bar modes.Bar modes.Text ];
|
||||
column_meters_1 = [ "Tasks" "LoadAverage" "Uptime" "Systemd" ];
|
||||
column_meters_modes_1 = [ modes.Text modes.Text modes.Text modes.Text ];
|
||||
};
|
||||
|
||||
test.stubs.htop = { };
|
||||
|
||||
# Test that the 'fields' key is written in addition to the customized
|
||||
# settings or htop won't read the options.
|
||||
nmt.script = ''
|
||||
htoprc=home-files/.config/htop/htoprc
|
||||
assertFileExists $htoprc
|
||||
assertFileContent $htoprc \
|
||||
${
|
||||
builtins.toFile "htoprc-expected" ''
|
||||
header_layout=two_50_50
|
||||
column_meters_0=AllCPUs2 Memory Swap Zram
|
||||
column_meters_1=Tasks LoadAverage Uptime Systemd
|
||||
column_meters_modes_0=1 1 1 2
|
||||
column_meters_modes_1=2 2 2 2
|
||||
fields=0 48 17 18 38 39 40 2 46 47 49 1
|
||||
''
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue