aboutsummaryrefslogtreecommitdiff
path: root/pkgs/build-support/fetchmavenartifact
diff options
context:
space:
mode:
authorhlolli <hlolli@gmail.com>2020-12-05 18:56:46 +0100
committerhlolli <hlolli@gmail.com>2020-12-05 18:56:46 +0100
commit38ad37822813692de906c87f47801370ac1bcf1a (patch)
tree752d39207a97295075d73f3d86edb0b46cd3dade /pkgs/build-support/fetchmavenartifact
parent49c789703ccb70acebfaec4388f543a9ad63520a (diff)
add classifier as an argument
Diffstat (limited to 'pkgs/build-support/fetchmavenartifact')
-rw-r--r--pkgs/build-support/fetchmavenartifact/default.nix23
1 files changed, 8 insertions, 15 deletions
diff --git a/pkgs/build-support/fetchmavenartifact/default.nix b/pkgs/build-support/fetchmavenartifact/default.nix
index 2058600960ae..42ad7603a8f7 100644
--- a/pkgs/build-support/fetchmavenartifact/default.nix
+++ b/pkgs/build-support/fetchmavenartifact/default.nix
@@ -17,6 +17,8 @@ args@
artifactId
, # Example: "4.3.6"
version
+, # Example: "jdk11"
+ classifier ? null
, # List of maven repositories from where to fetch the artifact.
# Example: [ http://oss.sonatype.org/content/repositories/public ].
repos ? defaultRepos
@@ -36,28 +38,19 @@ assert (repos != []) || (url != "") || (urls != []);
let
- classifierSplit =
- with stdenv.lib.strings;
- splitString "$" artifactId;
- artifactId_ = builtins.head classifierSplit;
- classifier =
- with stdenv.lib;
- if builtins.length classifierSplit > 1
- then concatStrings ["-" (builtins.elemAt classifierSplit 1)]
- else "";
name_ =
with stdenv.lib; concatStrings [
(replaceChars ["."] ["_"] groupId) "_"
- (replaceChars ["."] ["_"] artifactId_) "-"
+ (replaceChars ["."] ["_"] artifactId) "-"
version
];
mkJarUrl = repoUrl:
with stdenv.lib; concatStringsSep "/" [
(removeSuffix "/" repoUrl)
(replaceChars ["."] ["/"] groupId)
- artifactId_
+ artifactId
version
- "${artifactId_}-${version}${classifier}.jar"
+ "${artifactId}-${version}-${optionalString (!isNull classifier) "-${classifier}"}.jar"
];
urls_ =
if url != "" then [url]
@@ -65,8 +58,8 @@ let
else map mkJarUrl repos;
jar =
fetchurl (
- builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ]
- // { urls = urls_; name = "${name_}${classifier}.jar"; }
+ builtins.removeAttrs args ["groupId" "artifactId" "version" "classifier" "repos" "url" ]
+ // { urls = urls_; name = "${name_}.jar"; }
);
in
stdenv.mkDerivation {
@@ -76,7 +69,7 @@ in
# packages packages that mention this derivation in their buildInputs.
installPhase = ''
mkdir -p $out/share/java
- ln -s ${jar} $out/share/java/${artifactId_}-${version}${classifier}.jar
+ ln -s ${jar} $out/share/java/${artifactId}-${version}.jar
'';
# We also add a `jar` attribute that can be used to easily obtain the path
# to the downloaded jar file.