1
1
forked from extern/flakelight

Make mocked pkgs not depend on overlay prev stdenvs

Accessing some of the stdenvs would cause an infinite recursion. We can
continue to rely on base stdenv and also bail if any field other than
mkDerivation is used. All the stdenvs supported have a subset of the
attrs of base stdenv, so this is safe.
This commit is contained in:
Archit Gupta 2024-01-21 22:22:31 -08:00
parent 787ce03070
commit a6f3658ae9

View File

@ -17,7 +17,7 @@ let
assert fargs != { }; assert fargs != { };
f (mock // builtins.intersectAttrs fargs autoArgs // args); f (mock // builtins.intersectAttrs fargs autoArgs // args);
mockStdenv = real: stdenv: real.${stdenv} or (throw "") // { mockStdenv = builtins.mapAttrs (_: _: throw "") real.stdenv // {
mkDerivation = args: mkDerivation = args:
if lib.isFunction args then lib.fix args else args; if lib.isFunction args then lib.fix args else args;
}; };
@ -27,18 +27,18 @@ lib.fix (self: {
callPackage = callPackageWith self; callPackage = callPackageWith self;
stdenv = mockStdenv real "stdenv"; stdenv = mockStdenv;
stdenvNoCC = mockStdenv real "stdenvNoCC"; stdenvNoCC = mockStdenv;
stdenv_32bit = mockStdenv real "stdenv_32bit"; stdenv_32bit = mockStdenv;
stdenvNoLibs = mockStdenv real "stdenvNoLibs"; stdenvNoLibs = mockStdenv;
libcxxStdenv = mockStdenv real "libcxxStdenv"; libcxxStdenv = mockStdenv;
gccStdenv = mockStdenv real "gccStdenv"; gccStdenv = mockStdenv;
gccStdenvNoLibs = mockStdenv real "gccStdenvNoLibs"; gccStdenvNoLibs = mockStdenv;
gccMultiStdenv = mockStdenv real "gccMultiStdenv"; gccMultiStdenv = mockStdenv;
clangStdenv = mockStdenv real "clangStdenv"; clangStdenv = mockStdenv;
clangStdenvNoLibs = mockStdenv real "clangStdenvNoLibs"; clangStdenvNoLibs = mockStdenv;
clangMultiStdenv = mockStdenv real "clangMultiStdenv"; clangMultiStdenv = mockStdenv;
ccacheStdenv = mockStdenv real "ccacheStdenv"; ccacheStdenv = mockStdenv;
runCommandWith = args: _: args; runCommandWith = args: _: args;
runCommand = name: _: _: { inherit name; }; runCommand = name: _: _: { inherit name; };