40 lines
976 B
Nix
40 lines
976 B
Nix
{ pkgs ? import <nixpkgs> {}, ... }:
|
|
|
|
|
|
let
|
|
cljdeps = pkgs.callPackage ./deps.nix {};
|
|
classpath = cljdeps.makeClasspaths {};
|
|
exec-name = "worther";
|
|
main-class = "worther.core";
|
|
manifest = pkgs.writeText "${exec-name}-MANIFEST.MF" ''
|
|
Manifest-Version: 1.0
|
|
Main-Class: ${main-class}
|
|
|
|
'';
|
|
|
|
in pkgs.stdenv.mkDerivation {
|
|
name = exec-name;
|
|
|
|
nativeBuildInputs = with pkgs; [ jre makeWrapper ];
|
|
|
|
buildInputs = map (x: x.paths) cljdeps.packages;
|
|
|
|
src = ./src;
|
|
|
|
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
|
|
|
|
buildPhase = ''
|
|
mkdir classes
|
|
java -cp .:${classpath} clojure.main -e "(compile '${main-class})"
|
|
jar cmf ${manifest} out.jar -C classes worther
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/bin
|
|
mkdir -p $out/share/java
|
|
cp out.jar $out/share/java/${exec-name}.jar
|
|
makeWrapper ${pkgs.jdk}/bin/java $out/bin/${exec-name} \
|
|
--add-flags "-cp ${classpath}:$out/share/java/${exec-name}.jar ${main-class}"
|
|
'';
|
|
}
|