nix-direnv: make flakes support optional
`nix-direnv` depends on `nixUnstable` for flakes support, but that causes it to print a warning unless your user is trusted or the `experimental-features` setting is enabled. Neither of these are desirable (note that setting `experimental-features` in nix.conf causes warnings on `nixStable`). Since flakes are experimental, this commit makes `nixStable` the default and optionally allows `nixUnstable` with a new flag `enableFlakes`, prioritising a good experience for users not using experimental features. (cherry picked from commit 03310df843a344215b45b2e8aef11ae9402a40e2)
This commit is contained in:
parent
0507e901b3
commit
60f31b6692
|
@ -1,5 +1,15 @@
|
||||||
{ lib, stdenv, fetchFromGitHub, gnugrep, nixUnstable }:
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, gnugrep
|
||||||
|
, nixStable
|
||||||
|
, nixUnstable
|
||||||
|
, enableFlakes ? false
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
nix = if enableFlakes then nixUnstable else nixStable;
|
||||||
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "nix-direnv";
|
pname = "nix-direnv";
|
||||||
version = "1.2.6";
|
version = "1.2.6";
|
||||||
|
@ -14,7 +24,7 @@ stdenv.mkDerivation rec {
|
||||||
# Substitute instead of wrapping because the resulting file is
|
# Substitute instead of wrapping because the resulting file is
|
||||||
# getting sourced, not executed:
|
# getting sourced, not executed:
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
sed -i "1a NIX_BIN_PREFIX=${nixUnstable}/bin/" direnvrc
|
sed -i "1a NIX_BIN_PREFIX=${nix}/bin/" direnvrc
|
||||||
substituteInPlace direnvrc --replace "grep" "${gnugrep}/bin/grep"
|
substituteInPlace direnvrc --replace "grep" "${gnugrep}/bin/grep"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue