forked from cuplv/cuanto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
60 lines (52 loc) · 1.52 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
{ stdenv, sbt, z3, jdk }:
let
# If we're using Linux openjdk, there is an option that removes lots
# of unneeded extra dependencies.
jdk' =
if stdenv.isLinux
then jdk.override {minimal = true;}
else jdk;
jarsPath = varName: pkgs: stdenv.mkDerivation {
name = "jarsPath-${varName}";
src = ./.;
buildInputs = [jdk'] ++ pkgs;
propagatedBuildInputs = pkgs;
installPhase = ''
# Create CLASSPATH at build-time
mkdir $out
echo $CLASSPATH > $out/${varName}
# Export build-time CLASSPATH at run-time
mkdir -p $out/nix-support
cat <<EOF > $out/nix-support/setup-hook
export ${varName}=`cat $out/${varName}`
EOF
'';
};
# This function takes a list of packages and produces a new package
# which sets $CUANTO_CLASSPATH to include the jars of all the input
# packages. In this project, `sbt` is configured to load external
# unmanaged jars from $CUANTO_CLASSPATH only, so system-installed jars
# must use this function to be found.
#
# Example usage:
# ...
# buildInputs = [
# sbt z3 (cuantoClasspath [japron])
# ];
# ...
#
# Note that the packages given to `cuantoClasspath` are *propagated*,
# so in the above example, the non-classpath parts of `japron` are
# available to outer build just as they would have if
# `cuantoClasspath` was not used. You don't have to repeat it in the
# "top level" of `buildInputs`.
cuantoClasspath = jarsPath "CUANTO_CLASSPATH";
in
stdenv.mkDerivation rec {
name = "cuanto-${version}";
version = "dev";
src = ./.;
buildInputs = [
sbt z3
];
}