diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..71bfe94 --- /dev/null +++ b/flake.lock @@ -0,0 +1,174 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "flake-utils": [ + "kardinal", + "flake-utils" + ], + "nixpkgs": [ + "kardinal", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722589758, + "narHash": "sha256-sbbA8b6Q2vB/t/r1znHawoXLysCyD4L/6n6/RykiSnA=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "4e08ca09253ef996bd4c03afa383b23e35fe28a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, + "kardinal": { + "inputs": { + "flake-utils": "flake-utils_2", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1727351905, + "narHash": "sha256-bF36zIb+gxrYpiipV6pLlSMW27SIklgT6ezcSgJ/mHo=", + "owner": "kurtosis-tech", + "repo": "kardinal", + "rev": "4be70324e7b2fa936254db003c5629b6677ff095", + "type": "github" + }, + "original": { + "owner": "kurtosis-tech", + "ref": "4be70324e7b2", + "repo": "kardinal", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1726320982, + "narHash": "sha256-RuVXUwcYwaUeks6h3OLrEmg14z9aFXdWppTWPMTwdQw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8f7492cce28977fbf8bd12c72af08b1f6c7c3e49", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1727264057, + "narHash": "sha256-KQPI8CTTnB9CrJ7LrmLC4VWbKZfljEPBXOFGZFRpxao=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "759537f06e6999e141588ff1c9be7f3a5c060106", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "kardinal": "kardinal", + "nixpkgs": "nixpkgs_2", + "unstable": "unstable" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "unstable": { + "locked": { + "lastModified": 1727122398, + "narHash": "sha256-o8VBeCWHBxGd4kVMceIayf5GApqTavJbTa44Xcg5Rrk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "30439d93eb8b19861ccbe3e581abf97bdc91b093", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c160413 --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +{ + description = "Go development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + flake-utils.url = "github:numtide/flake-utils"; + unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + kardinal.url = "github:kurtosis-tech/kardinal/4be70324e7b2"; + }; + outputs = { + self, + nixpkgs, + flake-utils, + unstable, + kardinal, + ... + }: + flake-utils.lib.eachDefaultSystem + ( + system: let + pkgs = import nixpkgs { + inherit system; + overlays = [ + (final: prev: { + kardinal = kardinal.outputs.packages.${system}; + }) + ]; + }; + in { + devShells.default = let + start-local-cluster = pkgs.writeShellApplication { + name = "start-local-cluster"; + runtimeInputs = with pkgs; [minikube istioctl kubectl]; + text = '' + kubectl config set-context minikube + minikube start --driver=docker + minikube addons enable ingress + minikube addons enable metrics-server + + istioctl install --set profile=minimal --set meshConfig.accessLogFile=/dev/stdout -y + + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml + + kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/prometheus.yaml + kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/grafana.yaml + kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/jaeger.yaml + kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/kiali.yaml + kubectl rollout status deployment/kiali -n istio-system + ''; + }; + + kardinal-cli = pkgs.stdenv.mkDerivation { + name = "kardinal"; + dontUnpack = true; + buildInputs = [pkgs.kardinal.kardinal-cli]; + installPhase = '' + mkdir -p $out/bin + ln -s ${pkgs.kardinal.kardinal-cli}/bin/kardinal.cli $out/bin/kardinal + ''; + }; + in + pkgs.mkShell { + buildInputs = with pkgs; [ + go + gopls + go-tools + golangci-lint + reflex + + # local demo tools + kardinal-cli + minikube + kubectl + istioctl + telepresence2 + + # Scripts + start-local-cluster + ]; + + shellHook = '' + source <(kardinal completion bash) + echo "Go development environment loaded" + go version + ''; + }; + } + ); +}