mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 23:40:37 -05:00
First stab
This commit is contained in:
51
gradle-env.nix
Normal file
51
gradle-env.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
# 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;
|
||||
}
|
||||
Reference in New Issue
Block a user