2022-05-30 17:03:18 -07:00
|
|
|
{ lib, stdenv, callPackage, clojure, jre, build-tools-jar, writeTextDir
|
|
|
|
, writeShellScript, toEDN }:
|
2022-05-29 10:04:07 -07:00
|
|
|
{ src, name, group, version, clj-deps, src-paths }:
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
2022-05-29 22:57:25 -07:00
|
|
|
|
2022-05-30 16:46:55 -07:00
|
|
|
build-tools-deps = writeTextDir "deps.edn" (toEDN {
|
2022-05-30 16:09:14 -07:00
|
|
|
aliases.build = {
|
|
|
|
ns-build = "'build";
|
|
|
|
replace-deps."'io.github.clojure/tools.build"."local/root" =
|
|
|
|
"${build-tools-jar}";
|
|
|
|
};
|
2022-05-30 16:46:55 -07:00
|
|
|
});
|
2022-05-29 09:34:32 -07:00
|
|
|
|
2022-05-29 10:42:17 -07:00
|
|
|
classpath = clj-deps.makeClasspaths { };
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
full-name = "${group}-${name}-${version}-standalone.jar";
|
|
|
|
|
|
|
|
target = "$TEMP/target";
|
|
|
|
|
2022-05-30 17:36:27 -07:00
|
|
|
build-script = writeShellScript "create-uberjar.sh" ''
|
|
|
|
HOME=$TEMP/home
|
|
|
|
mkdir -p $HOME
|
|
|
|
mkdir -p ${target}
|
|
|
|
|
|
|
|
clojure \
|
|
|
|
-Scp .:${build-tools-jar}:${classpath} \
|
|
|
|
-Sdeps ${builtins.trace build-tools-deps build-tools-deps} \
|
|
|
|
-X:build \
|
|
|
|
lib-uberjar \
|
|
|
|
:project ${group}/${name} \
|
|
|
|
:version ${version} \
|
|
|
|
:srcs ${concatStringsSep "," src-paths} \
|
|
|
|
:target ${target}
|
|
|
|
'';
|
|
|
|
|
2022-05-29 09:45:16 -07:00
|
|
|
in stdenv.mkDerivation {
|
2022-05-30 17:36:27 -07:00
|
|
|
name = name;
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
src = src;
|
|
|
|
|
2022-05-30 16:54:45 -07:00
|
|
|
nativeBuildInputs = [ clojure jre ];
|
2022-05-29 10:42:17 -07:00
|
|
|
buildInputs = (map (x: x.paths) clj-deps.packages);
|
2022-05-29 09:34:32 -07:00
|
|
|
|
2022-05-30 17:37:00 -07:00
|
|
|
buildPhase = let script-call = "${build-script}";
|
2022-05-30 17:04:19 -07:00
|
|
|
in builtins.trace script-call script-call;
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mv ${target}/${name}-${version}-standalone.jar $out
|
|
|
|
'';
|
|
|
|
}
|