platformsh: add updateScript

This commit is contained in:
Laurent Arnoud 2024-06-04 15:07:28 +02:00
parent 95521efe3b
commit 9c5852513f
No known key found for this signature in database
GPG Key ID: 2AA771B0751C9763
3 changed files with 63 additions and 22 deletions

View File

@ -7,33 +7,25 @@
platformsh
}:
let versions = lib.importJSON ./versions.json;
arch = if stdenvNoCC.isx86_64 then "amd64"
else if stdenvNoCC.isAarch64 then "arm64"
else throw "Unsupported architecture";
os = if stdenvNoCC.isLinux then "linux"
else if stdenvNoCC.isDarwin then "darwin"
else throw "Unsupported os";
versionInfo = versions."${os}-${arch}";
inherit (versionInfo) hash url;
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "platformsh";
version = "5.0.15";
inherit (versions) version;
nativeBuildInputs = [ installShellFiles ];
src =
{
x86_64-darwin = fetchurl {
url = "https://github.com/platformsh/cli/releases/download/${finalAttrs.version}/platform_${finalAttrs.version}_darwin_all.tar.gz";
hash = "sha256-G5/T6ZPcvC7dvw82p2CEMEOb7GCTyCAB8xJ2lxV2UXk=";
};
aarch64-darwin = fetchurl {
url = "https://github.com/platformsh/cli/releases/download/${finalAttrs.version}/platform_${finalAttrs.version}_darwin_all.tar.gz";
hash = "sha256-G5/T6ZPcvC7dvw82p2CEMEOb7GCTyCAB8xJ2lxV2UXk=";
};
x86_64-linux = fetchurl {
url = "https://github.com/platformsh/cli/releases/download/${finalAttrs.version}/platform_${finalAttrs.version}_linux_amd64.tar.gz";
hash = "sha256-0h5Thp9pSp1TgUyNVVAjsEw+kAZVzfbsHzPMXzhZhSk=";
};
aarch64-linux = fetchurl {
url = "https://github.com/platformsh/cli/releases/download/${finalAttrs.version}/platform_${finalAttrs.version}_linux_arm64.tar.gz";
hash = "sha256-m0rxC9IfqY1k4Zh027zSkDWCGNv0E0oopFfBC/vYRgU=";
};
}
.${stdenvNoCC.system}
or (throw "${finalAttrs.pname}-${finalAttrs.version}: ${stdenvNoCC.system} is unsupported.");
# run ./update
src = fetchurl { inherit hash url; };
dontConfigure = true;
dontBuild = true;
@ -51,6 +43,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
'';
passthru = {
updateScript = ./update.sh;
tests.version = testers.testVersion {
inherit (finalAttrs) version;
package = platformsh;

View File

@ -0,0 +1,29 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq
#shellcheck shell=bash
set -eu -o pipefail
version=$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
https://api.github.com/repos/platformsh/cli/releases/latest | jq -e -r ".tag_name")
linux_arm64_url=https://github.com/platformsh/cli/releases/download/$version/platform_${version}_linux_arm64.tar.gz
linux_amd64_url=https://github.com/platformsh/cli/releases/download/$version/platform_${version}_linux_amd64.tar.gz
darwin_all_url=https://github.com/platformsh/cli/releases/download/$version/platform_${version}_darwin_all.tar.gz
linux_arm64_hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "$linux_arm64_url"))
linux_amd64_hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "$linux_amd64_url"))
darwin_all_hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "$darwin_all_url"))
jq -n \
--arg version "$version" \
--arg darwin_all_hash "$darwin_all_hash" \
--arg darwin_all_url "$darwin_all_url" \
--arg linux_amd64_hash "$linux_amd64_hash" \
--arg linux_amd64_url "$linux_amd64_url" \
--arg linux_arm64_hash "$linux_arm64_hash" \
--arg linux_arm64_url "$linux_arm64_url" \
'{ "version": $version,
"darwin-amd64": { "hash": $darwin_all_hash, "url": $darwin_all_url },
"darwin-arm64": { "hash": $darwin_all_hash, "url": $darwin_all_url },
"linux-amd64": { "hash": $linux_amd64_hash, "url": $linux_amd64_url },
"linux-arm64": { "hash": $linux_arm64_hash, "url": $linux_arm64_url }
}' > pkgs/by-name/pl/platformsh/versions.json

View File

@ -0,0 +1,19 @@
{
"version": "5.0.16",
"darwin-amd64": {
"hash": "sha256-07HuCcR/2MpRbYfszyezZjTO4r8JQif4jdDClKoKsNc=",
"url": "https://github.com/platformsh/cli/releases/download/5.0.16/platform_5.0.16_darwin_all.tar.gz"
},
"darwin-arm64": {
"hash": "sha256-07HuCcR/2MpRbYfszyezZjTO4r8JQif4jdDClKoKsNc=",
"url": "https://github.com/platformsh/cli/releases/download/5.0.16/platform_5.0.16_darwin_all.tar.gz"
},
"linux-amd64": {
"hash": "sha256-Z9GPvvwNP2FdPUuFkDNPDKT7Pp+H6ymRvrTiPcooe3c=",
"url": "https://github.com/platformsh/cli/releases/download/5.0.16/platform_5.0.16_linux_amd64.tar.gz"
},
"linux-arm64": {
"hash": "sha256-3615mSWDq4DJD3554ELkAh+rEIJ/OOtLrdDoojAjZf8=",
"url": "https://github.com/platformsh/cli/releases/download/5.0.16/platform_5.0.16_linux_arm64.tar.gz"
}
}