git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/less: use lesspipe package for preprocessing

Rather than a custom script the less config now uses the lesspipe package config by default.

commit288898d6f1dc532e1dfb8785a591a2d8ad55320b authorDaniel Schaefer <git@danielschaefer.me> dateMon 29 Jan 2018, 22:08 (9 years ago) parent192c233
1 file changed+19−24
nixos/modules/programs/less.nix+19−24
nixos/modules/programs/less.nix+19−24
@@ -28,24 +28,6 @@ let
2828 { src = pkgs.writeText "lessconfig" configFile; }
2929 "${pkgs.less}/bin/lesskey -o $out $src";
3030
31− lessPipe = pkgs.writeScriptBin "lesspipe.sh" ''
32− #! /bin/sh
33− case "$1" in
34− *.gz)
35− ${pkgs.gzip}/bin/gunzip --stdout "$1" 2>/dev/null
36− ;;
37− *.xz)
38− ${pkgs.xz}/bin/unxz --stdout "$1" 2>/dev/null
39− ;;
40− *.bz2)
41− ${pkgs.bzip2}/bin/bunzip2 --stdout "$1" 2>/dev/null
42− ;;
43− *) exit 1
44− ;;
45− esac
46− exit $?
47− '';
48−
4931in
5032
5133{
@@ -93,11 +75,19 @@ in
9375 description = "Defines environment variables.";
9476 };
9577
96− autoExtract = mkOption {
97− type = types.bool;
98− default = true;
78+ lessopen = mkOption {
79+ type = types.nullOr types.str;
80+ default = "|${pkgs.lesspipe}/bin/lesspipe.sh %s";
81+ description = ''
82+ Before less opens a file, it first gives your input preprocessor a chance to modify the way the contents of the file are displayed.
83+ '';
84+ };
85+
86+ lessclose = mkOption {
87+ type = types.nullOr types.str;
88+ default = null;
9989 description = ''
100− When enabled less automatically extracts .gz .xz .bz2 files before reading them.
90+ When less closes a file opened in such a way, it will call another program, called the input postprocessor, which may perform any desired clean-up action (such as deleting the replacement file created by LESSOPEN).
10191 '';
10292 };
10393 };
@@ -107,8 +97,13 @@ in
10797
10898 environment.systemPackages = [ pkgs.less ];
10999
110− environment.variables."LESSKEY_SYSTEM" = toString lessKey;
111− environment.variables."LESSOPEN" = "|${lessPipe}/bin/lesspipe.sh %s";
100+ environment.variables = {
101+ "LESSKEY_SYSTEM" = toString lessKey;
102+ } // optionalAttrs (cfg.lessopen != null) {
103+ "LESSOPEN" = cfg.lessopen;
104+ } // optionalAttrs (cfg.lessclose != null) {
105+ "LESSCLOSE" = cfg.lessclose;
106+ };
112107
113108 warnings = optional (
114109 cfg.clearDefaultCommands && (all (x: x != "quit") (attrValues cfg.commands))