From 44719bd4960c649f1a0b793aefab832524eef8bf Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Fri, 26 Mar 2021 10:32:37 +0000 Subject: [PATCH 1/2] octant: cleanup - Remove unneeded quotes around `${system}` - Cleanup meta - Correct the variable names in `update.sh` - Luckily even though the names were a jumble the correct shas were being put in the right places --- .../networking/cluster/octant/default.nix | 14 ++++++++------ .../networking/cluster/octant/update.sh | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/networking/cluster/octant/default.nix b/pkgs/applications/networking/cluster/octant/default.nix index 0e97b541a5d..734a1eb3ac3 100644 --- a/pkgs/applications/networking/cluster/octant/default.nix +++ b/pkgs/applications/networking/cluster/octant/default.nix @@ -6,7 +6,7 @@ let x86_64-linux = "Linux-64bit"; aarch64-linux = "Linux-arm64"; x86_64-darwin = "macOS-64bit"; - }."${system}" or (throw "Unsupported system: ${system}"); + }.${system} or (throw "Unsupported system: ${system}"); baseurl = "https://github.com/vmware-tanzu/octant/releases/download"; fetchsrc = version: sha256: fetchzip { url = "${baseurl}/v${version}/octant_${version}_${suffix}.tar.gz"; @@ -48,12 +48,14 @@ stdenv.mkDerivation rec { meta = with lib; { homepage = "https://octant.dev/"; changelog = "https://github.com/vmware-tanzu/octant/blob/v${version}/CHANGELOG.md"; - description = "Highly extensible platform for developers to better understand the complexity of Kubernetes clusters."; + description = "Highly extensible platform for developers to better understand the complexity of Kubernetes clusters"; longDescription = '' - Octant is a tool for developers to understand how applications run on a Kubernetes cluster. - It aims to be part of the developer's toolkit for gaining insight and approaching complexity found in Kubernetes. - Octant offers a combination of introspective tooling, cluster navigation, and object management along with a - plugin system to further extend its capabilities. + Octant is a tool for developers to understand how applications run on a + Kubernetes cluster. + It aims to be part of the developer's toolkit for gaining insight and + approaching complexity found in Kubernetes. Octant offers a combination of + introspective tooling, cluster navigation, and object management along + with a plugin system to further extend its capabilities. ''; license = licenses.asl20; maintainers = with maintainers; [ jk ]; diff --git a/pkgs/applications/networking/cluster/octant/update.sh b/pkgs/applications/networking/cluster/octant/update.sh index 4ffe4aefb30..6c34fc4b37a 100755 --- a/pkgs/applications/networking/cluster/octant/update.sh +++ b/pkgs/applications/networking/cluster/octant/update.sh @@ -28,11 +28,11 @@ replace_sha() { OCTANT_VER=$(curl -Ls -w "%{url_effective}" -o /dev/null https://github.com/vmware-tanzu/octant/releases/latest | awk -F'/' '{print $NF}' | sed 's/v//') OCTANT_LINUX_X64_SHA256=$(fetch_arch "$OCTANT_VER" "Linux-64bit") -OCTANT_DARWIN_X64_SHA256=$(fetch_arch "$OCTANT_VER" "Linux-arm64") -OCTANT_LINUX_AARCH64_SHA256=$(fetch_arch "$OCTANT_VER" "macOS-64bit") +OCTANT_LINUX_AARCH64_SHA256=$(fetch_arch "$OCTANT_VER" "Linux-arm64") +OCTANT_DARWIN_X64_SHA256=$(fetch_arch "$OCTANT_VER" "macOS-64bit") sed -i "s/version = \".*\"/version = \"$OCTANT_VER\"/" "$NIX_DRV" replace_sha "x86_64-linux" "$OCTANT_LINUX_X64_SHA256" -replace_sha "x86_64-darwin" "$OCTANT_LINUX_AARCH64_SHA256" -replace_sha "aarch64-linux" "$OCTANT_DARWIN_X64_SHA256" +replace_sha "aarch64-linux" "$OCTANT_LINUX_AARCH64_SHA256" +replace_sha "x86_64-darwin" "$OCTANT_DARWIN_X64_SHA256" From d040b6da58848164c68a5fcf6a12cff2cfb44f91 Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Fri, 26 Mar 2021 10:34:29 +0000 Subject: [PATCH 2/2] octant-desktop: init at 0.18.0 Unpacked from an AppImage or dmg depending on the platform --- .../networking/cluster/octant/desktop.nix | 78 +++++++++++++++++++ .../cluster/octant/update-desktop.sh | 36 +++++++++ pkgs/top-level/all-packages.nix | 1 + 3 files changed, 115 insertions(+) create mode 100644 pkgs/applications/networking/cluster/octant/desktop.nix create mode 100755 pkgs/applications/networking/cluster/octant/update-desktop.sh diff --git a/pkgs/applications/networking/cluster/octant/desktop.nix b/pkgs/applications/networking/cluster/octant/desktop.nix new file mode 100644 index 00000000000..0f43e29e628 --- /dev/null +++ b/pkgs/applications/networking/cluster/octant/desktop.nix @@ -0,0 +1,78 @@ +{ lib, stdenv, appimageTools, fetchurl, gsettings-desktop-schemas, gtk3, undmg }: + +let + pname = "octant-desktop"; + version = "0.18.0"; + name = "${pname}-${version}"; + + inherit (stdenv.hostPlatform) system; + + suffix = { + x86_64-linux = "AppImage"; + x86_64-darwin = "dmg"; + }.${system} or (throw "Unsupported system: ${system}"); + + src = fetchurl { + url = "https://github.com/vmware-tanzu/octant/releases/download/v${version}/Octant-${version}.${suffix}"; + sha256 = { + x86_64-linux = "sha256-sQxplTJ3xfHELepx+t7FtMpPTxTDoqTAL8oUz4sLaW0="; + x86_64-darwin = "sha256-ov9j+SgGXCwUjQaX3eCxVvPwPgUIwtHJ6Lmx2crOfIM="; + }.${system}; + }; + + linux = appimageTools.wrapType2 { + inherit name src passthru meta; + + profile = '' + export LC_ALL=C.UTF-8 + export XDG_DATA_DIRS=${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}:${gtk3}/share/gsettings-schemas/${gtk3.name}:$XDG_DATA_DIRS + ''; + + multiPkgs = null; # no 32bit needed + extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; + extraInstallCommands = + let appimageContents = appimageTools.extractType2 { inherit name src; }; in + '' + mv $out/bin/{${name},${pname}} + install -Dm444 ${appimageContents}/octant.desktop -t $out/share/applications + substituteInPlace $out/share/applications/octant.desktop \ + --replace 'Exec=AppRun --no-sandbox' 'Exec=${pname}' + install -m 444 -D ${appimageContents}/octant.png \ + $out/share/icons/hicolor/512x512/apps/octant.png + ''; + }; + + darwin = stdenv.mkDerivation { + inherit name src passthru meta; + + nativeBuildInputs = [ undmg ]; + sourceRoot = "Octant.app"; + installPhase = '' + mkdir -p $out/Applications/Octant.app + cp -R . $out/Applications/Octant.app + ''; + }; + + passthru = { updateScript = ./update-desktop.sh; }; + + meta = with lib; { + homepage = "https://octant.dev/"; + changelog = "https://github.com/vmware-tanzu/octant/blob/v${version}/CHANGELOG.md"; + description = "Highly extensible platform for developers to better understand the complexity of Kubernetes clusters"; + longDescription = '' + Octant is a tool for developers to understand how applications run on a + Kubernetes cluster. + It aims to be part of the developer's toolkit for gaining insight and + approaching complexity found in Kubernetes. Octant offers a combination of + introspective tooling, cluster navigation, and object management along + with a plugin system to further extend its capabilities. + ''; + license = licenses.asl20; + maintainers = with maintainers; [ jk ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; + +in +if stdenv.isDarwin +then darwin +else linux diff --git a/pkgs/applications/networking/cluster/octant/update-desktop.sh b/pkgs/applications/networking/cluster/octant/update-desktop.sh new file mode 100755 index 00000000000..4450834b4b7 --- /dev/null +++ b/pkgs/applications/networking/cluster/octant/update-desktop.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused gawk nix-prefetch + +set -euo pipefail + +ROOT="$(dirname "$(readlink -f "$0")")" +NIX_DRV="$ROOT/desktop.nix" +if [ ! -f "$NIX_DRV" ]; then + echo "ERROR: cannot find desktop.nix in $ROOT" + exit 1 +fi + +fetch_arch() { + VER="$1"; SUFFIX="$2" + URL="https://github.com/vmware-tanzu/octant/releases/download/v${VER}/Octant-${VER}.${SUFFIX}" + nix-prefetch "{ stdenv, fetchurl }: +stdenv.mkDerivation rec { + pname = \"octant-desktop\"; version = \"${VER}\"; + src = fetchurl { url = \"$URL\"; }; +} +" +} + +replace_sha() { + sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV" +} + +OCTANT_VER=$(curl -Ls -w "%{url_effective}" -o /dev/null https://github.com/vmware-tanzu/octant/releases/latest | awk -F'/' '{print $NF}' | sed 's/v//') + +OCTANT_DESKTOP_LINUX_X64_SHA256=$(fetch_arch "$OCTANT_VER" "AppImage") +OCTANT_DESKTOP_DARWIN_X64_SHA256=$(fetch_arch "$OCTANT_VER" "dmg") + +sed -i "s/version = \".*\"/version = \"$OCTANT_VER\"/" "$NIX_DRV" + +replace_sha "x86_64-linux" "$OCTANT_DESKTOP_LINUX_X64_SHA256" +replace_sha "x86_64-darwin" "$OCTANT_DESKTOP_DARWIN_X64_SHA256" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e502a21f217..289d018ffcb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -548,6 +548,7 @@ in ociTools = callPackage ../build-support/oci-tools { }; octant = callPackage ../applications/networking/cluster/octant { }; + octant-desktop = callPackage ../applications/networking/cluster/octant/desktop.nix { }; starboard-octant-plugin = callPackage ../applications/networking/cluster/octant/plugins/starboard-octant-plugin.nix { }; pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;