about summary refs log tree commit diff
path: root/pkgs/tools/misc/usbimager/default.nix
blob: b845062c1783eb1d78cc0f616d968e9861ff38de (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
{ lib, stdenv, fetchFromGitLab, pkg-config, wrapGAppsHook
, withLibui ? true, gtk3
, withUdisks ? stdenv.isLinux, udisks, glib
, libX11 }:

stdenv.mkDerivation rec {
  pname = "usbimager";
  version = "1.0.10";

  src = fetchFromGitLab {
    owner = "bztsrc";
    repo = pname;
    rev = version;
    sha256 = "sha256-HTFopc2xrhp0XYubQtOwMKWTQ+3JSKAyL4mMyQ82kAs=";
  };

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

  nativeBuildInputs = [ pkg-config wrapGAppsHook ];
  buildInputs = lib.optionals withUdisks [ udisks glib ]
    ++ lib.optional (!withLibui) libX11
    ++ lib.optional withLibui gtk3;
    # libui is bundled with the source of usbimager as a compiled static library

  postPatch = ''
    sed -i \
      -e 's|install -m 2755 -g disk|install |g' \
      -e 's|-I/usr/include/gio-unix-2.0|-I${glib.dev}/include/gio-unix-2.0|g' \
      -e 's|install -m 2755 -g $(GRP)|install |g' Makefile
  '';

  dontConfigure = true;

  makeFlags =  [ "PREFIX=$(out)" ]
    ++ lib.optional withLibui "USE_LIBUI=yes"
    ++ lib.optional withUdisks "USE_UDISKS2=yes";

  meta = with lib; {
    description = "A very minimal GUI app that can write compressed disk images to USB drives";
    homepage = "https://gitlab.com/bztsrc/usbimager";
    license = licenses.mit;
    maintainers = with maintainers; [ vdot0x23 ];
    # windows and darwin could work, but untested
    # feel free add them if you have a machine to test
    platforms = with platforms; linux;
    # never built on aarch64-linux since first introduction in nixpkgs
    broken = stdenv.isLinux && stdenv.isAarch64;
    mainProgram = "usbimager";
  };
}