1{ stdenv, fetchFromGitHub, pkgconfig, libusb1, udev
2, enableGUI ? true, qt4 ? null
3}:
4
5stdenv.mkDerivation rec {
6 version = "1.4.1";
7 name = "heimdall-${version}";
8
9 src = fetchFromGitHub {
10 owner = "Benjamin-Dobell";
11 repo = "Heimdall";
12 rev = "v${version}";
13 sha256 = "1b7xpamwvw5r2d9yf73f0axv35vg8zaz1345xs3lmsr105phnnp4";
14 };
15
16 buildInputs =
17 [ pkgconfig libusb1 udev ]
18 ++ stdenv.lib.optional enableGUI qt4 ;
19
20 makeFlags = "udevrulesdir=$(out)/lib/udev/rules.d";
21
22 preConfigure =
23 ''
24 pushd libpit
25 ./configure
26 make
27 popd
28
29 cd heimdall
30 substituteInPlace Makefile.in --replace sudo true
31
32 # Give ownership of the Galaxy S USB device to the logged in
33 # user.
34 substituteInPlace 60-heimdall-galaxy-s.rules --replace 'MODE="0666"' 'TAG+="udev-acl"'
35 '';
36
37 postBuild = stdenv.lib.optionalString enableGUI
38 ''
39 pushd ../heimdall-frontend
40 substituteInPlace Source/mainwindow.cpp --replace /usr/bin $out/bin
41 qmake heimdall-frontend.pro OUTPUTDIR=$out/bin
42 make
43 popd
44 '';
45
46 postInstall =
47 ''
48 mkdir -p $out/share/doc/heimdall
49 cp ../Linux/README $out/share/doc/heimdall/
50 '' + stdenv.lib.optionalString enableGUI ''
51 make -C ../heimdall-frontend install
52 '';
53
54 meta = {
55 homepage = http://www.glassechidna.com.au/products/heimdall/;
56 description = "A cross-platform open-source tool suite used to flash firmware onto Samsung Galaxy S devices";
57 license = stdenv.lib.licenses.mit;
58 };
59}