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