about summary refs log tree commit diff
path: root/pkgs/by-name/rp/rpi-imager/package.nix
blob: 39a07b53d3c3e476ba8a0ee733093c91922734fe (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
80
81
82
83
84
85
86
{
  lib,
  stdenv,
  cmake,
  curl,
  fetchFromGitHub,
  libarchive,
  nix-update-script,
  pkg-config,
  qt5,
  testers,
  util-linux,
  xz,
  enableTelemetry ? false,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "rpi-imager";
  version = "1.8.5";

  src = fetchFromGitHub {
    owner = "raspberrypi";
    repo = "rpi-imager";
    rev = "refs/tags/v${finalAttrs.version}";
    hash = "sha256-JrotKMyAgQO3Y5RsFAar9N5/wDpWiBcy8RfvBWDiJMs=";
  };

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

  # By default, the builder checks for JSON support in lsblk by running "lsblk --json",
  # but that throws an error, as /sys/dev doesn't exist in the sandbox.
  # This patch removes the check.
  patches = [ ./lsblkCheckFix.patch ];

  nativeBuildInputs = [
    cmake
    pkg-config
    qt5.wrapQtAppsHook
    util-linux
  ];

  buildInputs =
    [
      curl
      libarchive
      qt5.qtbase
      qt5.qtdeclarative
      qt5.qtgraphicaleffects
      qt5.qtquickcontrols2
      qt5.qtsvg
      qt5.qttools
      xz
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      qt5.qtwayland
    ];

  # Disable telemetry and update check.
  cmakeFlags = lib.optionals (!enableTelemetry) [
    "-DENABLE_CHECK_VERSION=OFF"
    "-DENABLE_TELEMETRY=OFF"
  ];

  passthru = {
    tests.version = testers.testVersion {
      package = finalAttrs.finalPackage;
      command = "QT_QPA_PLATFORM=offscreen rpi-imager --version";
    };
    updateScript = nix-update-script { };
  };

  meta = with lib; {
    description = "Raspberry Pi Imaging Utility";
    homepage = "https://github.com/raspberrypi/rpi-imager/";
    changelog = "https://github.com/raspberrypi/rpi-imager/releases/tag/v${finalAttrs.version}";
    license = licenses.asl20;
    mainProgram = "rpi-imager";
    maintainers = with maintainers; [
      ymarkus
      anthonyroussel
    ];
    platforms = platforms.all;
    # does not build on darwin
    broken = stdenv.hostPlatform.isDarwin;
  };
})