2025-04-02 published | 2025-04-17 edited
When deploying Python service to staging using Nix, I want to disable checks for that Python package. (Checks already happened in CI anyway.)
Obvious question is how; obvious answer is overrides. Then, let me reformulate that obvious question a bit: which one?
Giving up on the documentation, the nixpkgs source is a bit helpful:
Derivations built with
buildPythonPackagecan already be overridden withoverride,overrideAttrs, andoverrideDerivation.
This function introduces
overridePythonAttrsand it overrides the call tobuildPythonPackage.
This is the relevant overlay:
overlays = {
do-not-check-pypkg = final: prev: let
pypkg-wo-check = f: p: {
pypkg = p.pypkg.overridePythonAttrs { doCheck = false; };
};
in
{
pythonPackagesExtensions =
prev.pythonPackagesExtensions
++ [ats-wo-check];
};
};and then
nixpkgs.overlays = [self.overlays.do-not-check-pypkg];.
do-not-check-pypkg is an overlay for Nixpkgs, which
extends the pythonPackagesExtensions attribute – a list of
overlays (for Python packages) that are applied to the Python packages
at once.
pythonPackagesExtensions is extended by
pypkg-wo-check overlay.
pypkg-wo-check is an overlay for Python packages,
which disables check for the pypkg Python package.