This repository was archived by the owner on Mar 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
executable file
·112 lines (96 loc) · 3.69 KB
/
flake.nix
File metadata and controls
executable file
·112 lines (96 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.systems.url = "github:nix-systems/default";
inputs.flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
outputs = {
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
config = {allowUnfree = true;};
};
# Create a script to fetch GitHub credentials with a timeout
kctlWrapper = pkgs.writeShellScriptBin "k" ''
#!/usr/bin/env bash
# export KUBECONFIG="$HOME/Developer/Homelab/infra-sol/kubeconfig"
kubecolor "$@"
'';
# Create talosctl wrapper to ensure it uses correct config
talosWrapper = pkgs.writeShellScriptBin "t" ''
#!/usr/bin/env bash
# export TALOSCONFIG="$HOME/Developer/Homelab/infra-sol/taloscconfig"
talosctl "$@"
'';
fluxstat = pkgs.writeShellScriptBin "fls" ''
watch flux get all -A
'';
klogs = pkgs.writeShellScriptBin "klogs" ''
pods=$(kubectl get pods -A --no-headers)
selected_pod=$(echo "$pods" | awk '{print $2}' | fzf \
--prompt="Loading Pods..." \
--border-label="Select Pod" \
--bind "load:change-prompt: " \
--color=label:bold:blue \
--border \
--preview "echo '$pods' | grep '{1}' | awk '{print \"Namespace: \" \$1 \"\nName: \" \$2 \"\nStatus: \" \$4 \"\nAge: \" \$6 }'" )
selected_namespace=$(echo "$pods" | grep "$selected_pod" | awk '{print $1}')
kubectl logs -n "$selected_namespace" "$selected_pod" -f
'';
in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
kubectl
talosctl
fluxcd
# Additional useful tools
kubernetes-helm
k9s
kubectx
jq
yq-go
fzf
git-secret
_1password-cli
watch
kubecolor
fluxcd
# Include our credential fetching script
kctlWrapper
talosWrapper
fluxstat
klogs
# Include timeout utility for credential fetching
coreutils
];
shellHook = ''
# Check if configs exist and are readable
if [[ -f /tmp/kube-configs/kubeconfig && -f /tmp/kube-configs/talosconfig ]]; then
export KUBECONFIG="/tmp/kube-configs/kubeconfig"
export TALOSCONFIG="/tmp/kube-configs/talosconfig"
echo "✓ Using existing configs"
else
echo "⚠️ Configs not found. Run 'setup-configs' to initialize them."
# Create a helper function
setup-configs() {
echo "Setting up configs..."
mkdir -p /tmp/kube-configs
opsops read $HOME/Developer/Homelab/talos/sol/kubeconfig > /tmp/kube-configs/kubeconfig
opsops read $HOME/Developer/Homelab/talos/sol/talosconfig > /tmp/kube-configs/talosconfig
export KUBECONFIG="/tmp/kube-configs/kubeconfig"
export TALOSCONFIG="/tmp/kube-configs/talosconfig"
echo "✓ Configs loaded"
}
fi
'';
};
}
);
}