Nix-direnv: 1.1rc1 released (flake support)

Check it out at Release Flake support · nix-community/nix-direnv · GitHub
This release adds a use_flake function that will use the devShell output.
It will prevent garbage collection of the build environment and enable offline use.
Since flake inputs are also invalidated every 15 min, nix-direnv caches the output of nix develop.
Happy hacking on your next flight without internet!

4 Likes

The more feedback I get the faster I will release a stable version of this feature.

How does the flakes support compared to what is documented in direnv’s wiki? Nix · direnv/direnv Wiki · GitHub

(Just from codesize it seems simpler or more basic than what is in your use_flakes function in nix-direnv.)

Is it possible to turn nix-direnv into a flake itself? (and obviously using the flake-compat thingy or people who don’t use flake)

The wiki text their stated that using this function will prevent garbage collection, which is not the case. It does not even cache flake inputs longer than the tarball TTL of nix, which means that you have to redownload nixpkgs every once in a while. This is what nix-direnv solves. It is also faster then nix develop at the cost for some inaccuracy (it cannot track if files beyond flake.nix/flack.lock have change). It also normalizes some environment variables that come out of nix-shell like TMPDIR that users might not want set in their shell.

1 Like

This is on the TODO list. Also most people probably just want to use the nixpkgs version or the home-manager integration.

The nixpkgs diff, if anyone else wants to kick the tires:

From 79eeb8510123e830c4f0ae66e782bb65c7a97554 Mon Sep 17 00:00:00 2001
From: Cole Mickens <cole.mickens@gmail.com>
Date: Wed, 12 Aug 2020 08:27:12 +0000
Subject: [PATCH] nix-direnv: 1.0.0 -> 1.1rc2

---
 pkgs/tools/misc/nix-direnv/default.nix | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix
index cff7df1801f..92aa908f92e 100644
--- a/pkgs/tools/misc/nix-direnv/default.nix
+++ b/pkgs/tools/misc/nix-direnv/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "nix-direnv";
-  version = "1.0.0";
+  version = "1.1rc2";
 
   src = fetchFromGitHub {
     owner = "nix-community";
     repo = "nix-direnv";
     rev = "${version}";
-    sha256 = "1lwmg6mn3lf7s0345v53zadxn9v0x8z6pcbj90v5dx3pgrq41gs8";
+    sha256 = "sha256-MoBVI3HHt5BKzWKpzNh3cYMr5DisMswrVkWEkFpKQgU=";
   };
 
   # Substitute instead of wrapping because the resulting file is
-- 
2.28.0

I had to go ahead and switch my system to flakes (I had something hacky to avoid it before…), but it works well. Thanks!

edit: updated to 1.1rc2

This one is a crucial bug fix: fix restoring SSL_CERT_FILE files by Mic92 · Pull Request #33 · nix-community/nix-direnv · GitHub
I made a new release candidate for it: Release Fix ssl · nix-community/nix-direnv · GitHub

nix-direnv 1.1 released now: nix-direnv: 1.0.0 -> 1.1 by Mic92 · Pull Request #95586 · NixOS/nixpkgs · GitHub

2 Likes