home/direnv: improve use, add unuse

This commit is contained in:
Max Headroom 2023-08-25 00:13:12 +02:00
parent 7e1b33d2bc
commit 57cb03b2c7

View file

@ -2,9 +2,16 @@
let
use = pkgs.writeShellScriptBin "use" ''
echo "use ''${@:-flake}" >> .envrc
echo "use ''${@:-flake}" > .envrc
if test -e .git && ! ${pkgs.gnugrep}/bin/grep -qm1 '\.envrc' .git/info/exclude; then
echo ".envrc" >> .git/info/exclude
echo ".direnv/" >> .git/info/exclude
fi
${pkgs.direnv}/bin/direnv allow
'';
unuse = pkgs.writeShellScriptBin "unuse" ''
${pkgs.coreutils}/bin/rm .envrc
'';
in
{
@ -18,5 +25,5 @@ in
home.sessionVariables.DIRENV_LOG_FORMAT = "";
home.packages = [ use ];
home.packages = [ use unuse ];
}