diff --git a/default.nix b/default.nix index 5fb646f..cbdeec0 100644 --- a/default.nix +++ b/default.nix @@ -114,7 +114,7 @@ lib.makeScope pkgs.newScope (self: { __toPluginAble = toPluginAble self; - inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook; + inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook wheelUnpackHook; } ) # Null out any filtered packages, we don't want python.pkgs from nixpkgs diff --git a/hooks/default.nix b/hooks/default.nix index 001a3d0..e248a5e 100644 --- a/hooks/default.nix +++ b/hooks/default.nix @@ -49,4 +49,16 @@ in } ./fixup-hook.sh ) { }; + # When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion + # It doesn't _really_ depend on wheel though, it just copies the wheel. + wheelUnpackHook = callPackage + ({}: + makeSetupHook + { + name = "wheel-unpack-hook.sh"; + deps = [ ]; + } ./wheel-unpack-hook.sh + ) { }; + + } diff --git a/hooks/wheel-unpack-hook.sh b/hooks/wheel-unpack-hook.sh new file mode 100644 index 0000000..fca808a --- /dev/null +++ b/hooks/wheel-unpack-hook.sh @@ -0,0 +1,18 @@ +# Setup hook to use in case a wheel is fetched +echo "Sourcing wheel setup hook" + +wheelUnpackPhase(){ + echo "Executing wheelUnpackPhase" + runHook preUnpack + + mkdir -p dist + cp "$src" "dist/$(stripHash "$src")" + +# runHook postUnpack # Calls find...? + echo "Finished executing wheelUnpackPhase" +} + +if [ -z "${dontUseWheelUnpack-}" ] && [ -z "${unpackPhase-}" ]; then + echo "Using wheelUnpackPhase" + unpackPhase=wheelUnpackPhase +fi diff --git a/overrides.nix b/overrides.nix index 96cf4e8..087671b 100644 --- a/overrides.nix +++ b/overrides.nix @@ -944,17 +944,34 @@ self: super: } ); + # Stop infinite recursion by using bootstrapped pkg from nixpkgs - wheel = ( - pkgs.python3.pkgs.override { + bootstrapped-pip = super.bootstrapped-pip.override { + wheel = (pkgs.python3.pkgs.override { python = self.python; - } - ).wheel.overridePythonAttrs ( - old: - if old.format == "other" then old else { - inherit (super.wheel) pname name version src; - } - ); + }).wheel; + }; + wheel = + let + isWheel = super.wheel.src.isWheel or false; + # If "wheel" is a pre-built binary wheel + wheelPackage = super.buildPythonPackage { + inherit (super.wheel) pname name version src; + inherit (pkgs.python3.pkgs.wheel) meta; + format = "wheel"; + }; + # If "wheel" is built from source + sourcePackage = ( + pkgs.python3.pkgs.override { + python = self.python; + } + ).wheel.overridePythonAttrs ( + old: { + inherit (super.wheel) pname name version src; + } + ); + in + if isWheel then wheelPackage else sourcePackage; zipp = (