mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-18 02:44:30 +00:00
less: improve default settings (#139988)
* less: enable by default and set LESS=-R via lesskey
* since we set PAGER=less, programs.less.enable should default to
true.
* some programs, notably git, set a custom LESS environment if none is
present. using the lesskey mechanism to set LESS=-R lets such
programs continue to run less as they see fit.
This reverts commit 0e7b4e60a8
.
* less: remove use of deprecated lesskey binary format
* less: enable in environment.nix rather than less.nix
per discussion in #139988
This commit is contained in:
parent
14ec4a326f
commit
a2a0a58f7c
@ -18,12 +18,16 @@ in
|
||||
|
||||
environment.variables =
|
||||
{ NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
|
||||
# note: many programs exec() this directly, so default options for less must not
|
||||
# be specified here; do so in the default value of programs.less.envVariables instead
|
||||
PAGER = mkDefault "less";
|
||||
LESS = mkDefault "-R";
|
||||
EDITOR = mkDefault "nano";
|
||||
XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
|
||||
};
|
||||
|
||||
# since we set PAGER to this above, make sure it's installed
|
||||
programs.less.enable = true;
|
||||
|
||||
environment.profiles = mkAfter
|
||||
[ "/nix/var/nix/profiles/default"
|
||||
"/run/current-system/sw"
|
||||
|
@ -24,9 +24,7 @@ let
|
||||
}
|
||||
'';
|
||||
|
||||
lessKey = pkgs.runCommand "lesskey"
|
||||
{ src = pkgs.writeText "lessconfig" configText; preferLocalBuild = true; }
|
||||
"${pkgs.less}/bin/lesskey -o $out $src";
|
||||
lessKey = pkgs.writeText "lessconfig" configText;
|
||||
|
||||
in
|
||||
|
||||
@ -35,6 +33,8 @@ in
|
||||
|
||||
programs.less = {
|
||||
|
||||
# note that environment.nix sets PAGER=less, and
|
||||
# therefore also enables this module
|
||||
enable = mkEnableOption "less";
|
||||
|
||||
configFile = mkOption {
|
||||
@ -81,7 +81,9 @@ in
|
||||
|
||||
envVariables = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
default = {
|
||||
LESS = "-R";
|
||||
};
|
||||
example = {
|
||||
LESS = "--quit-if-one-screen";
|
||||
};
|
||||
@ -112,7 +114,7 @@ in
|
||||
environment.systemPackages = [ pkgs.less ];
|
||||
|
||||
environment.variables = {
|
||||
LESSKEY_SYSTEM = toString lessKey;
|
||||
LESSKEYIN_SYSTEM = toString lessKey;
|
||||
} // optionalAttrs (cfg.lessopen != null) {
|
||||
LESSOPEN = cfg.lessopen;
|
||||
} // optionalAttrs (cfg.lessclose != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user