mirrord: init at 3.125.0 (#349722)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "3.125.0",
|
||||
"assets": {
|
||||
"x86_64-linux": {
|
||||
"url": "https://github.com/metalbear-co/mirrord/releases/download/3.125.0/mirrord_linux_x86_64",
|
||||
"hash": "sha256-xh5M/YG2W61wiNd4iB6LVUfidkHkB5OmbCzRh7yUpeU="
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"url": "https://github.com/metalbear-co/mirrord/releases/download/3.125.0/mirrord_linux_aarch64",
|
||||
"hash": "sha256-MWGdYeJXseSAKlndUT07NNWCpywJfGJ0hGRklEMQQmw="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
testers,
|
||||
mirrord,
|
||||
autoPatchelfHook,
|
||||
}:
|
||||
|
||||
let
|
||||
manifest = lib.importJSON ./manifest.json;
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "mirrord";
|
||||
version = manifest.version;
|
||||
|
||||
src = fetchurl (manifest.assets.${stdenv.hostPlatform.system});
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isElf [
|
||||
autoPatchelfHook
|
||||
];
|
||||
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isElf [
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
install -D $src $out/bin/mirrord
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests.version = testers.testVersion {
|
||||
package = mirrord;
|
||||
};
|
||||
updateScript = ./update.py;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Run local processes in the context of Kubernetes environment";
|
||||
homepage = "https://mirrord.dev/";
|
||||
license = lib.licenses.mit;
|
||||
platforms = builtins.attrNames manifest.assets;
|
||||
maintainers = with lib.maintainers; [ aaronjheng ];
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
mainProgram = "mirrord";
|
||||
};
|
||||
})
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python -p "python3.withPackages (ps: with ps; [ ps.httpx ps.socksio ])"
|
||||
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
import httpx
|
||||
|
||||
platforms = {
|
||||
"x86_64-linux": "linux_x86_64",
|
||||
"aarch64-linux": "linux_aarch64",
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
headers = {}
|
||||
token = os.getenv("GITHUB_TOKEN")
|
||||
if token is not None:
|
||||
headers["Authorization"] = "Bearer {}".format(token)
|
||||
|
||||
resp = httpx.get(
|
||||
"https://api.github.com/repos/metalbear-co/mirrord/releases/latest",
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
latest_release = resp.json().get("tag_name")
|
||||
version = latest_release.removeprefix("v")
|
||||
|
||||
assets = {
|
||||
"version": version,
|
||||
"assets": {},
|
||||
}
|
||||
|
||||
for k, v in platforms.items():
|
||||
url = "https://github.com/metalbear-co/mirrord/releases/download/{}/mirrord_{}".format(
|
||||
version, v
|
||||
)
|
||||
|
||||
process = subprocess.run(
|
||||
["nix-prefetch-url", "--type", "sha256", url],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
process.check_returncode()
|
||||
|
||||
process = subprocess.run(
|
||||
["nix-hash", "--type", "sha256", "--to-sri", process.stdout.rstrip()],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
process.check_returncode()
|
||||
|
||||
hash = process.stdout.rstrip()
|
||||
assets["assets"][k] = {
|
||||
"url": url,
|
||||
"hash": hash,
|
||||
}
|
||||
|
||||
(pathlib.Path(__file__).parent / "manifest.json").write_text(
|
||||
json.dumps(assets, indent=2) + "\n"
|
||||
)
|
||||
Reference in New Issue
Block a user