1{
2 lib,
3 stdenv,
4 fetchpatch,
5 fetchFromGitHub,
6 btrfs-progs,
7 python3,
8 udevCheckHook,
9}:
10
11let
12 btrfsProgsPatched = btrfs-progs.overrideAttrs {
13 patches = [
14 (fetchpatch {
15 url = "https://raw.githubusercontent.com/Lakshmipathi/dduper/7e8f995a3a6179a31d15ce073bce6cfbaefb81ed/patch/btrfs-progs-v6.11/0001-Print-csum-for-a-given-file-on-stdout.patch";
16 hash = "sha256-ndydH5tHKYLKhstNdpfuJVCUrwl+6VJwprKy4hz8uwM=";
17 })
18 ];
19 };
20 py3 = python3.withPackages (
21 ps: with ps; [
22 prettytable
23 numpy
24 ]
25 );
26in
27stdenv.mkDerivation rec {
28 pname = "dduper";
29 version = "0.04";
30
31 src = fetchFromGitHub {
32 owner = "lakshmipathi";
33 repo = "dduper";
34 rev = "v${version}";
35 sha256 = "09ncdawxkffldadqhfblqlkdl05q2qmywxyg6p61fv3dr2f2v5wm";
36 };
37
38 buildInputs = [
39 btrfsProgsPatched
40 py3
41 ];
42
43 nativeBuildInputs = [
44 udevCheckHook
45 ];
46
47 doInstallCheck = true;
48
49 patchPhase = ''
50 substituteInPlace ./dduper --replace "/usr/sbin/btrfs.static" "${btrfsProgsPatched}/bin/btrfs"
51 '';
52
53 installPhase = ''
54 mkdir -p $out/bin
55 install -m755 ./dduper $out/bin
56 '';
57
58 meta = with lib; {
59 description = "Fast block-level out-of-band BTRFS deduplication tool";
60 mainProgram = "dduper";
61 homepage = "https://github.com/Lakshmipathi/dduper";
62 license = licenses.gpl2Plus;
63 maintainers = with maintainers; [ thesola10 ];
64 platforms = platforms.linux;
65 };
66}