From 2608e5266418138b74648c47611d3f77e45c65a4 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Thu, 18 Jun 2020 13:19:44 +0200 Subject: [PATCH 1/2] cargo-c: init at 0.6.7 This crate is required for building the C-API for rav1e [0] but is also used by other projects [1]. [0]: https://github.com/xiph/rav1e#building-the-c-api [1]: https://github.com/lu-zero/cargo-c/#users --- .../tools/rust/cargo-c/default.nix | 48 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 1 + 2 files changed, 49 insertions(+) create mode 100644 pkgs/development/tools/rust/cargo-c/default.nix diff --git a/pkgs/development/tools/rust/cargo-c/default.nix b/pkgs/development/tools/rust/cargo-c/default.nix new file mode 100644 index 000000000000..bd2d370d1c87 --- /dev/null +++ b/pkgs/development/tools/rust/cargo-c/default.nix @@ -0,0 +1,48 @@ +{ rustPlatform, stdenv, lib, fetchFromGitHub, fetchurl +, pkg-config, openssl +}: + +rustPlatform.buildRustPackage rec { + pname = "cargo-c"; + version = "0.6.7"; + + src = stdenv.mkDerivation rec { + name = "${pname}-source-${version}"; + + src = fetchFromGitHub { + owner = "lu-zero"; + repo = pname; + rev = "v${version}"; + sha256 = "0n52xh4qg12bvvp2dgx5wfj5f31qijdqahasa3qfa3c3aqq7cvvg"; + }; + cargoLock = fetchurl { + url = "https://github.com/lu-zero/${pname}/releases/download/v${version}/Cargo.lock"; + sha256 = "0296187hsaxxmqhsrrva4qf313jwh3z08j1vxcbislxdq8xg32qb"; + }; + + installPhase = '' + mkdir -p $out + cp -R ./* $out/ + cp ${cargoLock} $out/Cargo.lock + ''; + }; + + cargoSha256 = "1gwyszpcmss2d0lm5hvf3b48jy7b0fm7xizhrl3wd6rzw7pg06zd"; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; + + meta = with lib; { + description = "A cargo subcommand to build and install C-ABI compatibile dynamic and static libraries"; + longDescription = '' + Cargo C-ABI helpers. A cargo applet that produces and installs a correct + pkg-config file, a static library and a dynamic library, and a C header + to be used by any C (and C-compatible) software. + ''; + homepage = "https://github.com/lu-zero/cargo-c"; + changelog = "https://github.com/lu-zero/cargo-c/releases/tag/v${version}"; + license = licenses.mit; + platforms = platforms.unix; + maintainers = with maintainers; [ primeos ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0a0bb8018efe..be4c03fd5396 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9198,6 +9198,7 @@ in cargo-audit = callPackage ../tools/package-management/cargo-audit { inherit (darwin.apple_sdk.frameworks) Security; }; + cargo-c = callPackage ../development/tools/rust/cargo-c { }; cargo-deb = callPackage ../tools/package-management/cargo-deb { inherit (darwin.apple_sdk.frameworks) Security; }; From 7024a01211d9d0a4f8ab138a611349c37ac5a537 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Thu, 18 Jun 2020 18:17:54 +0200 Subject: [PATCH 2/2] rav1e: Build and install C-compatible libraries This is required for AV1 encoding support via librav1e in FFmpeg 4.3: https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d8bf24459b694338de4ceb2a2e6d4d2949d6658d --- pkgs/tools/video/rav1e/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/video/rav1e/default.nix b/pkgs/tools/video/rav1e/default.nix index b8e43fe4f10f..f8d547b0285c 100644 --- a/pkgs/tools/video/rav1e/default.nix +++ b/pkgs/tools/video/rav1e/default.nix @@ -1,4 +1,4 @@ -{ rustPlatform, fetchFromGitHub, lib, nasm }: +{ rustPlatform, fetchFromGitHub, lib, nasm, cargo-c }: rustPlatform.buildRustPackage rec { pname = "rav1e"; @@ -13,7 +13,15 @@ rustPlatform.buildRustPackage rec { cargoSha256 = "1xaincrmpicp0skf9788w5631x1hxvifvq06hh5ribdz79zclzx3"; - nativeBuildInputs = [ nasm ]; + nativeBuildInputs = [ nasm cargo-c ]; + + postBuild = '' + cargo cbuild --release --frozen --prefix=${placeholder "out"} + ''; + + postInstall = '' + cargo cinstall --release --frozen --prefix=${placeholder "out"} + ''; meta = with lib; { description = "The fastest and safest AV1 encoder";