nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rust,
4 stdenv,
5 rustPlatform,
6 fetchCrate,
7 cargo-c,
8 nasm,
9 nix-update-script,
10 testers,
11 rav1e,
12}:
13
14rustPlatform.buildRustPackage rec {
15 pname = "rav1e";
16 version = "0.8.0";
17
18 src = fetchCrate {
19 inherit pname version;
20 hash = "sha256-hVeBrfZxqkxzUeuut0XgU4qph1z4gPzV/9mS7X9byto=";
21 };
22
23 cargoHash = "sha256-EDXzpHrdaHd3FQEuVnkQzqsYAjShsGc4XLhDAfmVXK8=";
24
25 nativeBuildInputs = [
26 cargo-c
27 nasm
28 ];
29
30 postPatch = ''
31 # remove feature that requires libgit2 and is only used to print a version string
32 substituteInPlace Cargo.toml --replace-fail '"git_version",' ""
33 ''
34 + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
35 # Darwin uses `llvm-strip`, which results in link errors when using `-x` to strip the asm library
36 # and linking it with cctools ld64.
37 substituteInPlace build.rs --replace-fail '.arg("-x")' '.arg("-S")'
38
39 # Thin LTO doesn’t appear to work with Rust 1.79. rav1e fail to build when building fern.
40 substituteInPlace Cargo.toml --replace-fail 'lto = "thin"' 'lto = "fat"'
41 '';
42
43 checkType = "debug";
44
45 postBuild = ''
46 ${rust.envVars.setEnv} cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
47 '';
48
49 postInstall = ''
50 ${rust.envVars.setEnv} cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
51 '';
52
53 passthru = {
54 tests.version = testers.testVersion { package = rav1e; };
55 updateScript = nix-update-script { };
56 };
57
58 meta = {
59 description = "Fastest and safest AV1 encoder";
60 longDescription = ''
61 rav1e is an AV1 video encoder. It is designed to eventually cover all use
62 cases, though in its current form it is most suitable for cases where
63 libaom (the reference encoder) is too slow.
64 Features: https://github.com/xiph/rav1e#features
65 '';
66 homepage = "https://github.com/xiph/rav1e";
67 changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
68 license = lib.licenses.bsd2;
69 maintainers = with lib.maintainers; [ getchoo ];
70 mainProgram = "rav1e";
71 };
72}