51 lines
1.2 KiB
Nix
51 lines
1.2 KiB
Nix
{ lib, stdenv, callPackage, clojure, jre, writeTextDir, writeShellScript, toEDN
|
|
}:
|
|
{ src, name, group, version, clj-deps, src-paths, build-tools-jar, ... }:
|
|
|
|
with lib;
|
|
let
|
|
build-tools-deps = writeTextDir "deps.edn" (toEDN {
|
|
aliases.build = {
|
|
ns-default = "'build";
|
|
extra-deps."'io.github.clojure/tools.build"."local/root" =
|
|
"${build-tools-jar}";
|
|
};
|
|
});
|
|
|
|
classpath = clj-deps.makeClasspaths { };
|
|
|
|
full-name = "${name}-${version}-standalone.jar";
|
|
|
|
target = "$TEMP/target";
|
|
|
|
build-script = writeShellScript "create-uberjar.sh" ''
|
|
HOME=$TEMP/home
|
|
mkdir -p $HOME
|
|
mkdir -p ${target}
|
|
|
|
clojure \
|
|
-Scp .:${build-tools-jar}:${classpath} \
|
|
-Sdeps ${build-tools-deps} \
|
|
-X:build \
|
|
lib-uberjar \
|
|
:project ${group}/${name} \
|
|
:version ${version} \
|
|
:src-dirs ${concatStringsSep "," src-paths} \
|
|
:target ${target}
|
|
'';
|
|
|
|
in stdenv.mkDerivation {
|
|
name = full-name;
|
|
|
|
src = src;
|
|
|
|
nativeBuildInputs = [ clojure jre ];
|
|
buildInputs = (map (x: x.paths) clj-deps.packages);
|
|
|
|
buildPhase = "${build-script}";
|
|
|
|
installPhase = ''
|
|
mv ${target}/${name}-${version}-standalone.jar $out
|
|
'';
|
|
}
|