treewide: Pass self when overriding Python

Otherwise references to the Python interpreter inside the set are wrong, as demonstrated by:
``` nix
with import <nixpkgs> { };
let
  python' = python3.override {
    packageOverrides = final: prev: { requests = prev.requests.overridePythonAttrs(old: { version = "1337";  }); };
  };
in python'.pkgs.python.pkgs.requests
```
which returns the _non_ overriden requests.

And the same with `self`:
```
with import <nixpkgs> { };
let
  python' = python3.override {
    self = python';
    packageOverrides = final: prev: { requests = prev.requests.overridePythonAttrs(old: { version = "1337";  }); };
  };
in python'.pkgs.python.pkgs.requests
```
which returns the overriden requests.

This can manifest itself as file collisions when constructing environments or as subtly incorrect dependency graphs.
This commit is contained in:
adisbladis 2024-08-02 23:10:35 +12:00
parent adb3cee87d
commit e0816431a2
67 changed files with 73 additions and 15 deletions

View File

@ -49,6 +49,7 @@
let
py = python311.override {
self = py;
packageOverrides = self: super: {
pyqt5 = super.pyqt5.override {
withLocation = true;

View File

@ -49,6 +49,7 @@
let
py = python311.override {
self = py;
packageOverrides = self: super: {
pyqt5 = super.pyqt5.override {
withLocation = true;

View File

@ -7,6 +7,7 @@
let
python = python3.override {
self = python;
packageOverrides = _: super: {
pillow = super.pillow.overridePythonAttrs rec {
version = "9.5.0";

View File

@ -15,6 +15,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
django = super.django_3.overridePythonAttrs (old: rec {
version = "3.1.14";

View File

@ -5,6 +5,7 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
wtforms = super.wtforms.overridePythonAttrs (oldAttrs: rec {
version = "2.3.1";

View File

@ -5,7 +5,7 @@
python3,
}:
let
python = python3.override { packageOverrides = self: super: { pydantic = super.pydantic_1; }; };
python = python3.override { self = python; packageOverrides = self: super: { pydantic = super.pydantic_1; }; };
in
python.pkgs.buildPythonApplication rec {
pname = "dbx";

View File

@ -3,9 +3,8 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
self = py;
# not compatible with prompt_toolkit >=2.0
prompt-toolkit = super.prompt-toolkit.overridePythonAttrs (oldAttrs: rec {
name = "${oldAttrs.pname}-${version}";

View File

@ -18,6 +18,7 @@
let
python = python310.override {
self = python;
packageOverrides = (self: super: {
matplotlib = super.matplotlib.override {
enableGtk3 = true;

View File

@ -6,6 +6,7 @@
let
# python-ldap-3.4.4 does not work with python3(12)
python = python311.override {
self = python;
packageOverrides = self: super: {
validators = super.validators.overridePythonAttrs (_: rec {
version = "0.20.0";

View File

@ -12,6 +12,7 @@ let
nixopsContextBase = this: {
python = python3.override {
self = this.python;
packageOverrides = self: super: {
nixops = self.callPackage ./unwrapped.nix { };
} // (this.plugins self super);

View File

@ -7,6 +7,7 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
# Support for later tweepy releases is missing

View File

@ -7,6 +7,7 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
# Requires "urwid~=2.1.2", otherwise some tests are failing

View File

@ -7,6 +7,7 @@
}:
let
python = python3.override {
self = python;
packageOverrides = self: super: {
django = super.django_3;
};

View File

@ -37,6 +37,7 @@ let
# https://github.com/NixOS/nixpkgs/issues/298719
# https://github.com/paperless-ngx/paperless-ngx/issues/5494
python = python3.override {
self = python;
packageOverrides = final: prev: {
# tesseract5 may be overwritten in the paperless module and we need to propagate that to make the closure reduction effective
ocrmypdf = prev.ocrmypdf.override { tesseract = tesseract5; };

View File

@ -13,6 +13,7 @@
# https://github.com/NixOS/nixpkgs/pull/54425#discussion_r250688781
let
python = python3.override {
self = python;
packageOverrides = self: super: {
srht = self.callPackage ./core.nix { };

View File

@ -6,6 +6,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
pychromecast = super.pychromecast.overridePythonAttrs (_: rec {
version = "13.1.0";

View File

@ -24,6 +24,7 @@ let
};
python = python311.override {
self = python;
packageOverrides = self: super: {
pydantic = super.pydantic_1;

View File

@ -8,6 +8,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
# pyCA is incompatible with SQLAlchemy 2.0
sqlalchemy = super.sqlalchemy_1_4;
@ -80,4 +81,3 @@ python3.pkgs.buildPythonApplication rec {
maintainers = with maintainers; [ pmiddend ];
};
}

View File

@ -23,6 +23,7 @@ let
});
py = python3.override {
self = py;
packageOverrides = self: super: {
inherit buildAzureCliPackage;

View File

@ -7,6 +7,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
sqlalchemy = super.sqlalchemy_1_4;
};

View File

@ -8,6 +8,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
pydantic-yaml = super.pydantic-yaml.overridePythonAttrs (old: rec {
version = "0.11.2";

View File

@ -5,6 +5,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
lark = super.lark.overridePythonAttrs (old: rec {
# gdtoolkit needs exactly this lark version

View File

@ -5,6 +5,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
lark = super.lark.overridePythonAttrs (old: rec {
# gdtoolkit needs exactly this lark version

View File

@ -11,6 +11,7 @@
let
py = python3.override {
self = py;
packageOverrides = final: prev: {
# sqlalchemy 1.4.x or 2.x are not supported
sqlalchemy = prev.sqlalchemy.overridePythonAttrs (oldAttrs: rec {
@ -174,4 +175,3 @@ py.pkgs.buildPythonPackage rec {
maintainers = teams.wdz.members;
};
}

View File

@ -9,6 +9,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
music-assistant-frontend = self.callPackage ./frontend.nix { };
};

View File

@ -26,6 +26,7 @@ let
inherit (self.passthru) generator-out;
};
python3 = buildPackages.python3.override {
self = python3;
packageOverrides = _: _: {
nanopb-proto = self.passthru.python-module;
};
@ -119,4 +120,3 @@ in
'';
};
})

View File

@ -11,6 +11,7 @@
let
python = python310.override {
self = python;
packageOverrides = final: prev: {
# requirements.txt fixes docutils at 0.17; the default 0.21.1 tested throws exceptions
docutils-0_17 = prev.docutils.overridePythonAttrs (old: rec {

View File

@ -3,6 +3,7 @@
let
python = python310.override {
self = python;
packageOverrides = self: super: {
pypdf2 = super.pypdf2.overridePythonAttrs (old: rec {
version = "1.28.6";

View File

@ -8,6 +8,7 @@
let
python = python310.override {
self = python;
packageOverrides = self: super: {
flask = super.flask.overridePythonAttrs (old: rec {
version = "2.3.3";

View File

@ -7,6 +7,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: { sqlalchemy = super.sqlalchemy_1_4; };
};
in

View File

@ -4,6 +4,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
# https://github.com/domainaware/parsedmarc/issues/464
msgraph-core = super.msgraph-core.overridePythonAttrs (old: rec {

View File

@ -10,6 +10,7 @@
let
python = python3.override {
self = python;
packageOverrides = final: prev: {
django-bootstrap4 = prev.django-bootstrap4.overridePythonAttrs (oldAttrs: rec {
version = "3.0.0";

View File

@ -11,6 +11,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
django = super.django_4;

View File

@ -8,6 +8,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
craft-application = super.craft-application.overridePythonAttrs (old: rec {
version = "1.2.1";

View File

@ -12,6 +12,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
pydantic-yaml = super.pydantic-yaml.overridePythonAttrs (old: rec {
version = "0.11.2";

View File

@ -5,7 +5,7 @@
fetchPypi
}:
let
python3Packages =
python3' =
(python3.override {
packageOverrides = final: prev: {
wxpython = prev.wxpython.overrideAttrs rec {
@ -17,7 +17,10 @@ let
};
};
};
}).pkgs;
});
python3Packages = python3'.pkgs;
in
python3Packages.buildPythonApplication rec {
pname = "yt-dlg";

View File

@ -6,6 +6,7 @@
# Take packages from self first, then python.pkgs (and secondarily pkgs)
lib.makeScope (self: newScope (self.python.pkgs // self)) (self: {
python = python3.override {
self = self.python;
packageOverrides = self: super: {
sqlalchemy = super.sqlalchemy_1_4;
moto = super.moto.overridePythonAttrs (oldAttrs: {

View File

@ -3,6 +3,7 @@
}:
let python = python3.override {
self = python;
packageOverrides = self: super: {
# see https://github.com/devicetree-org/dt-schema/issues/108
jsonschema = super.jsonschema.overridePythonAttrs (old: rec {
@ -27,4 +28,3 @@ let python = python3.override {
});
};
}; in python.pkgs.toPythonApplication python.pkgs.dtschema

View File

@ -5,6 +5,7 @@
let
python = python3.override {
self = python;
packageOverrides = pySelf: pySuper: {
connexion = pySuper.connexion.overridePythonAttrs (o: rec {
version = "2.14.2";

View File

@ -8,6 +8,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
antlr4-python3-runtime = super.antlr4-python3-runtime.override {
antlr4 = antlr4_9;

View File

@ -9,6 +9,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
pydantic = super.pydantic_1;
};

View File

@ -7,6 +7,7 @@
}:
let
python = python3.override {
self = python;
packageOverrides = self: super: {
sqlalchemy = super.sqlalchemy_1_4;

View File

@ -451,6 +451,7 @@ let
];
python = python312.override {
self = python;
packageOverrides = lib.composeManyExtensions (defaultOverrides ++ [ packageOverrides ]);
};

View File

@ -1,6 +1,7 @@
{ python3, fetchPypi, lib, overlay ? (_: _: {}) }:
python3.override {
lib.fix (self: python3.override {
inherit self;
packageOverrides = lib.composeExtensions
(self: super: {
/*
@ -35,4 +36,4 @@ python3.override {
})
overlay;
}
})

View File

@ -7,6 +7,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
tulir-telethon = self.telethon.overridePythonAttrs (oldAttrs: rec {
version = "1.37.0a1";

View File

@ -55,6 +55,7 @@ with lib;
let
# samba-tool requires libxcrypt-legacy algorithms
python = python3Packages.python.override {
self = python;
libxcrypt = libxcrypt-legacy;
};
wrapPython = python3Packages.wrapPython.override {

View File

@ -6,6 +6,7 @@
}:
let
py = python3.override {
self = py;
packageOverrides = final: prev: {
django = prev.django_5;
};

View File

@ -10,6 +10,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
fido2 = super.fido2.overridePythonAttrs (oldAttrs: rec {
version = "0.9.3";

View File

@ -8,6 +8,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
pyparsing = super.pyparsing.overridePythonAttrs rec {
version = "2.4.7";

View File

@ -7,6 +7,7 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
click = super.click.overridePythonAttrs (oldAttrs: rec {

View File

@ -3,10 +3,7 @@
}:
let
python = python3.override {
packageOverrides = self: super: {
};
};
python = python3;
in
python.pkgs.buildPythonPackage {

View File

@ -7,6 +7,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
torch = super.torch-bin;
torchvision = super.torchvision-bin;

View File

@ -169,6 +169,7 @@ let
# Watch out for python <> boost compatibility
python = python311.override {
self = python;
packageOverrides = self: super: let
cryptographyOverrideVersion = "40.0.1";
bcryptOverrideVersion = "4.0.1";

View File

@ -78,6 +78,7 @@
let
python = python3.override {
self = python;
packageOverrides = final: prev: {
# version 4 or newer would log the followng error but tests currently don't fail because radare2 is disabled
# ValueError: argument TNULL is not a TLSH hex string

View File

@ -12,6 +12,7 @@
let
python = python3Packages.python.override {
self = python;
packageOverrides = self: super: {
esphome-dashboard = self.callPackage ./dashboard.nix { };
};

View File

@ -9,6 +9,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
mistune = super.mistune.overridePythonAttrs (old: rec {
version = "2.0.5";

View File

@ -13,6 +13,7 @@
let
python = python39.override {
self = python;
packageOverrides = self: super: {
ntfy-webpush = self.callPackage ./webpush.nix { };

View File

@ -5,6 +5,7 @@
let
python' = python3.override {
self = python';
packageOverrides = final: prev: rec {
# tvdb_api v3.1.0 has a hard requirement on requests-cache < 0.6
requests-cache = prev.requests-cache.overridePythonAttrs (oldAttrs: rec {

View File

@ -9,6 +9,7 @@
let
python = python3.override {
self = python;
packageOverrides = final: prev: {
# aiosqlite>=0.16,<0.19
aiosqlite = prev.aiosqlite.overridePythonAttrs (old: rec {

View File

@ -10,6 +10,7 @@ let
# uses eliot in a way incompatible after version 1.14.0.
# These versions should be unpinned, when updating Tahoe-LAFS to a more recent version.
python = python311.override {
self = python;
packageOverrides = self: super: {
eliot = super.eliot.overridePythonAttrs (oldAttrs: rec {
version = "1.14.0";

View File

@ -5,6 +5,7 @@
let
python = python3.override {
self = python;
packageOverrides = final: prev: {
markdown-it-py = prev.markdown-it-py.overridePythonAttrs (_: {
doCheck = false;

View File

@ -22,6 +22,7 @@ let
});
} // (plugins self);
python = python3.override (old: {
self = python;
packageOverrides = lib.composeManyExtensions
((if old ? packageOverrides then [ old.packageOverrides ] else [ ]) ++ [ newPackageOverrides ]);
});

View File

@ -4,6 +4,7 @@
}:
let
py = python3.override {
self = py;
packageOverrides = self: super: {
cmd2 = super.cmd2.overridePythonAttrs (oldAttrs: rec {

View File

@ -5,6 +5,7 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
emoji = super.emoji.overridePythonAttrs rec {
version = "1.7.0";

View File

@ -5,6 +5,7 @@
}:
let
python = python3.override {
self = python;
packageOverrides = self: super: {
impacket = super.impacket.overridePythonAttrs {
version = "0.12.0.dev1-unstable-2023-11-30";

View File

@ -9,6 +9,7 @@
let
py = python3.override {
self = py;
packageOverrides = self: super: {
paramiko = super.paramiko.overridePythonAttrs (oldAttrs: rec {
version = "3.3.1";

View File

@ -5,6 +5,7 @@
let
python = python3.override {
self = python;
packageOverrides = self: super: {
# https://github.com/refi64/mrkd/pull/6
mistune = super.mistune.overridePythonAttrs (old: rec {