Adding support for `cargo-c`-specific hooks
Nobody has claimed this yet.
- Dominant language
- Nix
- Stars
- 26.2k
- Forks
- 20.1k
- PR merge metrics
- PR metrics pending
Description
CC @cpu @matthiasbeyer
While creating my kconfq project I realised that nixpkgs does not have any hooks for the cargo-c cargo applet.
The applet allows one to generate a header, pkg-config file and a cdynlib with nothing but cargo (no need for extra build systems like Meson). The sequence of cargo-c commands is always the same:
cargo cbuild
cargo ctest
cargo cinstall
Currently, nixpkgs has 6 derivations that use cargo-c:
- hdr10plus (
buildPhase) - libdovi (
buildPhase) libimagequant(does not have capi in the root-level crate, can't be built with the standard hook)- rav1e (
postBuild) - rustls-ffi (
buildPhase) - yara-x (
postBuild)
buildPhase vs postBuild
3 of the existing derivations call cargo-c commands inside the buildPhase, while other 2 do it inside the postBuild phase.
From what I observed with libdovi, replacing
buildPhase = ''
runHook preBuild
# `cargo cbuild` invocation
runHook postBuild
'';
installPhase = ''
runHook preInstall
# `cargo cisntall` invocation
runHook postInstall
'';
with
postBuild = ''
# `cargo cbuild` invocation
'';
postInstall = ''
# `cargo cisntall` invocation
'';
does not change the output of the derivation.
Proposal
Adding cargo-c as a nativeBuildInputs dependency should automatically enable cargocBuildHook, cargocCheckHook and cargocInstallHook hooks that will be added to the buildPhase, checkPhase and installPhase phases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the cargo-c invocations in the package.nix files for hdr10plus, libdovi, rav1e, rustls-ffi, and yara-x, especially their build, check, and install phases. Then trace existing cargo hook conventions in nixpkgs; done should be automatic cargoc build, check, and install hooks that cover these repeated commands without changing derivation output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100