mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 15:30:38 -05:00
52 lines
1.4 KiB
Nix
52 lines
1.4 KiB
Nix
# This file is generated by gradle2nix.
|
|
|
|
{ stdenvNoCC, lib, buildEnv, fetchurl }:
|
|
|
|
{ path, env, repositories, artifacts }@args:
|
|
|
|
let
|
|
mkPath = artifact: with artifact; lib.concatStringsSep "/" [
|
|
(lib.replaceChars ["."] ["/"] artifact.groupId)
|
|
artifact.artifactId
|
|
artifact.version
|
|
];
|
|
|
|
mkFilename = artifact: with artifact;
|
|
"${artifactId}-${version}${lib.optionalString (classifier != "") "-${classifier}"}.${extension}";
|
|
|
|
mkArtifactUrl = base: artifact:
|
|
"${lib.removeSuffix "/" base}/${mkPath artifact}/${mkFilename artifact}";
|
|
|
|
fetchArtifact = artifact:
|
|
let
|
|
artifactPath = mkPath artifact;
|
|
artifactName = mkFilename artifact;
|
|
in stdenvNoCC.mkDerivation rec {
|
|
name = with artifact; lib.concatStrings [
|
|
(lib.replaceChars ["."] ["_"] groupId) "-"
|
|
(lib.replaceChars ["."] ["_"] artifactId) "-"
|
|
version
|
|
(lib.optionalString (classifier != "") "-${classifier}")
|
|
"-" extension
|
|
];
|
|
|
|
src = fetchurl {
|
|
name = mkFilename artifact;
|
|
urls = map (url: mkArtifactUrl url artifact) repositories;
|
|
inherit (artifact) sha256;
|
|
};
|
|
|
|
phases = "installPhase fixupPhase";
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/${artifactPath}
|
|
ln -s ${src} $out/${artifactPath}/${artifactName}
|
|
'';
|
|
};
|
|
|
|
in
|
|
buildEnv {
|
|
name = "gradle-env-${builtins.replaceStrings [":"] ["-"] path}-${env}";
|
|
paths = map fetchArtifact artifacts;
|
|
}
|