nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchgit,
5 ant,
6 jdk,
7 jre,
8 xmlstarlet,
9 makeWrapper,
10 stripJavaArchivesHook,
11}:
12
13stdenv.mkDerivation (finalAttrs: {
14 pname = "jedit";
15 version = "5.7.0";
16
17 src = fetchgit {
18 url = "https://git.code.sf.net/p/jedit/jEdit";
19 tag = "v${finalAttrs.version}";
20 hash = "sha256-Q2uarFMWXTWuJ0brw1PNS/vKWUa9gOTpD6Fumn0wMoI=";
21 };
22
23 ivyDeps = stdenv.mkDerivation {
24 name = "${finalAttrs.pname}-${finalAttrs.version}-ivy-deps";
25 inherit (finalAttrs) src;
26
27 nativeBuildInputs = [
28 ant
29 jdk
30 xmlstarlet
31 ];
32
33 # set defaultCacheDir to something that can exist
34 # this directory won't get copied, but needs to be set properly
35 configurePhase = ''
36 runHook preConfigure
37
38 xmlstarlet ed --subnode /ivysettings -t elem -n caches ivysettings.xml \
39 | xmlstarlet ed --insert /ivysettings/caches -t attr -n defaultCacheDir -v "$(pwd)/ivy-cache" \
40 > ivysettings.xml.tmp
41 mv ivysettings.xml.tmp ivysettings.xml
42
43 runHook postConfigure
44 '';
45
46 buildPhase = ''
47 runHook preBuild
48 ant retrieve
49 runHook postBuild
50 '';
51
52 installPhase = ''
53 runHook preInstall
54 mkdir -p $out/lib
55 cp -r lib/* $out/lib
56 runHook postInstall
57 '';
58
59 outputHashMode = "recursive";
60 outputHashAlgo = "sha256";
61 outputHash = "sha256-NGSBGB7q0HpOpajJV68K0rqCOqFYNrZHsnUHW+1GSLs=";
62 };
63
64 # ignore a test failing because of the build environment
65 postPatch = ''
66 substituteInPlace test/org/gjt/sp/jedit/MiscUtilitiesTest.java \
67 --replace-fail "public class MiscUtilitiesTest" "@org.junit.Ignore public class MiscUtilitiesTest"
68 '';
69
70 nativeBuildInputs = [
71 ant
72 jdk
73 makeWrapper
74 stripJavaArchivesHook
75 ];
76
77 buildPhase = ''
78 runHook preBuild
79 ln -s ${finalAttrs.ivyDeps}/lib ./lib
80 ant build -Divy.done=true
81 runHook postBuild
82 '';
83
84 installPhase = ''
85 runHook preInstall
86
87 mkdir -p $out/share/jEdit
88 cp -r build/jedit.jar doc keymaps macros modes startup $out/share/jEdit
89
90 install -Dm644 icons/jedit-icon48.png $out/share/icons/hicolor/48x48/apps/jedit.png
91 install -Dm644 package-files/linux/deb/jedit.desktop -t $out/share/applications
92
93 sed -i $out/share/applications/jedit.desktop \
94 -e "s|Icon=.*|Icon=jedit|g" \
95 -e "s|Exec=.*|Exec=jedit|g"
96
97 install -Dm755 package-files/linux/jedit -t $out/bin
98 substituteInPlace $out/bin/jedit \
99 --replace-fail "/usr/share/jEdit/@jar.filename@" "$out/share/jEdit/jedit.jar"
100
101 wrapProgram $out/bin/jedit --set JAVA_HOME ${jre}
102
103 runHook postInstall
104 '';
105
106 meta = {
107 changelog = "https://sourceforge.net/p/jedit/jEdit/ci/v${finalAttrs.version}/tree/doc/CHANGES.txt";
108 description = "Programmer's text editor written in Java";
109 homepage = "https://www.jedit.org";
110 license = lib.licenses.gpl2Only;
111 mainProgram = "jedit";
112 maintainers = with lib.maintainers; [ tomasajt ];
113 platforms = lib.platforms.unix;
114 sourceProvenance = with lib.sourceTypes; [
115 fromSource
116 binaryBytecode # ivyDeps contains .jar dependencies
117 ];
118 };
119})