blob: d4e605998cc91f8f46c5bb425feb73b4d12f4719 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
{
lib,
stdenv,
buildPackages,
rustPlatform,
hdr10plus_tool,
cargo-c,
fontconfig,
}:
let
inherit (lib) optionals concatStringsSep;
inherit (buildPackages.rust.envVars) setEnv;
in
rustPlatform.buildRustPackage (finalAttrs: {
__structuredAttrs = true;
pname = "hdr10plus";
# Version of the library, not the tool
# See https://github.com/quietvoid/hdr10plus_tool/blob/main/hdr10plus/Cargo.toml
version = "2.1.4";
outputs = [
"out"
"dev"
];
inherit (hdr10plus_tool) src cargoDeps cargoHash;
nativeBuildInputs = [ cargo-c ];
buildInputs = [ fontconfig ];
cargoCFlags = [
"--package=hdr10plus"
"--frozen"
"--prefix=${placeholder "out"}"
"--includedir=${placeholder "dev"}/include"
"--pkgconfigdir=${placeholder "dev"}/lib/pkgconfig"
"--target=${stdenv.hostPlatform.rust.rustcTarget}"
];
# mirror Cargo flags
cargoCBuildFlags =
optionals (finalAttrs.cargoBuildType != "debug") [
"--profile=${finalAttrs.cargoBuildType}"
]
++ optionals (finalAttrs.cargoBuildNoDefaultFeatures) [
"--no-default-features"
]
++ optionals (finalAttrs.cargoBuildFeatures != [ ]) [
"--features=${concatStringsSep "," finalAttrs.cargoBuildFeatures}"
];
cargoCTestFlags =
optionals (finalAttrs.cargoCheckType != "debug") [
"--profile=${finalAttrs.cargoCheckType}"
]
++ optionals (finalAttrs.cargoCheckNoDefaultFeatures) [
"--no-default-features"
]
++ optionals (finalAttrs.cargoCheckFeatures != [ ]) [
"--features=${concatStringsSep "," finalAttrs.cargoCheckFeatures}"
];
configurePhase = ''
runHook preConfigure
# let stdenv handle stripping
export "CARGO_PROFILE_''${cargoBuildType@U}_STRIP"=false
prependToVar cargoCFlags -j "$NIX_BUILD_CORES"
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
${setEnv} cargo cbuild "''${cargoCFlags[@]}" "''${cargoCBuildFlags[@]}"
runHook postBuild
'';
checkPhase = ''
runHook preCheck
${setEnv} cargo ctest "''${cargoCFlags[@]}" "''${cargoCTestFlags[@]}"
runHook postCheck
'';
installPhase = ''
runHook preInstall
${setEnv} cargo cinstall "''${cargoCFlags[@]}" "''${cargoCBuildFlags[@]}"
runHook postInstall
'';
passthru.tests = {
inherit hdr10plus_tool;
};
meta = {
description = "Library to work with HDR10+ in HEVC files";
homepage = "https://github.com/quietvoid/hdr10plus_tool";
changelog = "https://github.com/quietvoid/hdr10plus_tool/releases/tag/${hdr10plus_tool.version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ mvs ];
pkgConfigModules = [ "hdr10plus-rs" ];
};
})
|