inline docs

This commit is contained in:
UGA Innovation Factory
2025-12-10 14:46:58 -05:00
parent 6e91b7e6d0
commit d1d0b44ea2
7 changed files with 34 additions and 1 deletions

View File

@@ -1,10 +1,14 @@
{ inputs, hosts, self, system }: { inputs, hosts, self, system }:
# This file defines the logic for generating various build artifacts (ISOs, Netboot, LXC, etc.)
# It exports a set of packages that can be built using `nix build .#<artifact-name>`
let let
nixpkgs = inputs.nixpkgs; nixpkgs = inputs.nixpkgs;
lib = nixpkgs.lib; lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
nixos-generators = inputs.nixos-generators; nixos-generators = inputs.nixos-generators;
# Creates a self-installing ISO for a specific host configuration
# This ISO will automatically partition the disk (using disko) and install the system
mkInstaller = hostName: mkInstaller = hostName:
let let
targetConfig = self.nixosConfigurations.${hostName}.config; targetConfig = self.nixosConfigurations.${hostName}.config;
@@ -24,6 +28,7 @@ let
]; ];
}; };
# Uses nixos-generators to create artifacts like LXC containers, Proxmox VMA, or Live ISOs
mkGenerator = hostName: format: mkGenerator = hostName: format:
nixos-generators.nixosGenerate { nixos-generators.nixosGenerate {
inherit system; inherit system;
@@ -37,6 +42,8 @@ let
inherit format; inherit format;
}; };
# Creates Netboot (iPXE) artifacts using the native NixOS netboot module
# Returns a system configuration that includes the netboot module
mkNetboot = hostName: mkNetboot = hostName:
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
@@ -52,6 +59,7 @@ let
hostNames = builtins.attrNames hosts.nixosConfigurations; hostNames = builtins.attrNames hosts.nixosConfigurations;
# Generate installer ISOs for hosts that have "installer-iso" in their buildMethods
installerPackages = lib.listToAttrs (lib.concatMap (name: installerPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "installer-iso" cfg.config.host.buildMethods then [{ if lib.elem "installer-iso" cfg.config.host.buildMethods then [{
@@ -60,6 +68,7 @@ let
}] else [] }] else []
) hostNames); ) hostNames);
# Generate Live ISOs for hosts that have "iso" in their buildMethods
isoPackages = lib.listToAttrs (lib.concatMap (name: isoPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "iso" cfg.config.host.buildMethods then [{ if lib.elem "iso" cfg.config.host.buildMethods then [{
@@ -68,6 +77,7 @@ let
}] else [] }] else []
) hostNames); ) hostNames);
# Generate iPXE artifacts (kernel, initrd, script) for hosts that have "ipxe" in their buildMethods
ipxePackages = lib.listToAttrs (lib.concatMap (name: ipxePackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "ipxe" cfg.config.host.buildMethods then [{ if lib.elem "ipxe" cfg.config.host.buildMethods then [{
@@ -87,6 +97,7 @@ let
}] else [] }] else []
) hostNames); ) hostNames);
# Generate LXC tarballs for hosts that have "lxc" in their buildMethods
lxcPackages = lib.listToAttrs (lib.concatMap (name: lxcPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "lxc" cfg.config.host.buildMethods then [{ if lib.elem "lxc" cfg.config.host.buildMethods then [{

View File

@@ -26,7 +26,15 @@
buildMethods = lib.mkOption { buildMethods = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
default = [ "installer-iso" ]; default = [ "installer-iso" ];
description = "List of allowed build methods (installer-iso, iso, ipxe, lxc, proxmox)."; description = ''
List of allowed build methods for this host.
Supported methods:
- "installer-iso": Generates an auto-install ISO that installs this configuration to disk.
- "iso": Generates a live ISO (using nixos-generators).
- "ipxe": Generates iPXE netboot artifacts (kernel, initrd, script).
- "lxc": Generates an LXC container tarball.
- "proxmox": Generates a Proxmox VMA archive.
'';
}; };
}; };

View File

@@ -8,6 +8,8 @@
... ...
}: }:
{ {
# This host type is for ephemeral, diskless systems (e.g. kiosks, netboot clients).
# It runs entirely from RAM and does not persist state across reboots.
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ boot.initrd.availableKernelModules = [

View File

@@ -1,3 +1,6 @@
# This module defines a systemd service that automatically installs NixOS to the disk.
# It is intended to be used in an installation ISO.
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
{ config, lib, pkgs, inputs, hostName, hostPlatform, targetSystem, diskoScript, ... }: { config, lib, pkgs, inputs, hostName, hostPlatform, targetSystem, diskoScript, ... }:
{ {
environment.systemPackages = [ environment.systemPackages = [

View File

@@ -1,3 +1,5 @@
# This module defines the software stack for a stateless kiosk.
# It includes a custom Firefox wrapper, Cage (Wayland kiosk compositor), and specific networking configuration.
{ {
config, config,
lib, lib,

View File

@@ -1,3 +1,6 @@
# This module configures Firefox for kiosk mode.
# It wraps Firefox with specific policies to disable UI elements and lock down the browser.
# It also includes a startup script that determines the kiosk URL based on the machine's MAC address.
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
@@ -49,6 +52,7 @@ let
BASE="http://homeassistant.lan:8123" BASE="http://homeassistant.lan:8123"
# Helper to find the primary MAC address
get_primary_mac() { get_primary_mac() {
for dev in /sys/class/net/*; do for dev in /sys/class/net/*; do
iface="$(basename "$dev")" iface="$(basename "$dev")"
@@ -64,6 +68,7 @@ let
MAC="$(get_primary_mac 2>/dev/null || echo "")" MAC="$(get_primary_mac 2>/dev/null || echo "")"
MAC="$(echo "$MAC" | tr '[:upper:]' '[:lower:]')" MAC="$(echo "$MAC" | tr '[:upper:]' '[:lower:]')"
# Map MAC addresses to specific station IDs
case "$MAC" in case "$MAC" in
"00:e0:4c:46:0b:32") STATION="1" ;; "00:e0:4c:46:0b:32") STATION="1" ;;
"00:e0:4c:46:07:26") STATION="2" ;; "00:e0:4c:46:07:26") STATION="2" ;;

View File

@@ -1,3 +1,5 @@
# This module configures the network for the stateless kiosk.
# It uses systemd-networkd to set up a VLAN (ID 5) on the primary interface.
{ config, lib, pkgs, inputs, ... }: { config, lib, pkgs, inputs, ... }:
{ {
# Minimal container networking (systemd-networkd) # Minimal container networking (systemd-networkd)