From 93435d27d250fa986bfec6b2ff263161ff8288cb Mon Sep 17 00:00:00 2001 From: William Phetsinorath Date: Fri, 25 Oct 2024 17:06:02 +0200 Subject: [PATCH] direnv: add support for mise integration --- modules/programs/direnv.nix | 16 +++++++++++++++- tests/modules/programs/direnv/default.nix | 1 + tests/modules/programs/direnv/mise.nix | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/direnv/mise.nix diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index 6d0af3ac1..37899c4a2 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -19,7 +19,7 @@ in { "Flake support is now always enabled.") ]; - meta.maintainers = [ lib.maintainers.rycee ]; + meta.maintainers = [ lib.maintainers.rycee lib.maintainers.shikanime ]; options.programs.direnv = { enable = mkEnableOption "direnv, the environment switcher"; @@ -95,6 +95,14 @@ in { package = mkPackageOption pkgs "nix-direnv" { }; }; + mise = { + enable = mkEnableOption '' + [mise](https://mise.jdx.dev/direnv.html), + integration of use_mise for direnv''; + + package = mkPackageOption pkgs "mise" { }; + }; + silent = mkEnableOption "silent mode, that is, disabling direnv logging"; }; @@ -112,6 +120,12 @@ in { xdg.configFile."direnv/direnvrc" = lib.mkIf (cfg.stdlib != "") { text = cfg.stdlib; }; + xdg.configFile."direnv/lib/hm-mise.sh" = mkIf cfg.mise.enable { + text = '' + eval "$(${getExe cfg.mise.package} direnv activate)" + ''; + }; + programs.bash.initExtra = mkIf cfg.enableBashIntegration ( # Using mkAfter to make it more likely to appear after other # manipulations of the prompt. diff --git a/tests/modules/programs/direnv/default.nix b/tests/modules/programs/direnv/default.nix index a0e618481..b61fb1e33 100644 --- a/tests/modules/programs/direnv/default.nix +++ b/tests/modules/programs/direnv/default.nix @@ -1,5 +1,6 @@ { direnv-bash = ./bash.nix; + direnv-mise = ./mise.nix; direnv-nix-direnv = ./nix-direnv.nix; direnv-nushell = ./nushell.nix; direnv-stdlib = ./stdlib.nix; diff --git a/tests/modules/programs/direnv/mise.nix b/tests/modules/programs/direnv/mise.nix new file mode 100644 index 000000000..b205df627 --- /dev/null +++ b/tests/modules/programs/direnv/mise.nix @@ -0,0 +1,17 @@ +{ config, ... }: + +{ + programs.bash.enable = true; + programs.direnv = { + enable = true; + mise = { + enable = true; + package = config.lib.test.mkStubPackage { name = "mise"; }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileExists home-files/.config/direnv/lib/hm-mise.sh + ''; +}