From 19398e505a80db1a1c41207ee89e1b1770c5dcf6 Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra Date: Fri, 27 Dec 2024 18:39:49 +0100 Subject: [PATCH] lesspipe: allow configuring package --- modules/programs/lesspipe.nix | 12 +++++++++--- tests/default.nix | 1 + tests/modules/programs/lesspipe/default.nix | 1 + tests/modules/programs/lesspipe/lesspipe.nix | 10 ++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 tests/modules/programs/lesspipe/default.nix create mode 100644 tests/modules/programs/lesspipe/lesspipe.nix diff --git a/modules/programs/lesspipe.nix b/modules/programs/lesspipe.nix index a7a51ffe..a9bca279 100644 --- a/modules/programs/lesspipe.nix +++ b/modules/programs/lesspipe.nix @@ -2,18 +2,24 @@ with lib; -{ +let + + cfg = config.programs.lesspipe; + +in { meta.maintainers = [ maintainers.rycee ]; options = { programs.lesspipe = { enable = mkEnableOption "lesspipe preprocessor for less"; + + package = mkPackageOption pkgs "lesspipe" { }; }; }; - config = mkIf config.programs.lesspipe.enable { + config = mkIf cfg.enable { home.sessionVariables = { - LESSOPEN = "|${pkgs.lesspipe}/bin/lesspipe.sh %s"; + LESSOPEN = "|${cfg.package}/bin/lesspipe.sh %s"; }; }; } diff --git a/tests/default.nix b/tests/default.nix index f7a1b283..177610e5 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -101,6 +101,7 @@ in import nmtSrc { ./modules/programs/kubecolor ./modules/programs/ledger ./modules/programs/less + ./modules/programs/lesspipe ./modules/programs/lf ./modules/programs/lsd ./modules/programs/lieer diff --git a/tests/modules/programs/lesspipe/default.nix b/tests/modules/programs/lesspipe/default.nix new file mode 100644 index 00000000..e7b9c383 --- /dev/null +++ b/tests/modules/programs/lesspipe/default.nix @@ -0,0 +1 @@ +{ lesspipe = ./lesspipe.nix; } diff --git a/tests/modules/programs/lesspipe/lesspipe.nix b/tests/modules/programs/lesspipe/lesspipe.nix new file mode 100644 index 00000000..70dcc954 --- /dev/null +++ b/tests/modules/programs/lesspipe/lesspipe.nix @@ -0,0 +1,10 @@ +{ + programs.lesspipe.enable = true; + + test.stubs.lesspipe = { }; + + nmt.script = '' + assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ + 'export LESSOPEN="|@lesspipe@/bin/lesspipe.sh %s"' + ''; +}