2022-12-05 03:51:00 +01:00
|
|
|
{ lib
|
|
|
|
, rust
|
|
|
|
, stdenv
|
|
|
|
, rustPlatform
|
|
|
|
, fetchCrate
|
2023-01-24 16:20:04 +01:00
|
|
|
, pkg-config
|
2022-12-05 03:51:00 +01:00
|
|
|
, cargo-c
|
2023-01-24 16:20:04 +01:00
|
|
|
, libgit2
|
|
|
|
, nasm
|
|
|
|
, zlib
|
2022-12-05 03:51:00 +01:00
|
|
|
, libiconv
|
|
|
|
, Security
|
2023-04-09 02:29:06 +02:00
|
|
|
, buildPackages
|
2022-12-05 03:51:00 +01:00
|
|
|
}:
|
2019-12-14 19:18:31 +01:00
|
|
|
|
2021-05-31 00:29:16 +02:00
|
|
|
let
|
|
|
|
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
2023-04-09 02:29:06 +02:00
|
|
|
|
|
|
|
# TODO: if another package starts using cargo-c (seems likely),
|
|
|
|
# factor this out into a makeCargoChook expression in
|
|
|
|
# pkgs/build-support/rust/hooks/default.nix
|
|
|
|
ccForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
|
|
|
|
cxxForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++";
|
|
|
|
ccForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
|
|
|
cxxForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
|
|
|
|
rustBuildPlatform = rust.toRustTarget stdenv.buildPlatform;
|
|
|
|
rustTargetPlatform = rust.toRustTarget stdenv.hostPlatform;
|
|
|
|
setEnvVars = ''
|
|
|
|
env \
|
|
|
|
"CC_${rustBuildPlatform}"="${ccForBuild}" \
|
|
|
|
"CXX_${rustBuildPlatform}"="${cxxForBuild}" \
|
|
|
|
"CC_${rustTargetPlatform}"="${ccForHost}" \
|
|
|
|
"CXX_${rustTargetPlatform}"="${cxxForHost}" \
|
|
|
|
'';
|
|
|
|
|
2021-05-31 00:29:16 +02:00
|
|
|
in rustPlatform.buildRustPackage rec {
|
2019-12-14 19:18:31 +01:00
|
|
|
pname = "rav1e";
|
2023-05-20 12:56:00 +02:00
|
|
|
version = "0.6.6";
|
2019-12-14 19:18:31 +01:00
|
|
|
|
2021-10-08 03:10:22 +02:00
|
|
|
src = fetchCrate {
|
|
|
|
inherit pname version;
|
2023-05-20 12:56:00 +02:00
|
|
|
sha256 = "sha256-urYMT1sJUMBj1L/2Hi+hcYbWbi0ScSls0pm9gLj9H3o=";
|
2020-11-19 03:42:33 +01:00
|
|
|
};
|
2019-12-14 19:18:31 +01:00
|
|
|
|
2023-05-20 12:56:00 +02:00
|
|
|
cargoHash = "sha256-qQfEpynhlIEKU1Ptq/jM1Wdtn+BVCZT1lmou2S1GL4I=";
|
2021-10-08 03:10:22 +02:00
|
|
|
|
2023-01-24 16:20:04 +01:00
|
|
|
depsBuildBuild = [ pkg-config ];
|
|
|
|
|
2023-03-01 23:41:50 +01:00
|
|
|
nativeBuildInputs = [ cargo-c libgit2 nasm ];
|
2022-12-05 03:51:00 +01:00
|
|
|
|
2023-03-01 23:41:50 +01:00
|
|
|
buildInputs = [
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2022-12-05 03:51:00 +01:00
|
|
|
libiconv
|
|
|
|
Security
|
|
|
|
];
|
2020-06-18 18:17:54 +02:00
|
|
|
|
2023-05-22 06:29:35 +02:00
|
|
|
# Darwin uses `llvm-strip`, which results in link errors when using `-x` to strip the asm library
|
|
|
|
# and linking it with cctools ld64.
|
|
|
|
postPatch = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
|
|
|
|
substituteInPlace build.rs --replace 'cmd.arg("-x")' 'cmd.arg("-S")'
|
|
|
|
'';
|
|
|
|
|
2021-12-06 07:24:28 +01:00
|
|
|
checkType = "debug";
|
|
|
|
|
2023-04-09 02:29:06 +02:00
|
|
|
postBuild = ''
|
|
|
|
${setEnvVars} \
|
2021-05-31 00:29:16 +02:00
|
|
|
cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
2020-06-18 18:17:54 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2023-04-09 02:29:06 +02:00
|
|
|
${setEnvVars} \
|
2021-05-31 00:29:16 +02:00
|
|
|
cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
2020-06-18 18:17:54 +02:00
|
|
|
'';
|
2019-12-14 19:18:31 +01:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "The fastest and safest AV1 encoder";
|
|
|
|
longDescription = ''
|
|
|
|
rav1e is an AV1 video encoder. It is designed to eventually cover all use
|
|
|
|
cases, though in its current form it is most suitable for cases where
|
|
|
|
libaom (the reference encoder) is too slow.
|
|
|
|
Features: https://github.com/xiph/rav1e#features
|
|
|
|
'';
|
2020-11-19 14:07:16 +01:00
|
|
|
homepage = "https://github.com/xiph/rav1e";
|
2020-05-29 21:16:25 +02:00
|
|
|
changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
|
2019-12-14 19:18:31 +01:00
|
|
|
license = licenses.bsd2;
|
2021-05-16 13:24:22 +02:00
|
|
|
maintainers = [ ];
|
2019-12-14 19:18:31 +01:00
|
|
|
};
|
|
|
|
}
|