From 9bbb4b929831f3f0f231ac1c82cef43ad970dfb9 Mon Sep 17 00:00:00 2001 From: technofab Date: Thu, 5 Jun 2025 19:42:47 +0200 Subject: [PATCH] feat(nix-kubernetes): add startup and shutdown tasks with home-manager --- nix-kubernetes/coder.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nix-kubernetes/coder.nix b/nix-kubernetes/coder.nix index 9b637c1..b370ee2 100644 --- a/nix-kubernetes/coder.nix +++ b/nix-kubernetes/coder.nix @@ -77,6 +77,12 @@ if [ ! -z "$DOTFILES_REPO" ]; then echo "Dotfiles present, reloading home-manager profile" reload-dotfiles + # the homeConfiguration can specify a program "coder_startup", run it + # here if it exists + if command -v coder_startup &> /dev/null; then + echo "Running startup tasks..." + coder_startup + fi else echo "No dotfiles repo specified, skipping..." fi @@ -84,5 +90,17 @@ run_on_start = true; start_blocks_login = true; }; + coder_script."home-manager-shutdown" = { + agent_id = "\${coder_agent.coder.id}"; + display_name = "Home Manager Shutdown"; + icon = "/emojis/1f3e0.png"; + script = '' + if command -v coder_shutdown &> /dev/null; then + echo "Running shutdown tasks..." + coder_shutdown + fi + ''; + run_on_stop = true; + }; }; }