Skip to content

Commit

Permalink
taler libeufin: init at 0.9.3-dev.33
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrosame committed Dec 23, 2023
1 parent 2b2917b commit aea8ec1
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 0 deletions.
130 changes: 130 additions & 0 deletions pkgs/by-name/libeufin/deps/artifacts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-call-logging-jvm/2.3.6/ktor-server-call-logging-jvm-2.3.6.jar";
sha256 = "sha256-2+0JE/yoKag8d8N2sfqRatXffpGn2pfvK/NINMgp4CQ=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-cors-jvm/2.3.6/ktor-server-cors-jvm-2.3.6.jar";
sha256 = "sha256-XLMYHGDhdKZp4D66H4F+IXpgvEtPvzfiTmK9fRVdsQw=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-content-negotiation-jvm/2.3.6/ktor-server-content-negotiation-jvm-2.3.6.jar";
sha256 = "sha256-8MKiz4jyiUBSJ0tN3ADbZk2pvDmRjuVxm8jVyepIcVk=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-status-pages-jvm/2.3.6/ktor-server-status-pages-jvm-2.3.6.jar";
sha256 = "sha256-t+5eJAjoPi5+SiErANGoUiYV4JPZaUSINI/mk3rez5g=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-test-host-jvm/2.3.6/ktor-server-test-host-jvm-2.3.6.jar";
sha256 = "sha256-hrtQZChQiW2Io+VGGv3CcmTMKn5DR9i/CCSum8brQrQ=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-host-common-jvm/2.3.6/ktor-server-host-common-jvm-2.3.6.jar";
sha256 = "sha256-q8FRK1MwK4/J3I2fDKGYZrXjjYduo9gVCF7uqvfal4s=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-core-jvm/2.3.6/ktor-server-core-jvm-2.3.6.jar";
sha256 = "sha256-UNG4jOCN5nOn4gvJ+LCU+MSi4lPTh8vjdiqIgwf8Uz0=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-server-netty-jvm/2.3.6/ktor-server-netty-jvm-2.3.6.jar";
sha256 = "sha256-mpZbiQdcyn15humQi8qUBvK/nySUIQRJTj8i1YahFMI=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-serialization-kotlinx-json-jvm/2.3.6/ktor-serialization-kotlinx-json-jvm-2.3.6.jar";
sha256 = "sha256-E9rhtl841ROH5xaro1/EQ/MDipJkpB5KmJI8L8/ssAQ=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-serialization-kotlinx-json/2.3.6/ktor-serialization-kotlinx-json-2.3.6.jar";
sha256 = "sha256-yV9zY97ZcooTqT7WWOl1IRtBhPC4+cF8Kbz3WqM+sBA=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-client-cio-jvm/2.3.6/ktor-client-cio-jvm-2.3.6.jar";
sha256 = "sha256-HRkrjyUR+7vBmmALl2AAW/JnF6I2FpB4ARqUREXL8Zk=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-client-core-jvm/2.3.6/ktor-client-core-jvm-2.3.6.jar";
sha256 = "sha256-F8RqVqEoxU3JiRYL1th7UQHoxkuAGpG05DMuwpmw68s=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-websocket-serialization-jvm/2.3.6/ktor-websocket-serialization-jvm-2.3.6.jar";
sha256 = "sha256-UHi9+14OjX/t0PDp0gAfWQkJfyGf6IbmHUoX+d57VG4=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-events-jvm/2.3.6/ktor-events-jvm-2.3.6.jar";
sha256 = "sha256-0RummxrxV7hz4nNHnrKRz4zY/R0Efi0z4w4+rO1RlFI=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-websockets-jvm/2.3.6/ktor-websockets-jvm-2.3.6.jar";
sha256 = "sha256-vTxhH8EYZc5QqoPKx3hApDVNqCevbT+GJHKrLseTYRU=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-http-cio-jvm/2.3.6/ktor-http-cio-jvm-2.3.6.jar";
sha256 = "sha256-rbVL7tt2UPJV+7wzxklpnxBBZAsKek3B2TJtGL+n4WE=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-network-tls-jvm/2.3.6/ktor-network-tls-jvm-2.3.6.jar";
sha256 = "sha256-elp6iWFcH9voEKN3BywJyRxa5x7+PfE4QaNTAFh04mU=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-http-jvm/2.3.6/ktor-http-jvm-2.3.6.jar";
sha256 = "sha256-N0avjwFDE7/7BwENwZ/xqRXW7Sb2ww+kpIiH8AGAe0Q=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-test-dispatcher-jvm/2.3.6/ktor-test-dispatcher-jvm-2.3.6.jar";
sha256 = "sha256-C8nubEVHNSgcVzgHL9bU5tq7nHmHqqokDwltUuZ4SDo=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-network-jvm/2.3.6/ktor-network-jvm-2.3.6.jar";
sha256 = "sha256-GzefLtjx6jj2U4yf0EaMY1Sv/Z70uLU38bAv+Ma9/zE=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-utils-jvm/2.3.6/ktor-utils-jvm-2.3.6.jar";
sha256 = "sha256-AI2ez6gSg9XvoGyO8zlrGSvLrBcETG+NbzGeMP4fyyM=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-io-jvm/2.3.6/ktor-io-jvm-2.3.6.jar";
sha256 = "sha256-782fRFGsgA6eQALr11j2Yn/0/oTLnoCoxiIgkE0kQCE=";
}
{
url = "https://repo.maven.apache.org/maven2/io/ktor/ktor-client-apache-jvm/2.3.6/ktor-client-apache-jvm-2.3.6.jar";
sha256 = "sha256-Ww2uKnJDUqSslSjsKYaoHdPMoJcCgJlZ20YsN8qm8vg=";
}
{
url = "https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.8.20/kotlin-stdlib-jdk7-1.8.20.jar";
sha256 = "sha256-rx7EDDuVGv3MDCoBc8e4F2PFKBwtW6+/CoVEokxdzAw=";
}
{
url = "https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.8.20/kotlin-stdlib-jdk8-1.8.20.jar";
sha256 = "sha256-45i2eXdiJxi/GP+ZtznH2doGDzP7RYouJSAyIcFq8BA=";
}
{
url = "https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-slf4j/1.7.1/kotlinx-coroutines-slf4j-1.7.1.jar";
sha256 = "sha256-+7QMp+VaeAF/6siXGAvmT1YqLreBxqP2ybsv+I2SIj8=";
}
{
url = "https://repo.maven.apache.org/maven2/com/github/ajalt/clikt/clikt-jvm/4.2.1/clikt-jvm-4.2.1.jar";
sha256 = "sha256-799fw436KVOi4Zlc7LoNwoGqs1OF1ZX+BCFVFYxhZH8=";
}
{
url = "https://repo.maven.apache.org/maven2/com/github/ajalt/mordant/mordant-jvm/2.2.0/mordant-jvm-2.2.0.jar";
sha256 = "sha256-L6WeW4GvzHG2q2EosnZ2/8YR0KPBguvA5DezZmq1YgE=";
}
{
url = "https://repo.maven.apache.org/maven2/com/github/ajalt/colormath/colormath-jvm/3.3.1/colormath-jvm-3.3.1.jar";
sha256 = "sha256-JhMoNBXi4SZhaX3HKVra2g9g7Bfs/K8+8cTuD9t4iRM=";
}
{
url = "https://repo.maven.apache.org/maven2/org/jetbrains/markdown/0.5.2/markdown-0.5.2.jar";
sha256 = "sha256-HGsba7nOgwSLhkiZCsHTQnv6z+vI5Y4y7pBD3dDcOio=";
}
{
url = "https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.10/kotlin-stdlib-common-1.9.10.jar";
sha256 = "sha256-zeM0G6GKK6JisLfPbFWyDJDo1DTkLJoT5qP3cNuWWog=";
}
{
url = "https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/atomicfu/0.19.0/atomicfu-0.19.0.jar";
sha256 = "sha256-BAJqx3zvZEde/enCOFVT8wRc2YoMmTS6u8wX293t9Xc=";
}
]
56 changes: 56 additions & 0 deletions pkgs/by-name/libeufin/deps/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# There are lots of manual interaction here. Once https://github.com/NixOS/nixpkgs/pull/272380
# lands, we could look into using gradleHook for this package.
{
pname,
version,
src,
patches,
gradle,
fetchurl,
stdenv,
fetchgit,
writeText,
symlinkJoin,
perl,
callPackage,
}: let
nameprefix = "${pname}-${version}";
# Pre-download deps into derivation
deps = stdenv.mkDerivation {
name = "${nameprefix}-auto-deps";
inherit patches src version;

nativeBuildInputs = [gradle perl];
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --no-daemon assemble
'';
# Mavenize paths: each part of the namespace is a folder.
installPhase = ''
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
# Work around naming issues. Remove "-gradleXX" from filename.
mv $out/org/jetbrains/kotlin/kotlin-gradle-plugin/1.9.20/kotlin-gradle-plugin-1.9.20{-gradle81,}.jar
mv $out/org/jetbrains/kotlin/kotlin-serialization/1.9.20/kotlin-serialization-1.9.20{-gradle81,}.jar
cp -r $GRADLE_USER_HOME/caches $out
'';
outputHashMode = "recursive";
outputHash = "sha256-3Ggu654HXqRfST8deyd7D3NwNYBR6pZuSlY/sVgspAY=";
outputHashAlgo = "sha256";
};
# For dependencies that are still missing, we fetch them individually from Maven
artifactsMeta = import ./artifacts.nix;
fetchArtifact = x:
callPackage ./fetch-maven-artifact.nix {
inherit (x) url sha256;
inherit nameprefix;
};
in
# Merge the offlibe Maven repo folders into a unique derivation
symlinkJoin {
name = "${nameprefix}-offline-deps";
paths = [deps] ++ (map fetchArtifact artifactsMeta);
}
51 changes: 51 additions & 0 deletions pkgs/by-name/libeufin/deps/fetch-maven-artifact.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Fetch a jar from Maven repo and provide it in an offline Maven repository format.
{
url,
sha256,
nameprefix,
stdenv,
fetchurl,
lib,
}: let
inherit (lib.strings) hasPrefix hasSuffix removePrefix removeSuffix;
inherit (lib) splitString throwIfNot;
inherit (lib.lists) init last;
inherit (builtins) concatStringsSep;

urlPrefix = "https://repo.maven.apache.org/maven2/";
artifactSuffix = ".jar";

noPrefix =
throwIfNot
(hasPrefix urlPrefix url)
"Only Maven URLs that start with '${urlPrefix}' can be fetched."
(removePrefix urlPrefix url);
noSuffix =
throwIfNot
(hasSuffix artifactSuffix noPrefix)
"Only '${artifactSuffix}' artifacts can be fetched."
(removeSuffix artifactSuffix noPrefix);
splitted = splitString "/" noSuffix;
artifactPath = init splitted;
artifactName = last splitted;
in
stdenv.mkDerivation {
name = "${nameprefix}-dep-${artifactName}";

src = fetchurl {
inherit url sha256;
name = "${artifactName}.jar";
};

phases = ["installPhase"];

installPhase = let
# The namespace of the artifact name constitutes a folder path
# in the offline Maven repo format.
artifactPathString = concatStringsSep "/" artifactPath;
in ''
mkdir -p $out/${artifactPathString}
install -Dm444 $src $out/${artifactPathString}
mv $out/${artifactPathString}/*.jar $out/${artifactPathString}/${artifactName}.jar;
'';
}
22 changes: 22 additions & 0 deletions pkgs/by-name/libeufin/init.gradle.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
clear()
maven { url '__DEPS_PATH__/'; metadataSources {mavenPom(); artifact()} }
}
}
repositories {
clear()
maven { url '__DEPS_PATH__/'; metadataSources {mavenPom(); artifact()} }
}
}
}

settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
maven { url '__DEPS_PATH__/'; metadataSources {mavenPom(); artifact()} }
}
}
}
84 changes: 84 additions & 0 deletions pkgs/by-name/libeufin/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
lib,
callPackage,
stdenv,
fetchgit,
python3,
jdk17_headless,
gradle-packages,
perl,
writeText,
git,
}: let
pname = "libeufin";
version = "0.9.3-dev.33";
src = fetchgit {
url = "https://git.taler.net/libeufin.git/";
rev = "v${version}";
hash = "sha256-BGxlmK4u914byOt/4FGnw5wGZtxhQmfhQHSJY+C8YqY=";
fetchSubmodules = true;
leaveDotGit = true; # Required for correct submodule fetching
# Delete .git folder for reproducibility (otherwise, the hash changes unexpectedly after fetching submodules)
# Save the HEAD short commit hash in a file so it can be retrieved later for versioning.
postFetch = ''
(
cd $out
git rev-parse --short HEAD > ./util/src/main/resources/HEAD.txt
rm -rf .git
)
'';
};
patches = [
# The .git folder had to be deleted. Read hash from file instead of using the git command.
./read-HEAD-hash-from-file.patch
# Gradle projects provide a .module metadata file as artifact. This artifact is used by gradle
# to download dependencies to the cache when needed, but do not provide the jar for the
# offline installation for our build phase. Since we make an offline Maven repo, we have to
# substitute the gradle deps for their maven counterpart to retrieve the .jar artifacts.
./use-maven-deps.patch
];

gradle = callPackage gradle-packages.gradle_8 {java = jdk17_headless;};

# Pre-download deps into a derivation
deps = callPackage ./deps {inherit gradle patches pname src version;};

# init.gradle points to the offline maven repository created in the deps derivation
gradleInit = writeText "init.gradle" (
builtins.replaceStrings
["__DEPS_PATH__"]
["${deps}"]
(builtins.readFile ./init.gradle.template)
);
in
stdenv.mkDerivation {
inherit patches pname src version;

preConfigure = ''
cp build-system/taler-build-scripts/configure ./configure
'';

# Tell gradle to use the offline Maven repository
buildPhase = ''
gradle bank:installShadowDist nexus:installShadowDist --offline --no-daemon --init-script ${gradleInit}
'';

installPhase = ''
make install-nobuild
'';

nativeBuildInputs = [
python3
jdk17_headless
gradle
];

# Tests need a database to run.
doCheck = false;

meta = {
homepage = "https://git.taler.net/libeufin.git/";
description = "Integration and sandbox testing for FinTech APIs and data formats.";
license = lib.licenses.agpl3Plus;
};
}
24 changes: 24 additions & 0 deletions pkgs/by-name/libeufin/read-HEAD-hash-from-file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/build.gradle b/build.gradle
index 632f7c52..9cd52a1e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -40,9 +40,11 @@ idea {
}

task versionFile() {
+ // At this point, .git has been deleted
def stdout = new ByteArrayOutputStream()
exec {
- commandLine 'git', 'rev-parse', '--short', 'HEAD'
+ // Generated during src.postFetch
+ commandLine 'cat', "${projectDir}/util/src/main/resources/HEAD.txt"
standardOutput = stdout
}
def gitHash = stdout.toString().trim()
@@ -59,4 +61,4 @@ task libeufinVersion {

classes {
dependsOn versionFile
-}
+}
\ No newline at end of file
Loading

0 comments on commit aea8ec1

Please sign in to comment.