1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

htop: fix darwin defaults

M_SHARE is not a valid column on Darwin. It seems that previously htop
ignored unknown columns, but the current version does not display all
subsequent columns.
This commit is contained in:
Roman Timushev 2022-05-13 22:53:16 +02:00 committed by Robert Helgesson
parent cb9f03d519
commit e6869735d2
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 34 additions and 18 deletions

View file

@ -3,6 +3,7 @@
with lib;
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
cfg = config.programs.htop;
@ -73,6 +74,21 @@ let
M_PSSWP = 120;
};
defaultFields = with fields; [
PID
USER
PRIORITY
NICE
M_SIZE
M_RESIDENT
M_SHARE
STATE
PERCENT_CPU
PERCENT_MEM
TIME
COMM
];
modes = {
Bar = 1;
Text = 2;
@ -154,20 +170,10 @@ in {
xdg.configFile."htop/htoprc" = let
defaults = {
fields = with fields; [
PID
USER
PRIORITY
NICE
M_SIZE
M_RESIDENT
M_SHARE
STATE
PERCENT_CPU
PERCENT_MEM
TIME
COMM
];
fields = if isDarwin then
remove fields.M_SHARE defaultFields
else
defaultFields;
};
before = optionalAttrs (cfg.settings ? header_layout) {

View file

@ -17,7 +17,12 @@ with lib;
# Test that the 'fields' key is written in addition to the customized
# settings or htop won't read the options.
nmt.script = ''
nmt.script = let
fields = if pkgs.stdenv.hostPlatform.isDarwin then
"0 48 17 18 38 39 2 46 47 49 1"
else
"0 48 17 18 38 39 40 2 46 47 49 1";
in ''
htoprc=home-files/.config/htop/htoprc
assertFileExists $htoprc
assertFileContent $htoprc \
@ -28,7 +33,7 @@ with lib;
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
fields=${fields}
''
}
'';

View file

@ -11,14 +11,19 @@ with lib;
# Test that the 'fields' key is written in addition to the customized
# settings or htop won't read the options.
nmt.script = ''
nmt.script = let
fields = if pkgs.stdenv.hostPlatform.isDarwin then
"0 48 17 18 38 39 2 46 47 49 1"
else
"0 48 17 18 38 39 40 2 46 47 49 1";
in ''
htoprc=home-files/.config/htop/htoprc
assertFileExists $htoprc
assertFileContent $htoprc \
${
builtins.toFile "htoprc-expected" ''
color_scheme=6
fields=0 48 17 18 38 39 40 2 46 47 49 1
fields=${fields}
''
}
'';