nixpkgs/pkgs/by-name/ra/rav1e/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

83 lines
2.2 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
lib,
rust,
stdenv,
rustPlatform,
fetchCrate,
pkg-config,
cargo-c,
darwin,
libgit2,
libiconv,
nasm,
nix-update-script,
testers,
zlib,
rav1e,
}:
rustPlatform.buildRustPackage rec {
pname = "rav1e";
version = "0.7.1";
src = fetchCrate {
inherit pname version;
hash = "sha256-Db7qb7HBAy6lniIiN07iEzURmbfNtuhmgJRv7OUagUM=";
};
cargoHash = "sha256-VyQ6n2kIJ7OjK6Xlf0T0GNsBvgESRETzKZDZzAn8ZuY=";
depsBuildBuild = [ pkg-config ];
nativeBuildInputs = [
cargo-c
libgit2
nasm
];
buildInputs =
[ zlib ]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
];
# 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.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
substituteInPlace build.rs --replace-fail '.arg("-x")' '.arg("-S")'
# Thin LTO doesnt appear to work with Rust 1.79. rav1e fail to build when building fern.
substituteInPlace Cargo.toml --replace-fail 'lto = "thin"' 'lto = "fat"'
'';
checkType = "debug";
postBuild = ''
${rust.envVars.setEnv} cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
'';
postInstall = ''
${rust.envVars.setEnv} cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
'';
passthru = {
tests.version = testers.testVersion { package = rav1e; };
updateScript = nix-update-script { };
};
meta = {
description = "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
'';
homepage = "https://github.com/xiph/rav1e";
changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
license = lib.licenses.bsd2;
maintainers = with lib.maintainers; [ getchoo ];
mainProgram = "rav1e";
};
}