Skip to content

libcap_ng: support building python bindings - #546283

Merged
GrimmTheShrimp merged 3 commits into
NixOS:stagingfrom
GrimmTheShrimp:libcap_ng-python
Jul 27, 2026
Merged

GrimmTheShrimp merged 3 commits into
NixOS:stagingfrom
GrimmTheShrimp:libcap_ng-python

Conversation

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

Things done

@GrimmTheShrimp GrimmTheShrimp changed the title Libcap ng python libcap_ng: support building python bindings Jul 27, 2026
@GrimmTheShrimp GrimmTheShrimp changed the title libcap_ng: support building python bindings libcap_ng: support building python bindings Jul 27, 2026
@GrimmTheShrimp

Copy link
Copy Markdown
Contributor Author

I was evaluating libcap_ng (with its py bindings) as a potential replacement to libcap after looking at #502310. We could still do that in the future, because python lends itself better to checks and passing json to it, but that needs more work and investigation.

@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, onny and pyrox0 and removed request for a team July 27, 2026 12:27
@nixpkgs-ci nixpkgs-ci Bot added 8.has: package (new) This PR adds a new package 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: python Python is a high-level, general-purpose programming language. labels Jul 27, 2026
@GrimmTheShrimp
GrimmTheShrimp added this pull request to the merge queue Jul 27, 2026
Merged via the queue into NixOS:staging with commit 10f3cbc Jul 27, 2026
32 checks passed
@GrimmTheShrimp
GrimmTheShrimp deleted the libcap_ng-python branch July 27, 2026 13:04
swig
]
++ lib.optionals withPython [
python3Packages.python # m4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m4 checks for that?

@GrimmTheShrimp GrimmTheShrimp Jul 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, same issue as in libapparmor for different bits, and m4 does do python, yes

Comment on lines +9217 to +9222
}@python3Packages:
toPythonModule (
pkgs.libcap_ng.override {
withPython = true;
inherit python3Packages;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}@python3Packages:
toPythonModule (
pkgs.libcap_ng.override {
withPython = true;
inherit python3Packages;
}
}:
toPythonModule (
pkgs.libcap_ng.override {
withPython = true;
python3Packages = pythonPackages;
}

Normally I would suggest something like this.

@GrimmTheShrimp GrimmTheShrimp Jul 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this causes issues with cross, see e.g. #476808

@trofi

trofi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Does pypy3Packages.libcap_ng.tests eval for you in staging? It fails for me as:

$ nix-instantiate -A pypy3Packages.libcap_ng.tests
error:
       … while evaluating the attribute 'python'
         at pkgs/by-name/li/libcap_ng/package.nix:69:7:
           68|       pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
           69|       python = python3Packages.libcap_ng;
             |       ^
           70|     };

       error: attribute 'libcap_ng' missing
       at pkgs/by-name/li/libcap_ng/package.nix:69:16:
           68|       pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
           69|       python = python3Packages.libcap_ng;
             |                ^
           70|     };

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor Author
image evals just fine here and starts chipping away at a build

@trofi

trofi commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

I wonder why my environment is different. Mine is x86_64-linux, nix 2.34.8 (and 2.35.1). Slightly more hermetic flake reference also fails the same:

$ nix build github:NixOS/nixpkgs/staging#pypy3Packages.libcap_ng.tests.python
error: attribute 'libcap_ng' missing
       at «github:NixOS/nixpkgs/b24cff5be70e80e212ee1c33758c0a57f2f9f5ec»/pkgs/by-name/li/libcap_ng/package.nix:69:16:
           68|       pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
           69|       python = python3Packages.libcap_ng;
             |                ^
           70|     };

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor Author

oh hold on i was holding it wrong... I see what is going on.

The splicing hacks in pkgs/top-level/python-packages.nix don't actually pass in libcap_ng itself, making the passthru fail. Both pypy3Packages.libcap_ng and libcap_ng.tests.python succeed, but not pypy3Packages.libcap_ng.tests.python. The fix is quite simple.

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor Author

proposed fix in #547656

thiagokokada pushed a commit to thiagokokada/nixpkgs that referenced this pull request Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants