2022-12-17 10:02:37 +00:00
|
|
|
{ lib
|
|
|
|
, rust
|
|
|
|
, stdenv
|
|
|
|
, rustPlatform
|
|
|
|
, fetchCrate
|
2023-02-02 18:25:31 +00:00
|
|
|
, pkg-config
|
2022-12-17 10:02:37 +00:00
|
|
|
, cargo-c
|
2023-02-02 18:25:31 +00:00
|
|
|
, libgit2
|
|
|
|
, nasm
|
|
|
|
, zlib
|
2022-12-17 10:02:37 +00:00
|
|
|
, libiconv
|
|
|
|
, Security
|
2023-04-29 16:46:19 +00:00
|
|
|
, buildPackages
|
2022-12-17 10:02:37 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
let
|
|
|
|
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
2023-04-29 16:46:19 +00: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-06-28 23:13:55 +00:00
|
|
|
in rustPlatform.buildRustPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "rav1e";
|
2023-04-29 16:46:19 +00:00
|
|
|
version = "0.6.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
src = fetchCrate {
|
|
|
|
inherit pname version;
|
2023-04-29 16:46:19 +00:00
|
|
|
sha256 = "sha256-G7o82MAZmMOfs1wp3AVUgXxDW6Txuc0qTm5boRpXF6g=";
|
2020-11-21 19:51:51 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
cargoHash = "sha256-12bePpI8z35gzCHGKDpaGUVvosQqijP60NCgElHDsyw=";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
depsBuildBuild = [ pkg-config ];
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
nativeBuildInputs = [ cargo-c libgit2 nasm ];
|
2022-12-17 10:02:37 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
buildInputs = [
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2022-12-17 10:02:37 +00:00
|
|
|
libiconv
|
|
|
|
Security
|
|
|
|
];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2021-12-26 17:43:05 +00:00
|
|
|
checkType = "debug";
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
postBuild = ''
|
|
|
|
${setEnvVars} \
|
2021-06-28 23:13:55 +00:00
|
|
|
cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2023-04-29 16:46:19 +00:00
|
|
|
${setEnvVars} \
|
2021-06-28 23:13:55 +00:00
|
|
|
cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00: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-21 19:51:51 +00:00
|
|
|
homepage = "https://github.com/xiph/rav1e";
|
2020-06-02 18:00:15 +00:00
|
|
|
changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.bsd2;
|
2021-05-20 23:08:51 +00:00
|
|
|
maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|