Implements Phase 2 of the automated deployment pipeline. This commit adds a Python CLI tool that automates the creation of NixOS host configurations, eliminating manual boilerplate and reducing errors. Features: - Python CLI using typer framework with rich terminal UI - Comprehensive validation (hostname format/uniqueness, IP subnet/uniqueness) - Jinja2 templates for NixOS configurations - Automatic updates to flake.nix and terraform/vms.tf - Support for both static IP and DHCP configurations - Dry-run mode for safe previews - Packaged as Nix derivation and added to devShell Usage: create-host --hostname myhost --ip 10.69.13.50/24 The tool generates: - hosts/<hostname>/default.nix - hosts/<hostname>/configuration.nix - Updates flake.nix with new nixosConfigurations entry - Updates terraform/vms.tf with new VM definition All generated configurations include full system imports (monitoring, SOPS, autoupgrade, etc.) and are validated with nix flake check and tofu validate. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
39 lines
655 B
Nix
39 lines
655 B
Nix
{ lib
|
|
, python3
|
|
, python3Packages
|
|
}:
|
|
|
|
python3Packages.buildPythonApplication {
|
|
pname = "create-host";
|
|
version = "0.1.0";
|
|
|
|
src = ./.;
|
|
|
|
pyproject = true;
|
|
|
|
build-system = with python3Packages; [
|
|
setuptools
|
|
];
|
|
|
|
propagatedBuildInputs = with python3Packages; [
|
|
typer
|
|
jinja2
|
|
rich
|
|
];
|
|
|
|
# Install templates to share directory
|
|
postInstall = ''
|
|
mkdir -p $out/share/create-host
|
|
cp -r templates $out/share/create-host/
|
|
'';
|
|
|
|
# No tests yet
|
|
doCheck = false;
|
|
|
|
meta = with lib; {
|
|
description = "NixOS host configuration generator for homelab infrastructure";
|
|
license = licenses.mit;
|
|
maintainers = [ ];
|
|
};
|
|
}
|