From c304803fda4f107beda5d76069b91ed9304d526d Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Thu, 27 Aug 2026 16:49:24 -0400 Subject: [PATCH] portainer management --- bin/lib/cmds.nu | 24 +++++++- configs/fwbook/hypr/conf/animations.lua | 2 +- hosts/hl-bigbox1.nix | 25 ++++++++- hosts/hl-minipc2.nix | 55 ++++++++----------- modules/nixos/server/GUIDELINES.md | 5 +- modules/nixos/server/services/ABOUTME.md | 5 -- modules/nixos/server/services/ai-services.nix | 14 ++--- secrets.nix | 4 ++ secrets/portainer-agent-bigbox1.age | 7 +++ 9 files changed, 90 insertions(+), 51 deletions(-) create mode 100644 secrets/portainer-agent-bigbox1.age diff --git a/bin/lib/cmds.nu b/bin/lib/cmds.nu index 4028e6e..bfc89d9 100644 --- a/bin/lib/cmds.nu +++ b/bin/lib/cmds.nu @@ -342,7 +342,12 @@ export def "skyg decrypt" [secret: string@secret-names] { } # Encrypt a file to secrets/ folder (re-encrypts using agenix) -export def "skyg encrypt" [secret: string@secret-names, source?: string] { +# --yaml Validate the content as YAML (via yq) before encrypting +export def "skyg encrypt" [ + secret: string@secret-names, + source?: string, + --yaml # Validate the content as YAML (via yq) before encrypting +] { cd $REPO_ROOT let src = $source | default $".tmp/unencrypted-($secret)" if not ($src | path exists) { @@ -354,6 +359,23 @@ export def "skyg encrypt" [secret: string@secret-names, source?: string] { } } vi $src + + if $yaml { + # `complete` captures stdout/stderr/exit_code; `try/catch` guards a missing yq + let lint = (try { yq e '.' $src | complete } catch { null }) + if $lint == null { + print $"â�Œ Could not run yq — is it on PATH? Add 'yq' to the devShell in flake.nix." + return + } + if $lint.exit_code != 0 { + print $"â�Œ YAML validation failed for ($src):" + print ($lint.stderr | str trim) + print $"Fix the syntax, then re-run: skyg encrypt ($secret) --yaml" + return + } + print $"✅ YAML valid: ($src)" + } + let dest = $"secrets/($secret).age" cat $src | EDITOR="cp /dev/stdin" agenix -e $dest print $"Encrypted ($dest)" diff --git a/configs/fwbook/hypr/conf/animations.lua b/configs/fwbook/hypr/conf/animations.lua index b84801c..4bef9fa 100644 --- a/configs/fwbook/hypr/conf/animations.lua +++ b/configs/fwbook/hypr/conf/animations.lua @@ -7,7 +7,7 @@ hl.animation({ leaf = "workspaces", enabled = true, speed = 2, - bezier = "wsslide", + bezier = "default", style = "slidevert", }) diff --git a/hosts/hl-bigbox1.nix b/hosts/hl-bigbox1.nix index 5d68f7c..37bd481 100644 --- a/hosts/hl-bigbox1.nix +++ b/hosts/hl-bigbox1.nix @@ -40,7 +40,30 @@ networkDrives.enable = true; }; - # Dockge container service group + # Portainer Agent + age.secrets.portainer-agent-bigbox1.file = ../secrets/portainer-agent-bigbox1.age; + skyg.nixos.common.container-services.portainer-agent = { + enable = true; + autoUpdate.enable = true; + services.agent = { + image = "portainer/agent:2.45.0"; + volumes = [ + "/var/run/docker.sock:/var/run/docker.sock" + "/var/lib/docker/volumes:/var/lib/docker/volumes" + "portainer_agent_data:/data" + ]; + environmentFiles = [ config.age.secrets.portainer-agent-bigbox1.path ]; + environment = { + EDGE_INSECURE_POLL = "1"; + EDGE = "1"; + }; + }; + volumes.portainer_agent_data = { + name = "portainer_data"; + }; + }; + + # Jellyfin container service group skyg.nixos.common.container-services.jellyfin = { enable = true; autoUpdate.enable = true; diff --git a/hosts/hl-minipc2.nix b/hosts/hl-minipc2.nix index 3c6ad01..10d7187 100644 --- a/hosts/hl-minipc2.nix +++ b/hosts/hl-minipc2.nix @@ -21,39 +21,6 @@ # Disable firewall networking.firewall.enable = false; - # Dockge container service group - skyg.nixos.common.container-services.dockge = { - enable = true; - services.dockge = { - image = "louislam/dockge:1"; - ports = [ "5001:5001" ]; - volumes = [ - "/var/run/docker.sock:/var/run/docker.sock" - "dockge-data:/app/data" - "dockge-stacks:/opt/stacks" - ]; - environment.DOCKGE_STACKS_DIR = "/opt/stacks"; - }; - volumes = { - dockge-data = { - driver = "local"; - driver_opts = { - type = "nfs"; - o = "addr=terra1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime"; - device = ":/mnt/Data/apps/arrs/dockge/data"; - }; - }; - dockge-stacks = { - driver = "local"; - driver_opts = { - type = "nfs"; - o = "addr=terra1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime"; - device = ":/mnt/Data/apps/arrs/dockge/stacks"; - }; - }; - }; - }; - # Scrypted container service group skyg.nixos.common.container-services.scrypted = { enable = true; @@ -93,6 +60,28 @@ }; }; + # Portainer Service + skyg.nixos.common.container-services.portainer = { + enable = true; + autoUpdate.enable = true; + services.portainer = { + image = "portainer/portainer-ce:lts"; + volumes = [ + "/var/run/docker.sock:/var/run/docker.sock" + "portainer_data:/data" + ]; + ports = [ + "9443:9443" + "8000:8000" + ]; + }; + volumes = { + portainer_data = { + name = "portainer_data"; + }; + }; + }; + age.secrets.stack1.file = ../secrets/stack1.age; skyg.nixos.common.container-services.stack1 = { enable = true; diff --git a/modules/nixos/server/GUIDELINES.md b/modules/nixos/server/GUIDELINES.md index 1e6aa27..3205507 100644 --- a/modules/nixos/server/GUIDELINES.md +++ b/modules/nixos/server/GUIDELINES.md @@ -8,8 +8,7 @@ How to add and modify homelab server roles/services. Read alongside the repo-roo ## Anatomy of a service module Most files here follow the same shape. When adding a new service, mirror an existing one -(`jellyfin.nix` for a simple native service, `dockge.nix`/`scrypted.nix` for containerized -NFS-backed services): +(`jellyfin.nix` for a simple native service): ```nix { config, lib, pkgs, ... }: @@ -41,7 +40,7 @@ Then add it to `services/default.nix`'s `imports` list (and to the `services/ABO choice from `modules/nixos/common/containers/`. Don't hardcode `docker run` in a service (the `openwrt` deploy script is the only sanctioned shell-out, and it lives elsewhere). 5. **NFS-backed volumes**: create them with `system.activationScripts` + `docker volume - create --driver local --opt type=nfs` (see `dockge.nix`), and reference homelab hosts by + create --driver local --opt type=nfs`, and reference homelab hosts by their `*.lab.internal` names. 6. **Scheduled jobs** (backups, auto-updates) should use the `skyg.server.timers.` helper in `timers.nix` rather than hand-writing `systemd.timers`/`systemd.services`. diff --git a/modules/nixos/server/services/ABOUTME.md b/modules/nixos/server/services/ABOUTME.md index 56b577e..4d6f8f9 100644 --- a/modules/nixos/server/services/ABOUTME.md +++ b/modules/nixos/server/services/ABOUTME.md @@ -13,8 +13,6 @@ services/ ├── ai-services.nix # skyg.nixos.server.services.ai — ollama + Wyoming (whisper/piper/wake) ├── audiobookshelf.nix # skyg.nixos.server.services.audiobookshelf — audiobook/podcast server ├── jellyfin.nix # skyg.nixos.server.services.jellyfin — media server (uid/gid 7777) -├── scrypted.nix # skyg.nixos.server.services.scrypted — NVR (host net, NFS NVR volume) -├── dockge.nix # skyg.nixos.server.services.dockge — compose stack manager (NFS volumes) ├── signal-cli.nix # skyg.nixos.server.services.signal-cli — signal-cli HTTP daemon (Hermes Signal bridge) ├── openclaw.nix # skyg.nixos.server.services.openclaw — AI gateway (NOT imported by default) ├── colibri.nix # skyg.nixos.server.services.colibri — coli serve HTTP API (GLM-5.2/OLMoE local inference) @@ -25,8 +23,6 @@ services/ - **`ai-services.nix`** runs ollama (GPU-passthrough) and openwakeword as containers and enables NixOS-native Wyoming faster-whisper + piper. Opens 11434/10200/10300/10400. -- **`dockge.nix` / `scrypted.nix`** create NFS-backed docker volumes via - `system.activationScripts` and use `skyg.server.timers` for backups/auto-updates. - **`openclaw.nix`** is a native systemd service (with agenix-token support and security hardening). Note: it is **not** listed in `default.nix`'s imports, so it must be imported explicitly if used. @@ -42,7 +38,6 @@ skyg.nixos.server.services.ai.enable skyg.nixos.server.services.audiobookshelf.{enable,package,configDir,dataDir} skyg.nixos.server.services.jellyfin.enable skyg.nixos.server.services.scrypted.enable -skyg.nixos.server.services.dockge.{enable,openFirewall,port,volumes} skyg.nixos.server.services.signal-cli.{enable,host,port,configDir,account,environmentFile,openFirewall} skyg.nixos.server.services.openclaw.{enable,port,gatewayToken,...} skyg.nixos.server.services.colibri.{enable,package,model,host,port,environmentFile,openFirewall,...} diff --git a/modules/nixos/server/services/ai-services.nix b/modules/nixos/server/services/ai-services.nix index e42da74..8349d9d 100644 --- a/modules/nixos/server/services/ai-services.nix +++ b/modules/nixos/server/services/ai-services.nix @@ -24,13 +24,13 @@ in networking.firewall.allowedTCPPorts = openPorts; virtualisation.oci-containers = { containers = { - ollama = { - autoStart = true; - image = "ollama/ollama"; - extraOptions = [ "--device=nvidia.com/gpu=all" ]; - ports = [ "11434:11434" ]; - volumes = [ "ollama:/root/.ollama" ]; - }; + # ollama = { + # autoStart = true; + # image = "ollama/ollama"; + # extraOptions = [ "--device=nvidia.com/gpu=all" ]; + # ports = [ "11434:11434" ]; + # volumes = [ "ollama:/root/.ollama" ]; + # }; openwakeword = { autoStart = true; image = "rhasspy/wyoming-openwakeword"; diff --git a/secrets.nix b/secrets.nix index daacf63..54f5f3c 100644 --- a/secrets.nix +++ b/secrets.nix @@ -5,6 +5,7 @@ let minipc3 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEbvoe/UvhpRSWVXMCyj/qzuR7WnJdNF7CYRmmJE3yYu root@minisf1"; terra1 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHBKI8gqd7DDubShle4D3JGq61BP1NBKCZ81V3C9uyym root@nixos"; fwdesk = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHbBcdMpNPaELUzHRIoRkTUQde+mBQ87Ra2R+974FuUy root@hl-fwdesk"; + bigbox1 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFl5xiH4aFlmDWdoU+KmERLYOeOQK2aKP7jenY2G3rFb root@nixos"; in { "secrets/dns-addresses.conf.age".publicKeys = [ @@ -27,4 +28,7 @@ in # stack compose definition — minipc2 "secrets/stack1.age".publicKeys = [ ari minipc2 ]; "secrets/stack2.age".publicKeys = [ ari minipc2 ]; + + # portainer agent envs + "secrets/portainer-agent-bigbox1.age".publicKeys = [ ari bigbox1 ]; } diff --git a/secrets/portainer-agent-bigbox1.age b/secrets/portainer-agent-bigbox1.age new file mode 100644 index 0000000..a98b00c --- /dev/null +++ b/secrets/portainer-agent-bigbox1.age @@ -0,0 +1,7 @@ +age-encryption.org/v1 +-> ssh-ed25519 CIR0mA ejMujwOJsTCetZVSW14Xs0UiwBph7jDkOr5MyFZNWCE +7L6UzE9GL91fMb9+vbcOSxbQaRaNoy203xk6mfb2Q9k +-> ssh-ed25519 GhpmGA M6RvOGEKR5FrmnTendSchjzToxtNxuwR09+PAuP7mg4 +1FVS0e4B7NeLWZueBQSAQkEJcuqRQbEKNOmj+JjQKzQ +--- jC5qDXTdBrHZGCTQ9Dn8aZ4p8PNzBuSKsI10YSqclj4 +i¬/t#è©¥+54!x+lüÌã Ä໯”ãý‰h�¯¬ŽXV,/aQnØ,(KÝ…láÐýÛ™Lqmó¢É‰�B/j„<× ë¿Ëé>h¢™Ú)†m9n+yñÑЈ(µ³×8�ªNýI „ÔZ"m”`:¦½”Œ[_‡N­³Æô~òü*P4B›°2.ÕR\à8Ò�÷Ê%WŽd Ïúø`DéNÁÚâ3€Nîßµ¥{ �8 AË&;æ÷ЗÎû�8ïG¦õ&W7¦E,H*‰Yfm%—|›RxdºwÖ´¯1