1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

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:
Bart Bakker 2021-11-01 19:27:29 +00:00 committed by GitHub
parent 275f955db9
commit 7523252f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 3 deletions

View file

@ -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 != { }) { in mkIf (cfg.settings != { }) {
text = concatStringsSep "\n" text =
(mapAttrsToList formatOption (defaults // cfg.settings)) + "\n"; concatStringsSep "\n" (formatOptions before ++ formatOptions settings)
+ "\n";
}; };
}; };
} }

View file

@ -1,5 +1,6 @@
{ {
htop-empty-settings = ./empty-settings.nix; htop-empty-settings = ./empty-settings.nix;
htop-example-settings = ./example-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;
} }

View 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
''
}
'';
};
}