Implement the complete homelab-deploy system with three operational modes: - Listener mode: Runs on NixOS hosts as a systemd service, subscribes to NATS subjects with configurable templates, executes nixos-rebuild on deployment requests with concurrency control - MCP mode: MCP server exposing deploy, deploy_admin, and list_hosts tools for AI assistants with tiered access control - CLI mode: Manual deployment commands with subject alias support via environment variables Key components: - internal/messages: Request/response types with validation - internal/nats: Client wrapper with NKey authentication - internal/deploy: Executor with timeout and lock for concurrency - internal/listener: Subject template expansion and request handling - internal/cli: Deploy logic with alias resolution - internal/mcp: MCP server with mcp-go integration - nixos/module.nix: NixOS module with hardened systemd service Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
51 lines
1.3 KiB
Nix
51 lines
1.3 KiB
Nix
{
|
|
description = "Message-based NixOS deployment system using NATS";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
pkgsFor = system: nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
packages = forAllSystems (system:
|
|
let
|
|
pkgs = pkgsFor system;
|
|
in
|
|
{
|
|
homelab-deploy = pkgs.buildGoModule {
|
|
pname = "homelab-deploy";
|
|
version = "0.1.0";
|
|
src = ./.;
|
|
vendorHash = "sha256-JXa+obN62zrrwXlplqojY7dvEunUqDdSTee6N8c5JTg=";
|
|
subPackages = [ "cmd/homelab-deploy" ];
|
|
};
|
|
default = self.packages.${system}.homelab-deploy;
|
|
});
|
|
|
|
devShells = forAllSystems (system:
|
|
let
|
|
pkgs = pkgsFor system;
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
go
|
|
gopls
|
|
gotools
|
|
golangci-lint
|
|
govulncheck
|
|
delve
|
|
];
|
|
};
|
|
});
|
|
|
|
nixosModules.default = import ./nixos/module.nix;
|
|
nixosModules.homelab-deploy = self.nixosModules.default;
|
|
};
|
|
}
|