Skip to content

Commit d787ec6

Browse files
bmripskhaneliman
authored andcommitted
less: list options in correct order
1 parent 07d7972 commit d787ec6

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

modules/programs/less.nix

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ in
4343
int
4444
str
4545
];
46+
attrs = attrsOf (either scalar (listOf scalar));
4647
in
47-
attrsOf (either scalar (listOf scalar));
48-
default = { };
49-
description = "GNU-style options to be set via {env}`$LESS`.";
48+
coercedTo attrs (lib.cli.toGNUCommandLine { }) (listOf str);
49+
default = [ ];
50+
description = "Options to be set via {env}`$LESS`.";
5051
example = {
5152
RAW-CONTROL-CHARS = true;
5253
quiet = true;
@@ -61,10 +62,10 @@ in
6162

6263
xdg.configFile."lesskey" = lib.mkIf (cfg.config != "") { text = cfg.config; };
6364

64-
programs.less.config = lib.mkIf (cfg.options != { }) (
65+
programs.less.config = lib.mkIf (cfg.options != [ ]) (
6566
lib.mkBefore ''
6667
#env
67-
LESS = ${lib.cli.toGNUCommandLineShell { } cfg.options}
68+
LESS = ${lib.concatStringsSep " " cfg.options}
6869
''
6970
);
7071
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ lib, ... }:
2+
3+
{
4+
programs.less = {
5+
enable = true;
6+
options = lib.mkMerge [
7+
{
8+
quiet = true;
9+
use-color = true;
10+
}
11+
(lib.mkAfter {
12+
color = [
13+
"HkK" # header: gray
14+
"Mkb" # marks: blue
15+
];
16+
})
17+
(lib.mkOrder 2000 {
18+
prompt = "s%f";
19+
})
20+
];
21+
};
22+
23+
nmt.script = ''
24+
assertFileExists home-files/.config/lesskey
25+
assertFileContent home-files/.config/lesskey ${builtins.toFile "lesskey.expected" ''
26+
#env
27+
LESS = --quiet --use-color --color HkK --color Mkb --prompt s%f
28+
''}
29+
'';
30+
}

tests/modules/programs/less/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
less-correct-option-order = ./correct-option-order.nix;
23
less-custom-config = ./custom-config.nix;
34
less-custom-options = ./custom-options.nix;
45
less-custom-options-and-config = ./custom-options-and-config.nix;

0 commit comments

Comments
 (0)