File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed
tests/modules/programs/less Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 6262 xdg . configFile . "lesskey" = lib . mkIf ( cfg . config != "" ) { text = cfg . config ; } ;
6363
6464 programs . less . config = lib . mkIf ( cfg . options != { } ) (
65+ let
66+ color = lib . intersectAttrs {
67+ color = null ;
68+ D = null ;
69+ } cfg . options ;
70+ prompt = lib . intersectAttrs {
71+ prompt = null ;
72+ P = null ;
73+ } cfg . options ;
74+ otherOptions = lib . removeAttrs cfg . options [
75+ "color"
76+ "D"
77+ "P"
78+ "prompt"
79+ ] ;
80+
81+ toCommandLine = lib . cli . toCommandLineShell ( k : {
82+ option = if builtins . stringLength k == 1 then "-${ k } " else "--${ k } " ;
83+ sep = null ; # options and values must be separate strings
84+ explicitBool = false ;
85+ } ) ;
86+
87+ orderedOptions = lib . filter ( x : x != { } ) [
88+ otherOptions
89+ color # colors need to come after `--use-color`.
90+ prompt # the prompt has to be the last option.
91+ ] ;
92+ in
6593 lib . mkBefore ''
6694 #env
67- LESS = ${ lib . cli . toGNUCommandLineShell { } cfg . options }
95+ LESS = ${ lib . concatMapStringsSep " " toCommandLine orderedOptions }
6896 ''
6997 ) ;
7098 } ;
Original file line number Diff line number Diff line change 1+ {
2+ programs . less = {
3+ enable = true ;
4+ options = {
5+ color = [
6+ "HkK" # header: gray
7+ "Mkb" # marks: blue
8+ ] ;
9+ prompt = "s%f" ;
10+ quiet = true ;
11+ } ;
12+ } ;
13+
14+ nmt . script = ''
15+ assertFileExists home-files/.config/lesskey
16+ assertFileContent home-files/.config/lesskey ${ builtins . toFile "lesskey.expected" ''
17+ #env
18+ LESS = --quiet --color HkK --color Mkb --prompt s%f
19+ '' }
20+ '' ;
21+ }
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments