build avif_native from source for nix
This commit is contained in:
parent
2d45c85d2b
commit
0c864d613a
1 changed files with 15 additions and 29 deletions
|
|
@ -1,24 +1,11 @@
|
||||||
# avif_native's build hook downloads its prebuilt library, which the sandbox
|
# avif_native's build hook downloads its prebuilt library, which the sandbox
|
||||||
# can't do, so bundle it and point the manifest at the local copy instead
|
# can't do, so build it from source against nixpkgs' libavif, and point the
|
||||||
|
# manifest at it
|
||||||
{
|
{
|
||||||
stdenv,
|
stdenv,
|
||||||
fetchurl,
|
libavif,
|
||||||
jq,
|
jq,
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
artifacts = {
|
|
||||||
x86_64-linux = {
|
|
||||||
arch = "x64";
|
|
||||||
sha256 = "fa36210bc95b70abd14c20fd626204f57d0ef947297e9ff8ee66855c01e2c17f";
|
|
||||||
};
|
|
||||||
aarch64-linux = {
|
|
||||||
arch = "arm64";
|
|
||||||
sha256 = "163487e98b5eee0676be0dc8d3f60b5e0e5b67191a8a0a2abb5c8fad14a3a506";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
inherit (artifacts.${stdenv.hostPlatform.system}) arch sha256;
|
|
||||||
key = "linux-${arch}-decode-dav1d";
|
|
||||||
in
|
|
||||||
{ version, src, ... }:
|
{ version, src, ... }:
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "avif_native";
|
pname = "avif_native";
|
||||||
|
|
@ -26,24 +13,23 @@ stdenv.mkDerivation {
|
||||||
inherit (src) passthru;
|
inherit (src) passthru;
|
||||||
|
|
||||||
nativeBuildInputs = [ jq ];
|
nativeBuildInputs = [ jq ];
|
||||||
|
buildInputs = [ libavif ];
|
||||||
|
|
||||||
library = fetchurl {
|
buildPhase = ''
|
||||||
url = "https://github.com/Zhangw1998/avif_native/releases/download/native-v0.2.0/${key}-libavif_native.so.gz";
|
$CC -shared -fPIC src/avif_shim.c -lavif -o native/libavif_native.so
|
||||||
inherit sha256;
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
# The hook checksums the library, so it must stay byte-identical
|
# The hook checksums the library, so it mustn't change after it's hashed
|
||||||
dontFixup = true;
|
dontFixup = true;
|
||||||
|
|
||||||
|
# Nexus only decodes, with dav1d, see hooks.user_defines in pubspec.yaml
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
cp -r . $out
|
cp -r . $out
|
||||||
chmod -R u+w $out
|
jq --arg hash "$(sha256sum native/libavif_native.so | cut -d " " -f 1)" \
|
||||||
gunzip -c $library > $out/native/libavif_native.so
|
'.artifacts |= with_entries(
|
||||||
jq '.artifacts["${key}"].path = "libavif_native.so"' \
|
if .key | test("^linux-.*-decode-dav1d$")
|
||||||
native/manifest.json > $out/native/manifest.json
|
then .value += { path: "libavif_native.so", librarySha256: $hash }
|
||||||
|
else . end
|
||||||
runHook postInstall
|
)' native/manifest.json > $out/native/manifest.json
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue