-
Notifications
You must be signed in to change notification settings - Fork 2
/
wrapper.nix
57 lines (45 loc) · 1.74 KB
/
wrapper.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
{ symlinkJoin, lib, makeWrapper, neo4j, jre, db-home
, auth-enabled ? false, plugins ? [ ] }:
symlinkJoin rec {
name = "${neo4j.name}-wrapper";
preferLocalBuild = true;
allowSubstitutes = false;
buildInputs = [ neo4j ] ++ plugins ++ [ makeWrapper ];
paths = [ neo4j ] ++ plugins;
setAuthentication = (if auth-enabled then
""
else ''
substituteInPlace "$conf" \
--replace '#dbms.security.auth_enabled=false' 'dbms.security.auth_enabled=false'
'');
unrestrictedPlugins = builtins.filter (p: p.unrestricted) plugins;
setUnrestrictedPlugins = (if (builtins.length unrestrictedPlugins) > 0 then ''
substituteInPlace "$conf" \
--replace "#dbms.security.procedures.unrestricted=my.extensions.example,my.procedures.*" \
"dbms.security.procedures.unrestricted=${
(builtins.concatStringsSep ","
(map (p: p.pname + ".*") unrestrictedPlugins))
}"
'' else
"");
postBuild = ''
for NEO4J_SCRIPT in neo4j neo4j-admin cypher-shell
do
rm "$out"/bin/$NEO4J_SCRIPT
makeWrapper "$out"/share/neo4j/bin/$NEO4J_SCRIPT \
"$out"/bin/$NEO4J_SCRIPT \
--set JAVA_HOME "${jre}" \
--set NEO4J_HOME "$out"/share/neo4j
done
conf=$out/share/neo4j/conf/neo4j.conf
origconf=$(readlink $conf)
rm $conf
cp $origconf $conf
substituteInPlace "$conf" \
--replace '#dbms.directories.logs=logs' "dbms.directories.logs=${db-home}/logs" \
--replace '#dbms.directories.run=run' "dbms.directories.run=${db-home}/run" \
--replace '#dbms.directories.data=data' "dbms.directories.data=${db-home}/data" \
runHook setAuthentication;
runHook setUnrestrictedPlugins;
'';
}