forked from just-defi/just-link
-
Notifications
You must be signed in to change notification settings - Fork 25
/
default.nix
93 lines (76 loc) · 3.37 KB
/
default.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
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ stdenv, callPackage, openjdk8, gradle_6, makeWrapper, tree, system, perl, ...
}:
with stdenv;
let
deps = mkDerivation {
name = "depppps";
version = "0.0.6";
nativeBuildInputs =
[ openjdk8 (gradle_6.override { java = openjdk8; }) perl ];
src = ./.;
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d);
gradle --no-daemon resolveDependencies;
'';
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
installPhase = ''
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/maven/$x/$3/$4/$5" #e' \
| sh
rm -rf $out/maven/org/apache/httpcomponents/httpasyncclient/4.1.1
rm -rf $out/maven/org/slf4j/jcl-over-slf4j/1.7.25
rm -rf $out/maven/org/hamcrest/hamcrest-core/1.3
rm -rf $out/maven/junit/junit/4.12
rm -rf $out/maven/org/flywaydb/flyway-core/6.3.3
rm -rf $out/maven/org/apache/commons/commons-lang3/3.9
rm -rf $out/maven/io/dropwizard/metrics/metrics-core/3.1.2
rm -rf $out/maven/org/aspectj/aspectjrt/1.8.13
rm -rf $out/maven/org/aspectj/aspectjweaver/1.8.13
rm -rf $out/maven/org/aspectj/aspectjtools/1.8.13
rm -rf $out/maven/io/netty/netty-buffer/4.1.48.Final
rm -rf $out/maven/io/netty/netty-codec/4.1.48.Final
rm -rf $out/maven/io/netty/netty-codec-http/4.1.48.Final
rm -rf $out/maven/io/netty/netty-codec-http2/4.1.48.Final
rm -rf $out/maven/io/netty/netty-codec-socks/4.1.48.Final
rm -rf $out/maven/io/netty/netty-common/4.1.48.Final
rm -rf $out/maven/io/netty/netty-handler/4.1.48.Final
rm -rf $out/maven/io/netty/netty-handler-proxy/4.1.48.Final
rm -rf $out/maven/io/netty/netty-parent/4.1.48.Final
rm -rf $out/maven/io/netty/netty-transport/4.1.48.Final
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-7kJTNEcKby9JJN5Q4lrdguvia0MynYhdGNGwgSNY7Ds=";
};
backend = mkDerivation {
name = "winklink";
src = ./.;
buildInputs = [ openjdk8 gradle_6 makeWrapper perl ];
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
export HOME="$NIX_BUILD_TOP/home"
export JAVA_TOOL_OPTIONS="-Duser.home='$HOME'"
mkdir -p .m2/repository/
cp -r ${deps}/maven/* .m2/repository
export M2_HOME=.m2
ls ${deps}
# point to offline repo
sed -i "s#mavenLocal()#mavenLocal();maven { url '${deps}/maven' }#g" build.gradle
# point to offline repo
sed -i "s#mavenLocal()#mavenLocal();maven { url '${deps}/maven' }#g" node/build.gradle
# point to offline repo
sed -i "s#mavenLocal()#mavenLocal();maven { url '${deps}/maven' }#g" settings.gradle
gradle --offline --info --no-daemon build -x test
'';
installPhase = ''
mkdir -p $out/lib
mkdir -p $out/bin
cp node/build/libs/*.jar $out/lib
makeWrapper ${openjdk8}/bin/java $out/bin/winklink-node --add-flags "-jar $out/lib/node-v1.0.jar"
'';
};
frontend = (callPackage ./node/webapp/default.nix { }).shell;
in frontend