mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
less: configure LESS options
This commit is contained in:
parent
dfcea0573d
commit
67393957c2
5 changed files with 73 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ in
|
||||||
type = lib.types.lines;
|
type = lib.types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
example = ''
|
example = ''
|
||||||
|
#command
|
||||||
s back-line
|
s back-line
|
||||||
t forw-line
|
t forw-line
|
||||||
'';
|
'';
|
||||||
|
|
@ -32,6 +33,23 @@ in
|
||||||
{file}`$XDG_CONFIG_HOME/lesskey`.
|
{file}`$XDG_CONFIG_HOME/lesskey`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options = lib.mkOption {
|
||||||
|
type =
|
||||||
|
with lib.types;
|
||||||
|
attrsOf (oneOf [
|
||||||
|
bool
|
||||||
|
int
|
||||||
|
str
|
||||||
|
]);
|
||||||
|
default = { };
|
||||||
|
description = "GNU-style options to be set via {env}`$LESS`.";
|
||||||
|
example = {
|
||||||
|
RAW-CONTROL-CHARS = true;
|
||||||
|
quiet = true;
|
||||||
|
wheel-lines = 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -39,5 +57,12 @@ in
|
||||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."lesskey" = lib.mkIf (cfg.config != "") { text = cfg.config; };
|
xdg.configFile."lesskey" = lib.mkIf (cfg.config != "") { text = cfg.config; };
|
||||||
|
|
||||||
|
programs.less.config = lib.mkIf (cfg.options != { }) (
|
||||||
|
lib.mkBefore ''
|
||||||
|
#env
|
||||||
|
LESS = ${lib.cli.toGNUCommandLineShell { } cfg.options}
|
||||||
|
''
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
let
|
let
|
||||||
config = ''
|
config = ''
|
||||||
|
#command
|
||||||
s back-line
|
s back-line
|
||||||
t forw-line
|
t forw-line
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
27
tests/modules/programs/less/custom-options-and-config.nix
Normal file
27
tests/modules/programs/less/custom-options-and-config.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
let
|
||||||
|
config = ''
|
||||||
|
#command
|
||||||
|
s back-line
|
||||||
|
t forw-line
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
programs.less = {
|
||||||
|
enable = true;
|
||||||
|
inherit config;
|
||||||
|
options = {
|
||||||
|
RAW-CONTROL-CHARS = true;
|
||||||
|
quiet = true;
|
||||||
|
wheel-lines = 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/lesskey
|
||||||
|
assertFileContent home-files/.config/lesskey ${builtins.toFile "less.expected" ''
|
||||||
|
#env
|
||||||
|
LESS = --RAW-CONTROL-CHARS --quiet --wheel-lines 3
|
||||||
|
|
||||||
|
${config}''}
|
||||||
|
'';
|
||||||
|
}
|
||||||
18
tests/modules/programs/less/custom-options.nix
Normal file
18
tests/modules/programs/less/custom-options.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
programs.less = {
|
||||||
|
enable = true;
|
||||||
|
options = {
|
||||||
|
RAW-CONTROL-CHARS = true;
|
||||||
|
quiet = true;
|
||||||
|
wheel-lines = 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/lesskey
|
||||||
|
assertFileContent home-files/.config/lesskey ${builtins.toFile "lesskey.expected" ''
|
||||||
|
#env
|
||||||
|
LESS = --RAW-CONTROL-CHARS --quiet --wheel-lines 3
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
less-custom-config = ./custom-config.nix;
|
less-custom-config = ./custom-config.nix;
|
||||||
|
less-custom-options = ./custom-options.nix;
|
||||||
|
less-custom-options-and-config = ./custom-options-and-config.nix;
|
||||||
less-no-config = ./no-config.nix;
|
less-no-config = ./no-config.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue