1{ mkDerivation
2, lib, stdenv
3, fetchurl
4, ncurses
5, libuuid
6, pkg-config
7, libjpeg
8, zlib
9, libewf
10, enableNtfs ? !stdenv.isDarwin, ntfs3g ? null
11, enableExtFs ? !stdenv.isDarwin, e2fsprogs ? null
12, enableQt ? false, qtbase ? null, qttools ? null, qwt ? null
13}:
14
15assert enableNtfs -> ntfs3g != null;
16assert enableExtFs -> e2fsprogs != null;
17assert enableQt -> qtbase != null;
18assert enableQt -> qttools != null;
19assert enableQt -> qwt != null;
20
21(if enableQt then mkDerivation else stdenv.mkDerivation) rec {
22 pname = "testdisk";
23 version = "7.1";
24 src = fetchurl {
25 url = "https://www.cgsecurity.org/testdisk-${version}.tar.bz2";
26 sha256 = "1zlh44w67py416hkvw6nrfmjickc2d43v51vcli5p374d5sw84ql";
27 };
28
29 postPatch = ''
30 substituteInPlace linux/qphotorec.desktop \
31 --replace "/usr" "$out"
32 '';
33
34 enableParallelBuilding = true;
35
36 buildInputs = [
37 ncurses
38 libuuid
39 libjpeg
40 zlib
41 libewf
42 ]
43 ++ lib.optional enableNtfs ntfs3g
44 ++ lib.optional enableExtFs e2fsprogs
45 ++ lib.optionals enableQt [ qtbase qttools qwt ];
46
47 nativeBuildInputs = [ pkg-config ];
48
49 env.NIX_CFLAGS_COMPILE = "-Wno-unused";
50
51 meta = with lib; {
52 homepage = "https://www.cgsecurity.org/wiki/Main_Page";
53 downloadPage = "https://www.cgsecurity.org/wiki/TestDisk_Download";
54 description = "Data recovery utilities";
55 longDescription = ''
56 TestDisk is a powerful free data recovery software. It was primarily
57 designed to help recover lost partitions and/or make non-booting disks
58 bootable again when these symptoms are caused by faulty software: certain
59 types of viruses or human error (such as accidentally deleting a
60 Partition Table).
61
62 PhotoRec is a file data recovery software designed to recover lost files
63 including video, documents and archives from hard disks, CD-ROMs, and
64 lost pictures (thus the Photo Recovery name) from digital camera memory.
65 PhotoRec ignores the file system and goes after the underlying data, so
66 it will still work even if your media's file system has been severely
67 damaged or reformatted.
68 '';
69 license = lib.licenses.gpl2Plus;
70 platforms = lib.platforms.all;
71 maintainers = with maintainers; [ fgaz eelco ];
72 };
73}