summary refs log tree commit diff
path: root/pkgs/os-specific/linux/firmware/ipu6-camera-bins/default.nix
blob: a4bbd6d2bb6bfe1ccd496343c2fab73f21159213 (plain) (blame)
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
{ lib
, stdenv
, fetchFromGitHub
, autoPatchelfHook
, expat
, zlib

# Pick one of
# - ipu6 (Tiger Lake)
# - ipu6ep (Alder Lake)
, ipuVersion ? "ipu6"
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "${ipuVersion}-camera-bin";
  version = "unstable-2023-02-08";

  src = fetchFromGitHub {
    owner = "intel";
    repo = "ipu6-camera-bins";
    rev = "276859fc6de83918a32727d676985ec40f31af2b";
    hash = "sha256-QnedM2UBbGyd2wIF762Mi+VkDZYtC6MifK4XGGxlUzw=";
  };

  sourceRoot = "${finalAttrs.src.name}/${ipuVersion}";

  nativeBuildInputs = [
    autoPatchelfHook
    stdenv.cc.cc.lib
    expat
    zlib
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out
    cp --no-preserve=mode --recursive \
      lib \
      include \
      $out/

    install -m 0644 -D ../LICENSE $out/share/doc/LICENSE

    runHook postInstall
  '';

  postFixup = ''
    for pcfile in $out/lib/pkgconfig/*.pc; do
      substituteInPlace $pcfile \
        --replace 'exec_prefix=/usr' 'exec_prefix=''${prefix}' \
        --replace 'prefix=/usr' "prefix=$out" \
        --replace 'libdir=/usr/lib' 'libdir=''${prefix}/lib' \
        --replace 'includedir=/usr/include' 'includedir=''${prefix}/include'
    done
  '';

  passthru = {
    inherit ipuVersion;
  };

  meta = let
    generation = {
      ipu6 = "Tiger Lake";
      ipu6ep = "Alder Lake";
    }.${ipuVersion};
  in with lib; {
    description = "${generation} IPU firmware and proprietary image processing libraries";
    homepage = "https://github.com/intel/ipu6-camera-bins";
    license = licenses.issl;
    sourceProvenance = with sourceTypes; [
      binaryFirmware
    ];
    maintainers = with maintainers; [
      hexa
    ];
    platforms = [ "x86_64-linux" ];
  };
})