evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / dy / dynamodb-local / package.nix
blob55258e1fe3fa22b3c25674285cc29d564be81c55
1 { lib
2 , stdenvNoCC
3 , fetchurl
4 , jdk_headless
5 , jre_minimal
6 , makeBinaryWrapper
7 , curl
8 , jq
9 , yq
10 , dynamodb-local
11 , testers
12 , common-updater-scripts
13 , writeShellScript
15 let
16   jre = jre_minimal.override {
17     modules = [
18       "java.logging"
19       "java.xml"
20       "java.desktop"
21       "java.management"
22       "java.naming"
23     ];
24     jdk = jdk_headless;
25   };
27 stdenvNoCC.mkDerivation (finalAttrs: {
28   pname = "dynamodb-local";
29   version = "2.5.2";
31   src = fetchurl {
32     url = "https://d1ni2b6xgvw0s0.cloudfront.net/v2.x/dynamodb_local_2024-06-20.tar.gz";
33     hash = "sha256-9SlgKNZFuy0/mf7eCjaUWVbrc4YXRDDnXADm+xs0540=";
34   };
36   sourceRoot = ".";
38   nativeBuildInputs = [ makeBinaryWrapper ];
40   installPhase = ''
41     runHook preInstall
43     mkdir -p $out/bin $out/share/dynamodb-local
44     cp -r DynamoDBLocal* $out/share/dynamodb-local
46     makeBinaryWrapper ${jre}/bin/java $out/bin/dynamodb-local \
47       --add-flags "-jar $out/share/dynamodb-local/DynamoDBLocal.jar"
49     runHook postInstall
50   '';
52   passthru = {
53     tests.version = testers.testVersion {
54       package = dynamodb-local;
55     };
56     updateScript = writeShellScript "update-dynamodb-local" ''
57       set -o errexit
58       export PATH="${lib.makeBinPath [ curl jq yq common-updater-scripts ]}:$PATH"
60       NEW_VERSION=$(curl -s https://repo1.maven.org/maven2/com/amazonaws/DynamoDBLocal/maven-metadata.xml | xq -r '.metadata.versioning.latest')
61       NEW_VERSION_DATE=$(curl -s https://repo1.maven.org/maven2/com/amazonaws/DynamoDBLocal/maven-metadata.xml | xq -r '.metadata.versioning.lastUpdated | "\(.[:4])-\(.[4:6])-\(.[6:8])"')
63       if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
64           echo "The new version same as the old version."
65           exit 0
66       fi
68       DOWNLOAD_URL="https://d1ni2b6xgvw0s0.cloudfront.net/v2.x/dynamodb_local_$NEW_VERSION_DATE.tar.gz"
69       NIX_HASH=$(nix hash to-sri sha256:$(nix-prefetch-url $DOWNLOAD_URL))
71       update-source-version "dynamodb-local" "$NEW_VERSION" "$NIX_HASH" "$DOWNLOAD_URL"
72     '';
73   };
75   meta = with lib; {
76     description = "DynamoDB Local is a small client-side database and server that mimics the DynamoDB service";
77     homepage = "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html";
78     license = licenses.unfree;
79     mainProgram = "dynamodb-local";
80     maintainers = with maintainers; [ shyim martinjlowm ];
81     platforms = platforms.all;
82     sourceProvenance = with lib.sourceTypes; [
83       binaryBytecode
84       binaryNativeCode
85     ];
86   };