-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[testing] Replace script-based tool installation with nix
Previously, binary tools like promtail and prometheus (enabling log and metrics collection) and kube and kind (enabling local kube clusters) were installed using bash scripts. A script-based approach, while simple, requires tedious and error-prone copying and committing to other repos (e.g. subnet-evm and hypersdk) that need the same functionality. Possible to rewrite the scripts to golang which allows usage via `go run` or `go install`. Simple enough if the versions never change, but still requires retrieving binaries, verifying their hashes for security, and potentially dealing with tar archives. Still more complicated if it becomes necessary to ensure the desired version is the one in the path. Switching to [nix](https://nixos.org/), on the other hand, is an established way of solving the problem that doesn't involve maintaining code. Installing nix is a one-time operation not too different from homebrew, except that the result has more guarantees of reproducibility across linux and macos.
- Loading branch information
Showing
9 changed files
with
148 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
use flake | ||
|
||
# Repo-local commands like ginkgo and tmpnetctl | ||
PATH_add bin | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,5 @@ tests/upgrade/upgrade.test | |
vendor | ||
|
||
**/testdata | ||
|
||
.direnv |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
# To use: | ||
# - install nix: https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix | ||
# - run `nix develop` or use direnv (https://direnv.net/) | ||
# - for quieter direnv output, set `export DIRENV_LOG_FORMAT=` | ||
|
||
description = "AvalancheGo development environment"; | ||
|
||
# Flake inputs | ||
inputs = { | ||
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*.tar.gz"; | ||
}; | ||
|
||
# Flake outputs | ||
outputs = { self, nixpkgs }: | ||
let | ||
# Systems supported | ||
allSystems = [ | ||
"x86_64-linux" # 64-bit Intel/AMD Linux | ||
"aarch64-linux" # 64-bit ARM Linux | ||
"x86_64-darwin" # 64-bit Intel macOS | ||
"aarch64-darwin" # 64-bit ARM macOS | ||
]; | ||
|
||
# Helper to provide system-specific attributes | ||
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { | ||
pkgs = import nixpkgs { inherit system; }; | ||
}); | ||
in | ||
{ | ||
# Development environment output | ||
devShells = forAllSystems ({ pkgs }: { | ||
default = pkgs.mkShell { | ||
# The Nix packages provided in the environment | ||
packages = with pkgs; [ | ||
# Monitoring tools | ||
promtail # Loki log shipper | ||
prometheus # Metrics collector | ||
|
||
# Kube tools | ||
kubectl # Kubernetes CLI | ||
kind # Kubernetes-in-Docker | ||
kubernetes-helm # Helm CLI (Kubernetes package manager) | ||
self.packages.${system}.kind-with-registry # Script installing kind configured with a local registry | ||
]; | ||
}; | ||
}); | ||
|
||
# Package to install the kind-with-registry script | ||
packages = forAllSystems ({ pkgs }: { | ||
kind-with-registry = pkgs.stdenv.mkDerivation { | ||
pname = "kind-with-registry"; | ||
version = "1.0.0"; | ||
|
||
src = pkgs.fetchurl { | ||
url = "https://raw.githubusercontent.com/kubernetes-sigs/kind/7cb9e6be25b48a0e248097eef29d496ab1a044d0/site/static/examples/kind-with-registry.sh"; | ||
sha256 = "0gri0x0ygcwmz8l4h6zzsvydw8rsh7qa8p5218d4hncm363i81hv"; | ||
}; | ||
|
||
phases = [ "installPhase" ]; | ||
|
||
installPhase = '' | ||
mkdir -p $out/bin | ||
install -m755 $src $out/bin/kind-with-registry.sh | ||
''; | ||
|
||
meta = with pkgs.lib; { | ||
description = "Script to set up kind with a local registry"; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [ "maru-ava" ]; | ||
}; | ||
}; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters