1{ lib, stdenv, fetchurl }:
2{ version
3, artifactId
4, groupId
5, sha512
6, type ? "jar"
7, suffix ? ""
8, sourceProvenance ? (if type == "jar" then [ lib.sourceTypes.binaryBytecode ] else [])
9}:
10
11let
12 m2Path = "${builtins.replaceStrings ["."] ["/"] groupId}/${artifactId}/${version}";
13 m2File = "${artifactId}-${version}${suffix}.${type}";
14 src = fetchurl {
15 inherit sha512;
16 url = "mirror://maven/${m2Path}/${m2File}";
17 };
18in stdenv.mkDerivation {
19 inherit version m2Path m2File src;
20 pname = artifactId;
21
22 dontUnpack = true;
23
24 installPhase = ''
25 mkdir -p $out/m2/$m2Path
26 cp $src $out/m2/$m2Path/$m2File
27 '';
28
29 meta.sourceProvenance = sourceProvenance;
30}