diff --git a/pkgs/by-name/up/upbound-main/package.nix b/pkgs/by-name/up/upbound-main/package.nix new file mode 100644 index 0000000000000..af8f2c95876f4 --- /dev/null +++ b/pkgs/by-name/up/upbound-main/package.nix @@ -0,0 +1,6 @@ +{ + upbound, +}: +upbound.override { + version-channel = "main"; +} diff --git a/pkgs/by-name/up/upbound/package.nix b/pkgs/by-name/up/upbound/package.nix index 9bf2b100c9100..0315f96004933 100644 --- a/pkgs/by-name/up/upbound/package.nix +++ b/pkgs/by-name/up/upbound/package.nix @@ -1,32 +1,81 @@ -{ lib, buildGoModule, fetchFromGitHub }: +{ + lib, + fetchurl, + installShellFiles, + versionCheckHook, + stdenvNoCC, + version-channel ? "stable", +}: +let + inherit (stdenvNoCC.hostPlatform) system; + sources = + if "${version-channel}" == "main" then import ./sources-main.nix else import ./sources-stable.nix; + arch = sources.archMap.${system}; -buildGoModule rec { - pname = "upbound"; - version = "0.34.0"; +in +stdenvNoCC.mkDerivation { + pname = if "${version-channel}" == "main" then "upbound-main" else "upbound"; + version = sources.version; + srcs = [ + (fetchurl { + url = sources.fetchurlAttrSet.${system}.docker-credential-up.url; + sha256 = sources.fetchurlAttrSet.${system}.docker-credential-up.hash; + }) - src = fetchFromGitHub { - owner = pname; - repo = "up"; - rev = "v${version}"; - hash = "sha256-npWCGR0/iXAF7efreWhpwqboXJ24lqk5TPaB7glwEFI="; - }; + (fetchurl { + url = sources.fetchurlAttrSet.${system}.up.url; + sha256 = sources.fetchurlAttrSet.${system}.up.hash; + }) + ]; + + sourceRoot = "."; + + nativeBuildInputs = [ installShellFiles ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + + cp ./${arch}/up $out/bin/up + chmod +x $out/bin/up - vendorHash = "sha256-f/RPyjrC5FsOjC5wnBtqEbLeVX7VeiVYFpRXcQ2lTc4="; + cp ./${arch}/docker-credential-up $out/bin/docker-credential-up + chmod +x $out/bin/docker-credential-up - subPackages = [ "cmd/docker-credential-up" "cmd/up" ]; + runHook postInstall + ''; - ldflags = [ - "-s" - "-w" - "-X github.com/upbound/up/internal/version.version=v${version}" + postInstall = '' + installShellCompletion --bash --name up <(echo complete -C up up) + ''; + + versionCheckProgramArg = "version"; + + nativeInstallCheckInputs = [ + versionCheckHook ]; - meta = with lib; { - description = - "CLI for interacting with Upbound Cloud, Upbound Enterprise, and Universal Crossplane (UXP)"; + doCheck = false; + + passthru.updateScript = [ + ./update.sh + "${version-channel}" + ]; + + passthru.tests = { + versionCheck = versionCheckHook; + }; + + meta = { + description = "CLI for interacting with Upbound Cloud, Upbound Enterprise, and Universal Crossplane (UXP)"; homepage = "https://upbound.io"; - license = licenses.asl20; - maintainers = with maintainers; [ lucperkins ]; + license = lib.licenses.unfree; + maintainers = with lib.maintainers; [ + lucperkins + jljox + ]; mainProgram = "up"; + platforms = sources.platformList; }; } diff --git a/pkgs/by-name/up/upbound/sources-main.nix b/pkgs/by-name/up/upbound/sources-main.nix new file mode 100644 index 0000000000000..acf3aee015293 --- /dev/null +++ b/pkgs/by-name/up/upbound/sources-main.nix @@ -0,0 +1,54 @@ +# Generated by "update.sh main" - do not update manually! +{ + version = "0.37.0-0.rc.0.38.g797e121"; + + platformList = [ + "aarch64-linux" + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + archMap = { + aarch64-linux = "linux_arm64"; + x86_64-linux = "linux_amd64"; + x86_64-darwin = "darwin_amd64"; + aarch64-darwin = "darwin_arm64"; + }; + + fetchurlAttrSet = { + + aarch64-linux.docker-credential-up = { + hash = "sha256-nZXniTuLzmV7tK/Pd4BjUzqYYH2OmQKC4yoCHOhZ3C8="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/docker-credential-up/linux_arm64.tar.gz"; + }; + x86_64-linux.docker-credential-up = { + hash = "sha256-LILaT+vn2CdKzNWxYOeda+Zid9V11I94+vwDGkGwxuQ="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/docker-credential-up/linux_amd64.tar.gz"; + }; + x86_64-darwin.docker-credential-up = { + hash = "sha256-7eUWveGIbimxbwOGtA6qrU7F8p8EpOCTHXN4vj74qqA="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/docker-credential-up/darwin_amd64.tar.gz"; + }; + aarch64-darwin.docker-credential-up = { + hash = "sha256-XTgSZjbHXyt1BXNeaHXqdi4gs8eeD/7rE657oAeQKv4="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/docker-credential-up/darwin_arm64.tar.gz"; + }; + aarch64-linux.up = { + hash = "sha256-cNk4uaXcdH3EucwGnGXGsPbmKGGO+ig3xfJ+fAcwEbo="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/up/linux_arm64.tar.gz"; + }; + x86_64-linux.up = { + hash = "sha256-3h+Jtl84UdWvs2cbrDsbtqlCCpvvYjzXZLmzDY/9aXE="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/up/linux_amd64.tar.gz"; + }; + x86_64-darwin.up = { + hash = "sha256-WzngxshyHnR1H7Rhkbw/wkN1i3TWyV8CcBTwLNVggdU="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/up/darwin_amd64.tar.gz"; + }; + aarch64-darwin.up = { + hash = "sha256-KLcxE4847DE6e0AznjlNZnS6GNhT1JJaCnYDecTZ6EQ="; + url = "https://cli.upbound.io/main/v0.37.0-0.rc.0.38.g797e121/bundle/up/darwin_arm64.tar.gz"; + }; + }; +} diff --git a/pkgs/by-name/up/upbound/sources-stable.nix b/pkgs/by-name/up/upbound/sources-stable.nix new file mode 100644 index 0000000000000..1dfc1b574cd2b --- /dev/null +++ b/pkgs/by-name/up/upbound/sources-stable.nix @@ -0,0 +1,54 @@ +# Generated by "update.sh stable" - do not update manually! +{ + version = "0.36.1"; + + platformList = [ + "aarch64-linux" + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + archMap = { + aarch64-linux = "linux_arm64"; + x86_64-linux = "linux_amd64"; + x86_64-darwin = "darwin_amd64"; + aarch64-darwin = "darwin_arm64"; + }; + + fetchurlAttrSet = { + + aarch64-linux.docker-credential-up = { + hash = "sha256-BnEQWK1Y4rCDEk5BgkUIeF0oK6C77AQZh6KWhS+MfqM="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/docker-credential-up/linux_arm64.tar.gz"; + }; + x86_64-linux.docker-credential-up = { + hash = "sha256-4A0Di92G/vi9NR/pH20E8aaSn/jYhduQbYH6aLL2R3E="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/docker-credential-up/linux_amd64.tar.gz"; + }; + x86_64-darwin.docker-credential-up = { + hash = "sha256-/i4VsDUk0B+htRv0UCjCLT1ByewO8UNHOMbbxqIfvvE="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/docker-credential-up/darwin_amd64.tar.gz"; + }; + aarch64-darwin.docker-credential-up = { + hash = "sha256-gaaaOfn8oOxjlYruGePFZ+e65cUgRJSlsr4iweVYdSE="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/docker-credential-up/darwin_arm64.tar.gz"; + }; + aarch64-linux.up = { + hash = "sha256-mxuDhdO0nZkozMsKiKcDPBscgrY0pSChJP5TUJz729E="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/up/linux_arm64.tar.gz"; + }; + x86_64-linux.up = { + hash = "sha256-oZ1RpPZAKzChRWKUhUcKPRXhqmf3FBXvpFCICMsWh+w="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/up/linux_amd64.tar.gz"; + }; + x86_64-darwin.up = { + hash = "sha256-a4QsXlfmmFhRYxC0yZ7yVIHmP8VUgggfOZSenMXGlKA="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/up/darwin_amd64.tar.gz"; + }; + aarch64-darwin.up = { + hash = "sha256-PPHlADbIiQ/CAF746lulvuHjwwo1V563K9Haf/7IjEI="; + url = "https://cli.upbound.io/stable/v0.36.1/bundle/up/darwin_arm64.tar.gz"; + }; + }; +} diff --git a/pkgs/by-name/up/upbound/update.sh b/pkgs/by-name/up/upbound/update.sh new file mode 100755 index 0000000000000..ad0460aaade02 --- /dev/null +++ b/pkgs/by-name/up/upbound/update.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl + +#set -euo pipefail + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) + +# value can be main | stable +# Ensure at least one argument is passed +if [[ $# -lt 1 ]]; then + echo "Error: No argument provided. Please specify 'main' or 'stable'." + exit 1 +fi + +# Check if the first argument is 'main' or 'stable' +if [[ "$1" == "main" || "$1" == "stable" ]]; then + echo "Valid input: $1" +else + echo "Error: Invalid input. Please specify 'main' or 'stable'." + exit 1 +fi +channel=$1 + +baseUrl="https://cli.upbound.io/${channel}" +currentVersion=$(curl ${baseUrl}/current/version) + +version="${currentVersion:1}" + +declare -A archMapping +archMapping["aarch64-darwin"]="darwin_arm64" +archMapping["x86_64-darwin"]="darwin_amd64" +archMapping["aarch64-linux"]="linux_arm64" +archMapping["x86_64-linux"]="linux_amd64" + +archMapBlock= +for key in "${!archMapping[@]}"; do + line=$(printf "$key = \"${archMapping[$key]}\"; ") + archMapBlock="$archMapBlock$line" +done + +platformListBlock= +for key in "${!archMapping[@]}"; do + platformListBlock="$platformListBlock\"$key\" " +done + +cmds=("docker-credential-up" "up") +fetchurlAttrSetBlock= +for cmd in "${cmds[@]}"; do + for key in "${!archMapping[@]}"; do + arch=${archMapping[$key]} + url="${baseUrl}/v${version}/bundle/$cmd/${arch}.tar.gz"; + hash=$(nix-prefetch-url $url) + hash=$(nix hash convert "${hash}" --hash-algo sha256) + fetchurlAttrSetBlock=" + ${fetchurlAttrSetBlock} + $key.$cmd = { + hash = \"${hash}\"; + url = ${url}; + };" + done +done + +OUT_FILE="$SCRIPT_DIR/sources-${channel}.nix" +cat >$OUT_FILE <