summary refs log tree commit diff
path: root/pkgs/tools/misc/woeusb/default.nix
blob: 9c6211b13dfea453c333e4e515aba07bd67f127e (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
{ stdenv, fetchFromGitHub, autoreconfHook, makeWrapper
, coreutils, dosfstools, findutils, gawk, gnugrep, grub2_light, ncurses, ntfs3g, parted, utillinux, wget
, wxGTK30 }:

stdenv.mkDerivation rec {
  version = "3.2.1";
  name = "woeusb-${version}";

  src = fetchFromGitHub {
    owner = "slacka";
    repo = "WoeUSB";
    rev = "v${version}";
    sha256 = "0qymdc216ws6adkzmzxz6hx43dim0hpwab9c4qmgg8jnkhnpvnj1";
  };

  buildInputs = [ wxGTK30 autoreconfHook makeWrapper ];

  postPatch = ''
    # Emulate version smudge filter (see .gitattributes, .gitconfig).
    for file in configure.ac debian/changelog src/woeusb src/woeusb.1 src/woeusbgui.1; do
      substituteInPlace "$file" \
        --replace '@@WOEUSB_VERSION@@' '${version}'
    done

    substituteInPlace src/MainPanel.cpp \
      --replace "'woeusb " "'$out/bin/woeusb "
  '';

  postInstall = ''
    # don't write data into /
    substituteInPlace "$out/bin/woeusb" \
      --replace /media/ /run/woeusb/

    # woeusbgui launches woeusb with pkexec, which sets
    # PATH=/usr/sbin:/usr/bin:/sbin:/bin:/root/bin.  Perhaps pkexec
    # should be patched with a less useless default PATH, but for now
    # we add everything we need manually.
    wrapProgram "$out/bin/woeusb" \
      --set PATH '${stdenv.lib.makeBinPath [ coreutils dosfstools findutils gawk gnugrep grub2_light ncurses ntfs3g parted utillinux wget ]}'
  '';

  doInstallCheck = true;

  postInstallCheck = ''
    # woeusb --version checks for missing runtime dependencies.
    out_version="$("$out/bin/woeusb" --version)"
    [ "$out_version" = '${version}' ]
  '';

  meta = with stdenv.lib; {
    description = "Create bootable USB disks from Windows ISO images";
    homepage = https://github.com/slacka/WoeUSB;
    license = licenses.gpl3;
    maintainers = with maintainers; [ bjornfor gnidorah ];
    platforms = platforms.linux;
  };
}