2022-05-29 10:50:26 -07:00
|
|
|
{ lib, stdenv, callPackage, clojure, build-tools-jar, writeTextDir }:
|
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 10:49:44 -07:00
|
|
|
build-tools-deps = writeTextDir "deps.edn" ''
|
2022-05-29 09:34:32 -07:00
|
|
|
{ :aliases
|
|
|
|
{ :build
|
|
|
|
{ :ns-default build
|
|
|
|
:replace-deps {
|
|
|
|
io.github.clojure/tools.build {
|
|
|
|
:local/root "${build-tools-jar}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
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-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:42:17 -07:00
|
|
|
nativeBuildInputs = [ clojure ];
|
|
|
|
buildInputs = (map (x: x.paths) clj-deps.packages);
|
2022-05-29 09:34:32 -07:00
|
|
|
|
2022-05-29 10:46:20 -07:00
|
|
|
buildPhase = let
|
|
|
|
cmd = ''
|
|
|
|
HOME=$TEMP/home
|
2022-05-29 10:55:18 -07:00
|
|
|
BHOME=$TEMP/build-home
|
2022-05-29 10:46:20 -07:00
|
|
|
mkdir -p $HOME
|
|
|
|
mkdir -p ${target}
|
2022-05-29 10:55:18 -07:00
|
|
|
mkdir -p $BHOME
|
|
|
|
cp ${build-tools-deps} $BHOME/deps.edn
|
2022-05-29 10:46:20 -07:00
|
|
|
|
|
|
|
clojure \
|
2022-05-29 10:48:37 -07:00
|
|
|
-Scp .:${build-tools-jar}:${classpath} \
|
2022-05-29 10:55:18 -07:00
|
|
|
-Sdeps $BHOME/deps.edn \
|
2022-05-29 10:46:20 -07:00
|
|
|
-X:build \
|
|
|
|
lib-uberjar \
|
|
|
|
:project ${group}/${name} \
|
2022-05-29 10:48:37 -07:00
|
|
|
:version ${version} \
|
|
|
|
:srcs ${concatStringsSep "," src-paths} \
|
2022-05-29 10:46:20 -07:00
|
|
|
:target ${target}
|
|
|
|
'';
|
|
|
|
in builtins.trace cmd cmd;
|
2022-05-29 09:34:32 -07:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mv ${target}/${name}-${version}-standalone.jar $out
|
|
|
|
'';
|
|
|
|
}
|