2022-05-29 10:34:35 -07:00
|
|
|
{ lib, stdenv, callPackage, jre, clojure, build-tools-jar, writeScript
|
2022-05-29 10:04:07 -07:00
|
|
|
, writeText }:
|
|
|
|
{ src, name, group, version, clj-deps, src-paths }:
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
build-tools-deps = writeText "deps.edn" ''
|
|
|
|
{ :aliases
|
|
|
|
{ :build
|
|
|
|
{ :ns-default build
|
|
|
|
:replace-deps {
|
|
|
|
io.github.clojure/tools.build {
|
|
|
|
:local/root "${build-tools-jar}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
deps = callPackage clj-deps { };
|
2022-05-29 10:35:25 -07:00
|
|
|
classpath = deps.makeClasspaths { };
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
full-name = "${group}-${name}-${version}-standalone.jar";
|
|
|
|
|
|
|
|
target = "$TEMP/target";
|
|
|
|
|
2022-05-29 09:45:16 -07:00
|
|
|
in stdenv.mkDerivation {
|
2022-05-29 09:34:32 -07:00
|
|
|
name = name;
|
|
|
|
|
|
|
|
src = src;
|
|
|
|
|
2022-05-29 10:40:53 -07:00
|
|
|
nativeBuildInputs = [ jre clojure ];
|
|
|
|
buildInputs = (map (x: x.paths) deps.packages);
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
HOME=$TEMP/home
|
|
|
|
mkdir -p $HOME
|
|
|
|
mkdir -p ${target}
|
2022-05-29 10:34:35 -07:00
|
|
|
|
|
|
|
clojure \
|
2022-05-29 10:38:53 -07:00
|
|
|
-Scp ${classpath} \
|
2022-05-29 10:34:35 -07:00
|
|
|
-Sdeps ${build-tools-deps} \
|
|
|
|
-T:build \
|
|
|
|
lib-uberjar \
|
|
|
|
:project ${group}/${name} \
|
|
|
|
:version ${version}" \
|
2022-05-29 10:38:53 -07:00
|
|
|
:srcs ${concatStringsSep "," src-paths}" \
|
2022-05-29 10:34:35 -07:00
|
|
|
:target ${target}
|
2022-05-29 09:34:32 -07:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mv ${target}/${name}-${version}-standalone.jar $out
|
|
|
|
'';
|
|
|
|
}
|