1{
2 lib,
3 stdenv,
4 cairo,
5 elfutils,
6 fetchFromGitHub,
7 fetchpatch,
8 glib,
9 gobject-introspection,
10 gtksourceview3,
11 json-glib,
12 makeWrapper,
13 pango,
14 pkg-config,
15 polkit,
16 python3,
17 scons,
18 sphinx,
19 util-linux,
20 wrapGAppsHook3,
21 withGui ? false,
22}:
23
24assert withGui -> !stdenv.hostPlatform.isDarwin;
25
26stdenv.mkDerivation rec {
27 pname = "rmlint";
28 version = "2.10.2";
29
30 src = fetchFromGitHub {
31 owner = "sahib";
32 repo = "rmlint";
33 rev = "v${version}";
34 sha256 = "sha256-pOo1YfeqHUU6xyBRFbcj2lX1MHJ+a5Hi31BMC1nYZGo=";
35 };
36
37 patches = [
38 # pass through NIX_* environment variables to scons.
39 ./scons-nix-env.patch
40 # fixes https://github.com/sahib/rmlint/issues/664
41 (fetchpatch {
42 url = "https://github.com/sahib/rmlint/commit/f0ca57ec907f7199e3670038d60b4702d1e1d8e2.patch";
43 hash = "sha256-715X+R2BcQIaUV76hoO+EXPfNheOfw4OIHsqSoruIUI=";
44 })
45 ];
46
47 nativeBuildInputs = [
48 pkg-config
49 sphinx
50 scons
51 ]
52 ++ lib.optionals withGui [
53 makeWrapper
54 wrapGAppsHook3
55 gobject-introspection
56 ];
57
58 buildInputs = [
59 glib
60 json-glib
61 util-linux
62 ]
63 ++ lib.optionals withGui [
64 cairo
65 gtksourceview3
66 pango
67 polkit
68 python3
69 python3.pkgs.pygobject3
70 ]
71 ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [
72 elfutils
73 ];
74
75 prePatch = ''
76 # remove sources of nondeterminism
77 substituteInPlace lib/cmdline.c \
78 --replace "__DATE__" "\"Jan 1 1970\"" \
79 --replace "__TIME__" "\"00:00:00\""
80 substituteInPlace docs/SConscript \
81 --replace "gzip -c " "gzip -cn "
82 '';
83
84 # Otherwise tries to access /usr.
85 prefixKey = "--prefix=";
86
87 sconsFlags = lib.optionals (!withGui) [ "--without-gui" ];
88
89 # in GUI mode, this shells out to itself, and tries to import python modules
90 postInstall = lib.optionalString withGui ''
91 gappsWrapperArgs+=(--prefix PATH : "$out/bin")
92 gappsWrapperArgs+=(--prefix PYTHONPATH : "$(toPythonPath $out):$(toPythonPath ${python3.pkgs.pygobject3}):$(toPythonPath ${python3.pkgs.pycairo})")
93 '';
94
95 meta = with lib; {
96 description = "Extremely fast tool to remove duplicates and other lint from your filesystem";
97 homepage = "https://rmlint.readthedocs.org";
98 platforms = platforms.unix;
99 license = licenses.gpl3;
100 maintainers = with maintainers; [
101 aaschmid
102 koral
103 ];
104 mainProgram = "rmlint";
105 };
106}