Enable automatic per-project nix development shells with direnv
Alan Pearce alan@alanpearce.eu
Tue, 11 Apr 2023 15:12:03 +0200
2 files changed, 19 insertions(+), 1 deletions(-)
M system/settings/darwin.nix → system/settings/darwin.nix
@@ -18,6 +18,8 @@ }; settings.extra-platforms = "aarch64-darwin x86_64-darwin"; settings.experimental-features = "nix-command flakes"; settings.warn-dirty = false; + settings.keep-outputs = true; + settings.keep-derivations = true; }; nixpkgs.config = {
M user/settings/development/base.nix → user/settings/development/base.nix
@@ -2,7 +2,13 @@ { config , lib , pkgs , ... -}: { +}: +let + direnvHook = pkgs.runCommandLocal "direnv_hook" { } '' + ${pkgs.direnv}/bin/direnv hook zsh > $out + ''; +in +{ home.packages = with pkgs; [ shellcheck @@ -31,4 +37,14 @@ (self: super: { ripgrep = super.ripgrep.override { withPCRE2 = true; }; }) ]; + + programs.direnv = { + enable = true; + nix-direnv = { + enable = true; + }; + }; + programs.zsh.initExtra = '' + source ${direnvHook} + ''; }