diff --git a/modules/programs/htop.nix b/modules/programs/htop.nix index 0d353026..7141ff34 100644 --- a/modules/programs/htop.nix +++ b/modules/programs/htop.nix @@ -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) { diff --git a/tests/modules/programs/htop/header_layout.nix b/tests/modules/programs/htop/header_layout.nix index 2cf34998..aaf62852 100644 --- a/tests/modules/programs/htop/header_layout.nix +++ b/tests/modules/programs/htop/header_layout.nix @@ -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} '' } ''; diff --git a/tests/modules/programs/htop/settings-without-fields.nix b/tests/modules/programs/htop/settings-without-fields.nix index 2f4b3e86..f1efac2d 100644 --- a/tests/modules/programs/htop/settings-without-fields.nix +++ b/tests/modules/programs/htop/settings-without-fields.nix @@ -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} '' } '';