New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cargo-c and a C-API for rav1e #91050
Conversation
This crate is required for building the C-API for rav1e [0] but is also used by other projects [1]. [0]: https://github.com/xiph/rav1e#building-the-c-api [1]: https://github.com/lu-zero/cargo-c/#users
This is required for AV1 encoding support via librav1e in FFmpeg 4.3: https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d8bf24459b694338de4ceb2a2e6d4d2949d6658d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things that could be improved
postBuild = '' | ||
cargo cbuild --release --frozen --prefix=${placeholder "out"} | ||
''; | ||
|
||
postInstall = '' | ||
cargo cinstall --release --frozen --prefix=${placeholder "out"} | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to have this as a hook from cargo-c
but I don't think we have an extensible abstraction for this yet (though I'm not familiar with our Rust abstractions).
Also: I guess this breaks cross-compilation (if it did work before).
src = stdenv.mkDerivation rec { | ||
name = "${pname}-source-${version}"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "lu-zero"; | ||
repo = pname; | ||
rev = "v${version}"; | ||
sha256 = "0n52xh4qg12bvvp2dgx5wfj5f31qijdqahasa3qfa3c3aqq7cvvg"; | ||
}; | ||
cargoLock = fetchurl { | ||
url = "https://github.com/lu-zero/${pname}/releases/download/v${version}/Cargo.lock"; | ||
sha256 = "0296187hsaxxmqhsrrva4qf313jwh3z08j1vxcbislxdq8xg32qb"; | ||
}; | ||
|
||
installPhase = '' | ||
mkdir -p $out | ||
cp -R ./* $out/ | ||
cp ${cargoLock} $out/Cargo.lock | ||
''; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add an abstraction for this? Ideally buildRustPackage
should support adding the Cargo.lock
file before fetching the crates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please, there are a few packages which abuse cargoPatches
because of this e.g. https://github.com/NixOS/nixpkgs/blob/c87f619edd88c8f88134aaa821f1da73794b766f/pkgs/tools/package-management/cargo-update/0001-Generate-lockfile-for-cargo-update-v3.0.0.patch
Unfortunately this isn't that pretty but let's try it out and hopefully clean it up later. I successfully tested it with |
Motivation for this change
After #90541 this should make it possible to enable AV1 encoding support via librav1e in FFmpeg.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)