generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yacy.nix
118 lines (103 loc) · 2.61 KB
/
yacy.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, jre
, ant
, git
}:
stdenv.mkDerivation rec {
pname = "yacy";
# last stable release was in year 2016
version = "unstable-2022-11-22";
/*
# local source
src = ./src/yacy_search_server;
buildPhase = ''
# cleanup src, force rebuild
rm lib/yacycore.jar
ant clean
'';
*/
src = fetchFromGitHub {
owner = "yacy";
repo = "yacy_search_server";
# fix read-only applicationRoot
# https://github.com/yacy/yacy_search_server/pull/541
rev = "77958383cf2a5cb19eb24cda989db61d6197cbd4";
hash = "sha256-2ny+Hn1U7X7SwgZqUDYvAAYWaczW3cxW5wlf+io0QCs=";
};
# TODO fetch jar's separately
# TODO faster. currently takes 16 minutes
ivyCache = stdenv.mkDerivation {
name = "${pname}-${version}-deps";
inherit src;
nativeBuildInputs = [ jre ant ];
buildPhase = ''
ant resolve
'';
installPhase = ''
mkdir $out
cp -r ivy $out
cp -r lib $out
cp -r libt $out
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-UXIVnVm4jnVNOPqniXGhJcYdLIAxPDh3Ht82XTM/Xsw=";
};
# echo ivyCache = ${ivyCache}
postUnpack = ''
(
cd $sourceRoot
ls -l
cp -r ${ivyCache}/ivy .
chmod -R +w ivy
ln -v -s ${ivyCache}/lib/* lib/ || true
ln -v -s ${ivyCache}/libt/* libt/ || true
ls -l
)
'';
nativeBuildInputs = [ jre ant git makeWrapper ];
buildPhase = ''
# emulate <target name="resolve"
ivyResolvedPaths="$(
echo '<path id="compile.path">'
for f in lib/*.jar
do
f="$(readlink -f "$f")"
echo ' <pathelement location="'"$f"'" />'
done
echo '</path>'
echo '<path id="test.path">'
for f in libt/*.jar
do
f="$(readlink -f "$f")"
echo ' <pathelement location="'"$f"'" />'
done
echo '</path>'
)"
substituteInPlace build.xml \
--replace '</project>' "$ivyResolvedPaths</project>"
( set -x; cat build.xml ) # debug
ant -Dtarget-resolve-already-run=true compile
'';
# TODO checkPhase
installPhase = ''
mkdir -p $out/opt
cp -r . $out/opt/yacy
'';
# TODO create $out/bin/yacy
# TODO create nixos module: services.yacy
postFixup = ''
wrapProgram $out/opt/yacy/startYACY.sh \
--prefix PATH : ${lib.makeBinPath [ jre ]}
'';
meta = with lib; {
description = "Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance";
homepage = "https://github.com/yacy/yacy_search_server";
license = licenses.lgpl2Plus;
platforms = platforms.all;
maintainers = [ ];
};
}