nix-community / pip2nix

Freeze pip-installable packages into Nix expressions [maintainer=@datakurre]
168 stars 26 forks source link

Scaffold is broken with recent nixpkgs #65

Open datakurre opened 3 years ago

datakurre commented 3 years ago

See the possibly fixed example at:

https://github.com/rihardsk/mautrix-hangouts-nix/commit/f5ed572b4b56b2daff002a860b5f4e00e175ed32

From f5ed572b4b56b2daff002a860b5f4e00e175ed32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rihards=20Kri=C5=A1lauks?= <rihards.krislauks@gmail.com>
Date: Fri, 7 May 2021 20:51:40 +0300
Subject: [PATCH] Change how python packages are overriden to work around
 breaking changes in nixpkgs

The workaround seems to be working with nixpkgs at ce93c98ce22. mautrix-hangouts
still doesn't build because of some broken python packages, though.
---
 default.nix | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/default.nix b/default.nix
index 4ce33c2..dc7f86e 100644
--- a/default.nix
+++ b/default.nix
@@ -1,19 +1,25 @@
 # Scaffold generated by pip2nix 0.8.0.dev1
+# + some modifications have been added so support the changes that the Python
+# infrastructure in nixpkgs-unstable has gone through

 { pkgs ? (import <nixpkgs> {})
 , pythonPackages ? "python38Packages"
 }:

 let
-  inherit (pkgs.lib) fix extends;
+  inherit (pkgs.lib) fix composeExtensions;
   basePythonPackages = with builtins; if isAttrs pythonPackages
     then pythonPackages
     else getAttr pythonPackages pkgs;

+  # NOTE: As of some recent nixpgs-unstable version, this is broken.
+  # There's a workaround at the bottem that's using
+  # basePythonPackages.pkgs.override instead
+  #
   # Works with the new python-packages, still can fallback to the old
   # variant.
-  basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
-    self: basePythonPackages.override (a: { inherit self; }));
+  # basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
+  #   self: basePythonPackages.override (a: { inherit self; }));

   elem = builtins.elem;
   basename = path: with pkgs.lib; last (splitString "/" path);
@@ -41,11 +47,10 @@ let
   pythonPackagesLocalOverrides = self: super: {
   };

-  myPythonPackages =
-    (fix
-    (extends pythonPackagesLocalOverrides
-    (extends pythonPackagesOverrides
-    (extends pythonPackagesGenerated
-             basePythonPackagesUnfix))));
+  composedOverrides =
+    (composeExtensions pythonPackagesLocalOverrides
+                      (composeExtensions pythonPackagesOverrides
+                                         pythonPackagesGenerated));
+  myPythonPackages = basePythonPackages.python.override { packageOverrides = composedOverrides; };

-in myPythonPackages.mautrix-hangouts
+in myPythonPackages.pkgs.mautrix-hangouts
andersk commented 2 years ago

This uses composeExtensions in the wrong order—extends takes the last override first, while composeExtensions takes the last override last.

datakurre commented 2 years ago

@andersk Would you be able to provide a pull with a scaffold with the correct order?