2022-12-05 02:51:00 +00:00
|
|
|
{ lib
|
|
|
|
, rust
|
|
|
|
, stdenv
|
|
|
|
, rustPlatform
|
|
|
|
, fetchCrate
|
2023-01-24 15:20:04 +00:00
|
|
|
, pkg-config
|
2022-12-05 02:51:00 +00:00
|
|
|
, cargo-c
|
2023-01-24 15:20:04 +00:00
|
|
|
, libgit2
|
|
|
|
, nasm
|
|
|
|
, zlib
|
2022-12-05 02:51:00 +00:00
|
|
|
, libiconv
|
|
|
|
, Security
|
2023-04-09 00:29:06 +00:00
|
|
|
, buildPackages
|
2022-12-05 02:51:00 +00:00
|
|
|
}:
|
2019-12-14 18:18:31 +00:00
|
|
|
|
lib.systems: elaborate Rust metadata
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.
This has a couple of other advantages:
- It makes Rust less special. Now figuring out what Rust calls a
platform is the same as figuring out what Linux or QEMU call it.
- We can unify the schema used to define Rust targets, and the schema
used to access those values later. Just like you can set "config"
or "system" in a platform definition, and then access those same
keys on the elaborated platform, you can now set "rustcTarget" in
your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
in your code.
"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized. The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.
The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.
The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11. We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
2023-05-09 13:38:32 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2019-12-14 18:18:31 +00:00
|
|
|
pname = "rav1e";
|
2023-05-20 10:56:00 +00:00
|
|
|
version = "0.6.6";
|
2019-12-14 18:18:31 +00:00
|
|
|
|
2021-10-08 01:10:22 +00:00
|
|
|
src = fetchCrate {
|
|
|
|
inherit pname version;
|
2023-05-20 10:56:00 +00:00
|
|
|
sha256 = "sha256-urYMT1sJUMBj1L/2Hi+hcYbWbi0ScSls0pm9gLj9H3o=";
|
2020-11-19 02:42:33 +00:00
|
|
|
};
|
2019-12-14 18:18:31 +00:00
|
|
|
|
2023-05-20 10:56:00 +00:00
|
|
|
cargoHash = "sha256-qQfEpynhlIEKU1Ptq/jM1Wdtn+BVCZT1lmou2S1GL4I=";
|
2021-10-08 01:10:22 +00:00
|
|
|
|
2023-01-24 15:20:04 +00:00
|
|
|
depsBuildBuild = [ pkg-config ];
|
|
|
|
|
2023-03-01 22:41:50 +00:00
|
|
|
nativeBuildInputs = [ cargo-c libgit2 nasm ];
|
2022-12-05 02:51:00 +00:00
|
|
|
|
2023-03-01 22:41:50 +00:00
|
|
|
buildInputs = [
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2022-12-05 02:51:00 +00:00
|
|
|
libiconv
|
|
|
|
Security
|
|
|
|
];
|
2020-06-18 16:17:54 +00:00
|
|
|
|
2023-05-22 04:29:35 +00: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 06:24:28 +00:00
|
|
|
checkType = "debug";
|
|
|
|
|
2023-04-09 00:29:06 +00:00
|
|
|
postBuild = ''
|
lib.systems: elaborate Rust metadata
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.
This has a couple of other advantages:
- It makes Rust less special. Now figuring out what Rust calls a
platform is the same as figuring out what Linux or QEMU call it.
- We can unify the schema used to define Rust targets, and the schema
used to access those values later. Just like you can set "config"
or "system" in a platform definition, and then access those same
keys on the elaborated platform, you can now set "rustcTarget" in
your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
in your code.
"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized. The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.
The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.
The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11. We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
2023-05-09 13:38:32 +00:00
|
|
|
${rust.envVars.setEnv} cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
|
2020-06-18 16:17:54 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
lib.systems: elaborate Rust metadata
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.
This has a couple of other advantages:
- It makes Rust less special. Now figuring out what Rust calls a
platform is the same as figuring out what Linux or QEMU call it.
- We can unify the schema used to define Rust targets, and the schema
used to access those values later. Just like you can set "config"
or "system" in a platform definition, and then access those same
keys on the elaborated platform, you can now set "rustcTarget" in
your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
in your code.
"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized. The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.
The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.
The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11. We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
2023-05-09 13:38:32 +00:00
|
|
|
${rust.envVars.setEnv} cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
|
2020-06-18 16:17:54 +00:00
|
|
|
'';
|
2019-12-14 18:18:31 +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-19 13:07:16 +00:00
|
|
|
homepage = "https://github.com/xiph/rav1e";
|
2020-05-29 19:16:25 +00:00
|
|
|
changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
|
2019-12-14 18:18:31 +00:00
|
|
|
license = licenses.bsd2;
|
2021-05-16 11:24:22 +00:00
|
|
|
maintainers = [ ];
|
2023-11-23 02:51:17 +00:00
|
|
|
mainProgram = "rav1e";
|
2019-12-14 18:18:31 +00:00
|
|
|
};
|
|
|
|
}
|