about summary refs log tree commit diff
path: root/pkgs/tools/misc/woeusb/default.nix
blob: 9add255896f7578b833510dcce8b20d7c3c980f5 (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
{ lib, stdenv, fetchFromGitHub, installShellFiles, makeWrapper
, coreutils, dosfstools, findutils, gawk, gnugrep, grub2_light, ncurses, ntfs3g, parted, p7zip, util-linux, wimlib, wget }:

stdenv.mkDerivation rec {
  version = "5.2.4";
  pname = "woeusb";

  src = fetchFromGitHub {
    owner = "WoeUSB";
    repo = "WoeUSB";
    rev = "v${version}";
    sha256 = "sha256-HB1E7rP/U58dyL3j6YnhF5AOGAcHqmA/ZZ5JNBDibco=";
  };

  nativeBuildInputs = [ installShellFiles makeWrapper ];

  postPatch = ''
    # Emulate version smudge filter (see .gitattributes, .gitconfig).
    for file in sbin/woeusb share/man/man1/woeusb.1; do
      substituteInPlace "$file" \
        --replace '@@WOEUSB_VERSION@@' '${version}'
    done
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    mv sbin/woeusb $out/bin
    installManPage share/man/man1/woeusb.1

    wrapProgram "$out/bin/woeusb" \
      --set PATH '${lib.makeBinPath [ coreutils dosfstools findutils gawk gnugrep grub2_light ncurses ntfs3g parted p7zip util-linux wget wimlib ]}'

    runHook postInstall
  '';

  doInstallCheck = true;

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

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