less: list options in correct order

This commit is contained in:
Benedikt Rips 2025-11-23 15:42:16 +01:00 committed by Austin Horstman
parent 07d79726f1
commit d787ec69c3
3 changed files with 37 additions and 5 deletions

View file

@ -43,10 +43,11 @@ in
int
str
];
attrs = attrsOf (either scalar (listOf scalar));
in
attrsOf (either scalar (listOf scalar));
default = { };
description = "GNU-style options to be set via {env}`$LESS`.";
coercedTo attrs (lib.cli.toGNUCommandLine { }) (listOf str);
default = [ ];
description = "Options to be set via {env}`$LESS`.";
example = {
RAW-CONTROL-CHARS = true;
quiet = true;
@ -61,10 +62,10 @@ in
xdg.configFile."lesskey" = lib.mkIf (cfg.config != "") { text = cfg.config; };
programs.less.config = lib.mkIf (cfg.options != { }) (
programs.less.config = lib.mkIf (cfg.options != [ ]) (
lib.mkBefore ''
#env
LESS = ${lib.cli.toGNUCommandLineShell { } cfg.options}
LESS = ${lib.concatStringsSep " " cfg.options}
''
);
};

View file

@ -0,0 +1,30 @@
{ lib, ... }:
{
programs.less = {
enable = true;
options = lib.mkMerge [
{
quiet = true;
use-color = true;
}
(lib.mkAfter {
color = [
"HkK" # header: gray
"Mkb" # marks: blue
];
})
(lib.mkOrder 2000 {
prompt = "s%f";
})
];
};
nmt.script = ''
assertFileExists home-files/.config/lesskey
assertFileContent home-files/.config/lesskey ${builtins.toFile "lesskey.expected" ''
#env
LESS = --quiet --use-color --color HkK --color Mkb --prompt s%f
''}
'';
}

View file

@ -1,4 +1,5 @@
{
less-correct-option-order = ./correct-option-order.nix;
less-custom-config = ./custom-config.nix;
less-custom-options = ./custom-options.nix;
less-custom-options-and-config = ./custom-options-and-config.nix;