Skip to content

Commit

Permalink
direnv: add support for mise integration
Browse files Browse the repository at this point in the history
  • Loading branch information
shikanime authored and rycee committed Oct 25, 2024
1 parent 0c0268a commit 93435d2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modules/programs/direnv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
};

Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions tests/modules/programs/direnv/default.nix
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
17 changes: 17 additions & 0 deletions tests/modules/programs/direnv/mise.nix
Original file line number Diff line number Diff line change
@@ -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
'';
}

0 comments on commit 93435d2

Please sign in to comment.