initial commit
This commit is contained in:
38
nix/dbuild.nix
Normal file
38
nix/dbuild.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{ lib, stdenv, buildMavenRepositoryFromLockFile
|
||||
, makeWrapper, maven, jdk11_headless
|
||||
, nix-gitignore
|
||||
}:
|
||||
|
||||
|
||||
let
|
||||
mavenRepository = buildMavenRepositoryFromLockFile { file = ./mvn2nix-lock.json; };
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "dBuild";
|
||||
version = "0.0.1";
|
||||
name = "${pname}-${version}";
|
||||
src = nix-gitignore.gitignoreSource [ "*.nix" ] ./..;
|
||||
|
||||
nativeBuildInputs = [ jdk11_headless maven makeWrapper ];
|
||||
buildPhase = ''
|
||||
echo "Building with maven repository ${mavenRepository}"
|
||||
mvn package --offline -Dmaven.repo.local=${mavenRepository}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
# create the bin directory
|
||||
mkdir -p $out/bin
|
||||
|
||||
# create a symbolic link for the lib directory
|
||||
ln -s ${mavenRepository} $out/lib
|
||||
|
||||
# copy out the JAR
|
||||
# Maven already setup the classpath to use m2 repository layout
|
||||
# with the prefix of lib/
|
||||
cp target/${name}.jar $out/
|
||||
|
||||
# create a wrapper that will automatically set the classpath
|
||||
# this should be the paths from the dependency derivation
|
||||
makeWrapper ${jdk11_headless}/bin/java $out/bin/${pname} \
|
||||
--add-flags "-jar $out/${name}.jar"
|
||||
'';
|
||||
}
|
||||
1249
nix/mvn2nix-lock.json
Normal file
1249
nix/mvn2nix-lock.json
Normal file
File diff suppressed because it is too large
Load Diff
3
nix/overlay.nix
Normal file
3
nix/overlay.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
final: prev: {
|
||||
dbuild = final.callPackage ./dbuild.nix { };
|
||||
}
|
||||
Reference in New Issue
Block a user