summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/programs/environment.nix6
-rw-r--r--nixos/modules/programs/less.nix12
2 files changed, 12 insertions, 6 deletions
diff --git a/nixos/modules/programs/environment.nix b/nixos/modules/programs/environment.nix
index 39010323f61..d552c751afd 100644
--- a/nixos/modules/programs/environment.nix
+++ b/nixos/modules/programs/environment.nix
@@ -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"
diff --git a/nixos/modules/programs/less.nix b/nixos/modules/programs/less.nix
index c0188788ec7..794146b19fa 100644
--- a/nixos/modules/programs/less.nix
+++ b/nixos/modules/programs/less.nix
@@ -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) {