diff --git a/pkgs_pr/rmlint.nix b/pkgs_pr/rmlint.nix new file mode 100644 index 0000000..b25929a --- /dev/null +++ b/pkgs_pr/rmlint.nix @@ -0,0 +1,108 @@ +{ + lib, + stdenv, + cairo, + elfutils, + fetchFromGitHub, + fetchpatch, + glib, + gobject-introspection, + gtksourceview3, + json-glib, + makeWrapper, + pango, + pkg-config, + polkit, + python3, + scons, + sphinx, + util-linux, + wrapGAppsHook3, + withGui ? false, +}: + +assert withGui -> !stdenv.hostPlatform.isDarwin; + +stdenv.mkDerivation rec { + pname = "rmlint"; + version = "2.10.2"; + + src = fetchFromGitHub { + owner = "sahib"; + repo = "rmlint"; + rev = "v${version}"; + sha256 = "sha256-pOo1YfeqHUU6xyBRFbcj2lX1MHJ+a5Hi31BMC1nYZGo="; + }; + + patches = [ + # pass through NIX_* environment variables to scons. + ./rmlint/scons-nix-env.patch + # fix #664 + (fetchpatch { + url = "https://github.com/sahib/rmlint/commit/f0ca57ec907f7199e3670038d60b4702d1e1d8e2.patch"; + hash = "sha256-715X+R2BcQIaUV76hoO+EXPfNheOfw4OIHsqSoruIUI="; + }) + ]; + + nativeBuildInputs = + [ + pkg-config + sphinx + scons + ] + ++ lib.optionals withGui [ + makeWrapper + wrapGAppsHook3 + gobject-introspection + ]; + + buildInputs = + [ + glib + json-glib + util-linux + ] + ++ lib.optionals withGui [ + cairo + gtksourceview3 + pango + polkit + python3 + python3.pkgs.pygobject3 + ] + ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [ + elfutils + ]; + + prePatch = '' + # remove sources of nondeterminism + substituteInPlace lib/cmdline.c \ + --replace "__DATE__" "\"Jan 1 1970\"" \ + --replace "__TIME__" "\"00:00:00\"" + substituteInPlace docs/SConscript \ + --replace "gzip -c " "gzip -cn " + ''; + + # Otherwise tries to access /usr. + prefixKey = "--prefix="; + + sconsFlags = lib.optionals (!withGui) [ "--without-gui" ]; + + # in GUI mode, this shells out to itself, and tries to import python modules + postInstall = lib.optionalString withGui '' + gappsWrapperArgs+=(--prefix PATH : "$out/bin") + gappsWrapperArgs+=(--prefix PYTHONPATH : "$(toPythonPath $out):$(toPythonPath ${python3.pkgs.pygobject3}):$(toPythonPath ${python3.pkgs.pycairo})") + ''; + + meta = with lib; { + description = "Extremely fast tool to remove duplicates and other lint from your filesystem"; + homepage = "https://rmlint.readthedocs.org"; + platforms = platforms.unix; + license = licenses.gpl3; + maintainers = with maintainers; [ + aaschmid + koral + ]; + mainProgram = "rmlint"; + }; +} diff --git a/pkgs_pr/rmlint/scons-nix-env.patch b/pkgs_pr/rmlint/scons-nix-env.patch new file mode 100644 index 0000000..10ed569 --- /dev/null +++ b/pkgs_pr/rmlint/scons-nix-env.patch @@ -0,0 +1,19 @@ +scons does not use os environment by default: + https://scons.org/doc/2.1.0/HTML/scons-user/x1750.html + +nixpkgs' cc-wrapper on the other hand relies on various NIX_* variables +to be passed through like NIX_CFLAGS_COMPILE_BEFORE. +--- a/SConstruct ++++ b/SConstruct +@@ -559,10 +559,7 @@ options = dict( + SHLINKCOMSTR=link_shared_library_message, + LINKCOMSTR=link_program_message, + PREFIX=GetOption('prefix'), +- ENV = dict([ (key, os.environ[key]) +- for key in os.environ +- if key in ['PATH', 'TERM', 'HOME', 'PKG_CONFIG_PATH'] +- ]) ++ ENV = os.environ, + ) + + if ARGUMENTS.get('VERBOSE') == "1":