nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 makeDesktopItem,
6 copyDesktopItems,
7 makeBinaryWrapper,
8 jdk17,
9 ant,
10 stripJavaArchivesHook,
11 gettext,
12}:
13
14let
15 wpcleanerJar = "$out/share/wpcleaner/WikipediaCleaner.jar";
16 clientScript = "$out/bin/wpcleaner";
17 botScript = "$out/bin/wpcleaner-bot";
18 runTaskScript = "$out/bin/wpcleaner-run-task";
19 extraJavaArgs = [
20 "-Dawt.useSystemAAFontSettings=gasp"
21 "-Xms1g"
22 "-Xmx8g"
23 ];
24in
25stdenv.mkDerivation {
26 pname = "wpcleaner";
27 version = "2.0.5-unstable-2025-04-25";
28 src = fetchFromGitHub {
29 owner = "WPCleaner";
30 repo = "wpcleaner";
31 rev = "7fd357cf26349658183517658139870dd45eaedc";
32 hash = "sha256-iaAP/5Z+ghvMAn4ke7lhRqKov/3jXr0LMwbPDZ052j0=";
33 };
34
35 dontConfigure = true;
36
37 patches = [
38 # The names of the scripts are too generic (e.g. Bot.sh) and the scripts
39 # run the jar through getdown, which is a tool which checks if there is a
40 # new version of the jar automatically and update itself if it is the case,
41 # therefore we want to disable it.
42 ./0001-fix-script-names-and-remove-getdown.patch
43 # Building the documentation requires internet access to docs.oracle.com,
44 # which is not available at build time and is not useful to the user.
45 ./0002-dont-build-javadoc.patch
46 ];
47
48 nativeBuildInputs = [
49 jdk17
50 ant
51 gettext
52 makeBinaryWrapper
53 copyDesktopItems
54 stripJavaArchivesHook
55 ];
56
57 buildInputs = [ jdk17 ];
58
59 buildPhase = ''
60 runHook preBuild
61
62 cd WikipediaCleaner
63 echo "" | ant
64
65 runHook postBuild
66 '';
67
68 installPhase = ''
69 runHook preInstall
70
71 install -Dm744 build/dist/full/WikipediaCleaner.jar ${wpcleanerJar}
72 install -Dm744 resources/getdown/WPCleaner.sh ${clientScript}
73 install -Dm744 resources/getdown/Bot.sh ${botScript}
74 install -Dm744 run-task.sh ${runTaskScript}
75
76 substituteInPlace \
77 ${clientScript} ${botScript} ${runTaskScript} \
78 --subst-var-by wpcleaner_jar "${wpcleanerJar}" \
79 --subst-var-by tasks "$out/share/wpcleaner/tasks"
80
81 wrapProgram ${clientScript} \
82 --prefix PATH : ${lib.makeBinPath [ jdk17 ]} \
83 --prefix JAVA_JDK_OPTIONS " " "${lib.strings.concatStringsSep " " extraJavaArgs}"
84 wrapProgram ${botScript} \
85 --prefix PATH : ${lib.makeBinPath [ jdk17 ]} \
86 --prefix JAVA_JDK_OPTIONS " " "${lib.strings.concatStringsSep " " extraJavaArgs}"
87 wrapProgram ${runTaskScript} \
88 --prefix PATH : ${lib.makeBinPath [ jdk17 ]} \
89 --prefix JAVA_JDK_OPTIONS " " "${lib.strings.concatStringsSep " " extraJavaArgs}"
90
91 cp -r resources/tasks $out/share/wpcleaner
92 install -Dm644 resources/commons-nuvola-web-broom-64px.png $out/share/icons/hicolor/64x64/apps/wpcleaner.png
93
94 runHook postInstall
95 '';
96
97 desktopItems = [
98 (makeDesktopItem {
99 name = "wpcleaner";
100 desktopName = "WPCleaner";
101 comment = "Perform maintenance on Wikipedia";
102 icon = "wpcleaner";
103 exec = "wpcleaner";
104 categories = [ "Utility" ];
105 keywords = [ "Wikipedia" ];
106 })
107 ];
108
109 meta = {
110 description = "Utility for performing maintenance on Wikipedia";
111 longDescription = ''
112 WPCleaner is a tool designed to help with various maintenance tasks, especially repairing
113 links to disambiguation pages, checking Wikipedia, fixing spelling and typography, and
114 helping with translation of articles coming from other wikis.
115 '';
116 homepage = "https://wpcleaner.toolforge.org/";
117 downloadPage = "https://github.com/WPCleaner/wpcleaner";
118 license = lib.licenses.asl20;
119 mainProgram = "wpcleaner";
120 platforms = lib.platforms.all;
121 maintainers = with lib.maintainers; [ jeancaspar ];
122 };
123}