From a2c9f81b3fbcfcf0852040ef952c08537118e3bf Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Tue, 3 Sep 2024 15:06:18 -0700 Subject: [PATCH 1/2] nix-direnv: 3.0.5 -> 3.0.6 (cherry picked from commit a4626d4bc8273ae9e4bf34c9c83e9710f93b9791) --- pkgs/by-name/ni/nix-direnv/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ni/nix-direnv/package.nix b/pkgs/by-name/ni/nix-direnv/package.nix index 42569d8e79737..723ca0d1b4c8d 100644 --- a/pkgs/by-name/ni/nix-direnv/package.nix +++ b/pkgs/by-name/ni/nix-direnv/package.nix @@ -4,13 +4,13 @@ # https://github.com/abathur/resholve/issues/107 resholve.mkDerivation rec { pname = "nix-direnv"; - version = "3.0.5"; + version = "3.0.6"; src = fetchFromGitHub { owner = "nix-community"; repo = "nix-direnv"; rev = version; - hash = "sha256-imUlc5v/Ow7dgjCjTyEeet+4lNHLeEwfqGQcB4dKcao="; + hash = "sha256-oNqhPqgQT92yxbKmcgX4F3e2yTUPyXYG7b2xQm3TvQw="; }; # skip min version checks which are redundant when built with nix From 5b03e0c166a65d6768da4fa1404c4b6eb5eb8199 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Tue, 3 Sep 2024 15:10:48 -0700 Subject: [PATCH 2/2] nix-direnv: Update resholve solutions from upstream Upstream recently changed their resholve solutions somewhat to support using the ambient Nix on the user's `$PATH` or falling back to the default nixpkgs stable `nix` otherwise. Let's update our definitions to match. See: https://github.com/nix-community/nix-direnv/pull/513 (cherry picked from commit ea8ab50f9e8c3f782145124ca48ffa6a225e0504) --- pkgs/by-name/ni/nix-direnv/package.nix | 47 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/pkgs/by-name/ni/nix-direnv/package.nix b/pkgs/by-name/ni/nix-direnv/package.nix index 723ca0d1b4c8d..ff56c097c29a5 100644 --- a/pkgs/by-name/ni/nix-direnv/package.nix +++ b/pkgs/by-name/ni/nix-direnv/package.nix @@ -1,4 +1,11 @@ -{ resholve, lib, coreutils, direnv, nix, fetchFromGitHub }: +{ + resholve, + lib, + coreutils, + nix, + fetchFromGitHub, + writeText, +}: # resholve does not yet support `finalAttrs` call pattern hence `rec` # https://github.com/abathur/resholve/issues/107 @@ -13,11 +20,6 @@ resholve.mkDerivation rec { hash = "sha256-oNqhPqgQT92yxbKmcgX4F3e2yTUPyXYG7b2xQm3TvQw="; }; - # skip min version checks which are redundant when built with nix - postPatch = '' - sed -i 1iNIX_DIRENV_SKIP_VERSION_CHECK=1 direnvrc - ''; - installPhase = '' runHook preInstall install -m400 -D direnvrc $out/share/nix-direnv/direnvrc @@ -28,7 +30,7 @@ resholve.mkDerivation rec { default = { scripts = [ "share/nix-direnv/direnvrc" ]; interpreter = "none"; - inputs = [ coreutils nix ]; + inputs = [ coreutils ]; fake = { builtin = [ "PATH_add" @@ -43,23 +45,36 @@ resholve.mkDerivation rec { # cannot be reached when built with nix "shasum" ]; + external = [ + # We want to reference the ambient Nix when possible, and have custom logic + # for the fallback + "nix" + ]; }; keep = { "$cmd" = true; "$direnv" = true; + + # Nix fallback implementation + "$_nix_direnv_nix" = true; + "$ambient_nix" = true; + "$NIX_DIRENV_FALLBACK_NIX" = true; }; - execer = [ - "cannot:${direnv}/bin/direnv" - "cannot:${nix}/bin/nix" - ]; + prologue = + (writeText "prologue.sh" '' + NIX_DIRENV_FALLBACK_NIX=''${NIX_DIRENV_FALLBACK_NIX:-${lib.getExe nix}} + '').outPath; }; }; meta = { - description = "A fast, persistent use_nix implementation for direnv"; - homepage = "https://github.com/nix-community/nix-direnv"; - license = lib.licenses.mit; - platforms = lib.platforms.unix; - maintainers = with lib.maintainers; [ mic92 bbenne10 ]; + description = "Fast, persistent use_nix implementation for direnv"; + homepage = "https://github.com/nix-community/nix-direnv"; + license = lib.licenses.mit; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ + mic92 + bbenne10 + ]; }; }