summary refs log tree commit diff
path: root/pkgs/tools/cd-dvd/unetbootin/default.nix
blob: f80f606084706ea1db38b76d318d7aa161b3ed7e (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
{ lib
, stdenv
, coreutils
, fetchFromGitHub
, libsForQt5
, mtools
, p7zip
, qt5
, syslinux
, util-linux
, which
}:

stdenv.mkDerivation rec {
  pname = "unetbootin";
  version = "702";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = version;
    sha256 = "sha256-psX15XicPXAsd36BhuvK0G3GQS8hV/hazzO0HByCqV4=";
  };

  setSourceRoot = ''
    sourceRoot=$(echo */src/unetbootin)
  '';

  buildInputs = [
    qt5.qtbase
    qt5.qttools
    libsForQt5.qmake
  ];

  nativeBuildInputs = [ qt5.wrapQtAppsHook ];

  enableParallelBuilding = true;

  # Lots of nice hard-coded paths...
  postPatch = ''
    substituteInPlace unetbootin.cpp \
      --replace /bin/df             ${coreutils}/bin/df \
      --replace /sbin/blkid         ${util-linux}/sbin/blkid \
      --replace /sbin/fdisk         ${util-linux}/sbin/fdisk \
      --replace /sbin/sfdisk        ${util-linux}/sbin/sfdisk \
      --replace /usr/bin/syslinux   ${syslinux}/bin/syslinux \
      --replace /usr/bin/extlinux   ${syslinux}/sbin/extlinux \
      --replace /usr/share/syslinux ${syslinux}/share/syslinux

    substituteInPlace main.cpp \
      --replace /usr/share/unetbootin $out/share/unetbootin

    substituteInPlace unetbootin.desktop \
      --replace /usr/bin $out/bin
  '';

  preConfigure = ''
    lupdate unetbootin.pro
    lrelease unetbootin.pro
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 -t $out/bin                unetbootin
    install -Dm644 -t $out/share/unetbootin   unetbootin_*.qm
    install -Dm644 -t $out/share/applications unetbootin.desktop

    runHook postInstall
  '';

  qtWrapperArgs = [
    "--prefix PATH : ${lib.makeBinPath [ mtools p7zip which ]}"
    "--set QT_X11_NO_MITSHM 1"
  ];

  meta = with lib; {
    description = "A tool to create bootable live USB drives from ISO images";
    homepage = "http://unetbootin.github.io/";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ ebzzry ];
    platforms = platforms.linux;
  };
}