mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03: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
2 changed files with 12 additions and 6 deletions
|
@ -18,12 +18,16 @@ in
|
||||||
|
|
||||||
environment.variables =
|
environment.variables =
|
||||||
{ NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
|
{ 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";
|
PAGER = mkDefault "less";
|
||||||
LESS = mkDefault "-R";
|
|
||||||
EDITOR = mkDefault "nano";
|
EDITOR = mkDefault "nano";
|
||||||
XDG_CONFIG_DIRS = [ "/etc/xdg" ]; # needs to be before profile-relative paths to allow changes through environment.etc
|
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
|
environment.profiles = mkAfter
|
||||||
[ "/nix/var/nix/profiles/default"
|
[ "/nix/var/nix/profiles/default"
|
||||||
"/run/current-system/sw"
|
"/run/current-system/sw"
|
||||||
|
|
|
@ -24,9 +24,7 @@ let
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
lessKey = pkgs.runCommand "lesskey"
|
lessKey = pkgs.writeText "lessconfig" configText;
|
||||||
{ src = pkgs.writeText "lessconfig" configText; preferLocalBuild = true; }
|
|
||||||
"${pkgs.less}/bin/lesskey -o $out $src";
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -35,6 +33,8 @@ in
|
||||||
|
|
||||||
programs.less = {
|
programs.less = {
|
||||||
|
|
||||||
|
# note that environment.nix sets PAGER=less, and
|
||||||
|
# therefore also enables this module
|
||||||
enable = mkEnableOption "less";
|
enable = mkEnableOption "less";
|
||||||
|
|
||||||
configFile = mkOption {
|
configFile = mkOption {
|
||||||
|
@ -81,7 +81,9 @@ in
|
||||||
|
|
||||||
envVariables = mkOption {
|
envVariables = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = types.attrsOf types.str;
|
||||||
default = {};
|
default = {
|
||||||
|
LESS = "-R";
|
||||||
|
};
|
||||||
example = {
|
example = {
|
||||||
LESS = "--quit-if-one-screen";
|
LESS = "--quit-if-one-screen";
|
||||||
};
|
};
|
||||||
|
@ -112,7 +114,7 @@ in
|
||||||
environment.systemPackages = [ pkgs.less ];
|
environment.systemPackages = [ pkgs.less ];
|
||||||
|
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
LESSKEY_SYSTEM = toString lessKey;
|
LESSKEYIN_SYSTEM = toString lessKey;
|
||||||
} // optionalAttrs (cfg.lessopen != null) {
|
} // optionalAttrs (cfg.lessopen != null) {
|
||||||
LESSOPEN = cfg.lessopen;
|
LESSOPEN = cfg.lessopen;
|
||||||
} // optionalAttrs (cfg.lessclose != null) {
|
} // optionalAttrs (cfg.lessclose != null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue