From 38ad37822813692de906c87f47801370ac1bcf1a Mon Sep 17 00:00:00 2001 From: hlolli Date: Sat, 5 Dec 2020 18:56:46 +0100 Subject: add classifier as an argument --- pkgs/build-support/fetchmavenartifact/default.nix | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'pkgs/build-support/fetchmavenartifact') diff --git a/pkgs/build-support/fetchmavenartifact/default.nix b/pkgs/build-support/fetchmavenartifact/default.nix index 2058600960a..42ad7603a8f 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. -- cgit 1.4.1