build.tools.nix/mkClojureLib.nix

54 lines
1.1 KiB
Nix

{ lib, stdenv, callPackage, clojure, build-tools-jar, writeText }:
{ src, name, group, version, clj-deps, src-paths }:
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}"
}
}
}
}
}
'';
classpath = clj-deps.makeClasspaths { };
full-name = "${group}-${name}-${version}-standalone.jar";
target = "$TEMP/target";
in stdenv.mkDerivation {
name = name;
src = src;
nativeBuildInputs = [ clojure ];
buildInputs = (map (x: x.paths) clj-deps.packages);
buildPhase = ''
HOME=$TEMP/home
mkdir -p $HOME
mkdir -p ${target}
clojure \
-Scp .:${build-tools-jar}:${classpath} \
-Sdeps ${build-tools-deps} \
-T:build \
lib-uberjar \
:project ${group}/${name} \
:version ${version} \
:srcs ${concatStringsSep "," src-paths} \
:target ${target}
'';
installPhase = ''
mv ${target}/${name}-${version}-standalone.jar $out
'';
}