updates / experimental TC setup

This commit is contained in:
2026-10-24 10:44:58 +02:00
parent 3c25fc5d41
commit d36b281a4d
48 changed files with 1147 additions and 718 deletions
+149 -52
View File
@@ -36,11 +36,42 @@ Quick reference:
| Monitoring | node_exporter → Pushgateway, Alloy → Loki (journal), Snipe-IT asset check-in (daily 03:30) |
| Rollout | Pilot: 3 hosts, 2 weeks; then 5 → 10 → rest |
## AZ-TC-01 pilot status
Confirmed infrastructure values for the pilot (`hosts/AZ-TC-01/default.nix`):
- AD DNS domain: `az-group.local`
- Kerberos realm: `AZ-GROUP.LOCAL`
- DCs: `azdc01.az-group.local` (`192.168.152.253`) and `adpdc01.az-group.local` (`192.168.152.254`)
- Computer objects currently use the default `CN=Computers` container.
- Pilot WiFi uses WPA-Personal SSID `Pluto`; `Saturn` EAP-TLS is deferred.
## Provisioning workflow for a new Fleet Host
Assuming you've copied `hosts/AZ-TC-01/default.nix` to
`hosts/AZ-TC-NN/default.nix`, updated `networking.hostName`, added the
flake entry, and committed.
Copy `hosts/AZ-TC-01/default.nix` to `hosts/AZ-TC-NN/default.nix` and
update the hostname, site, hardware class and target disk. Thin Client
host directories are discovered automatically; no manual flake entry is
required.
For a lab installation use `site = "staging"` and explicitly enable only
integrations whose infrastructure values and secrets are available. The
`production` site enables AD, WiFi, NetBird, RustDesk and monitoring by
default.
### Step 0 — Create the host age identity
Each host uses a dedicated age identity rather than its SSH host key. This
avoids a first-boot dependency on an SSH key that does not exist yet.
```bash
mkdir -p .secrets/identities
age-keygen -o .secrets/identities/AZ-TC-01.age
age-keygen -y .secrets/identities/AZ-TC-01.age
```
Add the printed `age1...` recipient to `secrets.nix` and use it as the host
recipient for all AZ-TC-01 secrets. The private identity is ignored by Git
and is copied to `/var/lib/agenix/identity.age` only during provisioning.
### Step 1 — Pre-create the AD computer account + keytab
@@ -48,49 +79,63 @@ Run from a host that can reach the AD DC (e.g. `AZ-LT-NIX`). Requires
`adcli` (available on the admin workstation via `nix-shell -p adcli` if
not installed).
Prerequisite: the target OU must exist in AD. If `OU=ThinClients,...`
doesn't exist yet, create it first (or omit `--domain-ou` to use the
default `CN=Computers,...` container).
For AZ-TC-01, no `ThinClients` OU exists yet, so the computer account is
created in the default `CN=Computers` container (omit `--domain-ou`).
```bash
# Pre-create the computer object in the ThinClients OU
adcli preset-computer \
--domain=az-group.local \
--domain-ou="OU=ThinClients,DC=az-group,DC=local" \
--os-name="NixOS" --os-version="26.05" \
--login-user=administrator \
AZ-TC-01.az-group.local
# Check AD discovery and clock before joining
nix shell nixpkgs#adcli nixpkgs#krb5 nixpkgs#bind -c bash
dig +short SRV _kerberos._tcp.az-group.local @192.168.152.253
dig +short SRV _ldap._tcp.dc._msdcs.az-group.local @192.168.152.253
timedatectl status
# Produce a keytab for that pre-created computer object.
# --host-fqdn redirects adcli from the local machine to the AZ-TC-01
# account; -K writes only to the specified path (does NOT modify the
# local machine's /etc/krb5.keytab).
# Obtain an administrator Kerberos ticket
kinit administrator@AZ-GROUP.LOCAL
klist
# Create the computer account and binary keytab in one step
umask 077
adcli join \
--domain=az-group.local \
--domain-controller=azdc01.az-group.local \
--host-fqdn=AZ-TC-01.az-group.local \
--os-name="NixOS" --os-version="26.05" \
--login-user=administrator \
-K /tmp/AZ-TC-01.keytab
--computer-name=AZ-TC-01 \
--os-name=NixOS \
--os-version=26.05 \
--login-ccache="${KRB5CCNAME:-/tmp/krb5cc_$(id -u)}" \
--host-keytab=/tmp/AZ-TC-01.keytab \
--verbose
# Verify the keytab has expected principals
klist -k /tmp/AZ-TC-01.keytab
# Expected principals:
# AZ-TC-01$@AZ-GROUP
# host/AZ-TC-01.az-group.local@AZ-GROUP
# RestrictedKrbHost/AZ-TC-01.az-group.local@AZ-GROUP
# HOST/AZ-TC-01@AZ-GROUP
# RestrictedKrbHost/AZ-TC-01@AZ-GROUP
# Provision the agenix secret
agenix -e secrets/AZ-TC-01-krb5-keytab.age
# In the editor: paste /tmp/AZ-TC-01.keytab contents, save, exit.
rm /tmp/AZ-TC-01.keytab
# Validate the binary keytab before encryption
klist -k -e /tmp/AZ-TC-01.keytab
# Expected principals include:
# AZ-TC-01$@AZ-GROUP.LOCAL
# host/AZ-TC-01.az-group.local@AZ-GROUP.LOCAL
```
Tip: if you already have an admin TGT (via `kinit administrator@AZ-GROUP`),
you can replace `--login-user=administrator` with
`--login-ccache=${KRB5CCNAME:-/tmp/krb5cc_$(id -u)}` to skip the password
prompt.
**Never paste a binary keytab into an editor.** Encrypt it directly and
verify the round trip before committing:
```bash
agenix -e secrets/AZ-TC-01-krb5-keytab.age < /tmp/AZ-TC-01.keytab
verified_keytab="$(mktemp)"
chmod 0600 "$verified_keytab"
trap 'rm -f "$verified_keytab" /tmp/AZ-TC-01.keytab' EXIT
nix shell nixpkgs#age -c age --decrypt \
-i .secrets/identities/AZ-TC-01.age \
secrets/AZ-TC-01-krb5-keytab.age \
> "$verified_keytab"
nix shell nixpkgs#krb5 -c klist -k -e "$verified_keytab"
rm -f "$verified_keytab" /tmp/AZ-TC-01.keytab
trap - EXIT
```
If the installed `adcli` only exposes the short option for the keytab
path, replace `--host-keytab=/tmp/AZ-TC-01.keytab` with
`-K /tmp/AZ-TC-01.keytab` after confirming via `adcli join --help`.
### Step 2 — Provision NetBird setup key
@@ -101,7 +146,7 @@ In the NetBird UI (`https://netbird.az-group.local`):
3. Copy the key value.
4. `agenix -e secrets/AZ-TC-01-netbird-setupkey.age` → paste the key.
### Step 3 — Provision WiFi client certificate
### Step 3 — Provision WiFi client certificate (`Saturn`, deferred for AZ-TC-01)
In AD CS (`https://certsrv.az-group.local/certsrv`):
@@ -117,6 +162,35 @@ In AD CS (`https://certsrv.az-group.local/certsrv`):
6. `agenix -e secrets/AZ-TC-01-wifi-client-cert.age` → paste the PEM.
### Step 3b — Bootstrap on the temporary `Pluto` PSK network (AZ-TC-01 pilot)
While the `Saturn` EAP-TLS certificate is deferred, AZ-TC-01 connects to
the temporary WPA-Personal network `Pluto` instead
(`az.tc.wifi.mode = "psk"`, see `roles/thin-client/network/wifi.nix`).
Enter the password locally, without putting it in shell history or chat:
```bash
read -rsp 'Pluto WiFi password: ' WIFI_PSK
printf '\n'
printf '%s' "$WIFI_PSK" | nix develop --command agenix -e secrets/AZ-TC-01-wifi-psk.age
unset WIFI_PSK
```
Do not use `echo`, because it may add an unintended trailing newline to
the PSK. Verify the host identity can decrypt the secret without printing
it:
```bash
nix shell nixpkgs#age -c age --decrypt \
-i .secrets/identities/AZ-TC-01.age \
secrets/AZ-TC-01-wifi-psk.age \
| test -s /dev/stdin
```
The password must never be committed in plaintext or sent through chat —
only the encrypted `.age` file is safe to commit.
### Step 4 — Provision RustDesk credentials
```bash
@@ -133,17 +207,28 @@ The shared `rustdesk-psk.age` is one-time setup, reused for all hosts.
### Step 5 — Provision the host
Boot the OptiPlex from a stock Linux ISO (any modern NixOS installer ISO
or Ubuntu live ISO works). From the admin workstation:
or Ubuntu live ISO works). Set a temporary root password on the installer
and ensure its SSH service is running:
```bash
# Bootstrap nixos-anywhere into the booted ISO (via SSH or physical console)
# Then run the install:
nixos-anywhere \
--flake .#AZ-TC-01 \
--disko-config ./roles/thin-client/deployment/disko.nix \
root@<target-ip>
passwd
```
Then run the deployment from the admin workstation:
```bash
# Non-destructive local and remote preflight
nix run .#deploy -- --check AZ-TC-01 root@<target-ip>
# Install after showing the target hardware and confirming disk erasure
nix run .#deploy -- AZ-TC-01 root@<target-ip>
```
The wrapper accepts the installer's new host key in an isolated temporary
file and leaves `~/.ssh/known_hosts` unchanged. SSH may ask for the temporary
root password more than once during preflight and installation; no SSH key
needs to be provisioned on the installer.
The host will:
1. Partition the disk via disko (BTRFS layout).
@@ -152,16 +237,27 @@ The host will:
4. On first boot: agenix decrypts secrets, sssd starts with keytab,
NetBird enrolls via setup key, WiFi connects via EAP-TLS.
### Step 6 — Capture the host's SSH host key
The wrapper refuses to install if the selected host does not evaluate, the
configured target disk does not exist, a required secret is empty, or the
host age identity cannot decrypt an enabled feature's secret.
After first boot:
### Post-boot AD and WiFi checks
After first boot, run this operator checklist to confirm the pilot came
up healthy:
```bash
ssh-keyscan -t ed25519 AZ-TC-01.netbird | awk '{print $2 " " $3}'
nmcli --fields NAME,TYPE,DEVICE connection show --active
resolvectl query azdc01.az-group.local adpdc01.az-group.local
systemctl --no-pager --full status sssd
sssctl domain-status az-group.local
getent passwd '<known-ad-user>'
id '<known-ad-user>'
```
Update `secrets.nix` with the real `AZ-TC-01` SSH key value (replacing
the `PLACEHOLDER` line). Rebuild and redeploy.
Replace `<known-ad-user>` with a real non-administrator test account.
Test offline login (disconnect network, log in from SSSD's credential
cache) only after one successful online login with that account.
## Option reference
@@ -173,6 +269,7 @@ All tunable parameters live under `az.tc.*`:
| `az.tc.hardwareClass` | `generic-x86_64-uefi` | One of `dell-optiplex-micro` or `generic-x86_64-uefi` |
| `az.tc.site` | `default` | Site identifier (informational) |
| `az.tc.ad.ou` | `OU=ThinClients,DC=az-group,DC=local` | AD Organizational Unit for computer objects |
| `az.tc.wifi.mode` | `eap-tls` | WiFi authentication mode: `psk` (temporary WPA-Personal) or `eap-tls` |
| `az.tc.wifi.ssid` | `AZ-CORP` | Corp WiFi SSID |
| `az.tc.wifi.caCert` | `./assets/corp-wifi-ca.pem` | Corp CA cert (NOT secret) |
| `az.tc.netbird.managementUrl` | `https://netbird.az-group.local:443` | NetBird server URL |
@@ -218,8 +315,8 @@ with `# TODO:` in the respective modules.
- [ ] Real IT-Hotline phone number
- [ ] Real corporate wallpaper asset (replace placeholder SVG)
- [ ] Real corporate logo asset (replace placeholder SVG)
- [ ] Real AD DCs (`az-dc01.az-group.local`, `az-dc02.az-group.local` — currently guessed)
- [ ] Real AD Computer OU DN
- [ ] Real AD Computer OU DN (AZ-TC-01 currently uses the default `CN=Computers` container)
- [ ] Real `Saturn` EAP-TLS certificate for AZ-TC-01 (currently on temporary WPA-Personal `Pluto`)
## Build validation
+7 -2
View File
@@ -3,7 +3,12 @@
# RustDesk client (Hilfe annehmen) + daemon (unattended support).
# Q13 decisions: Beides (Client+Daemon), Self-hosted Server, Pre-Shared Key
# via agenix, Wayland portal pre-authorized, Permanent password via agenix.
{config, lib, pkgs, ...}: let
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf mkOption types;
cfg = config.az.tc;
hostname = config.networking.hostName;
@@ -21,7 +26,7 @@ in {
};
};
config = mkIf cfg.enable {
config = mkIf (cfg.enable && cfg.features.rustdesk) {
environment = {
systemPackages = with pkgs; [rustdesk];
+24 -10
View File
@@ -21,6 +21,7 @@
cfg = config.az.tc;
in {
imports = [
../../sites
./hardware
./session
./identity
@@ -44,13 +45,18 @@ in {
'';
};
site = lib.mkOption {
features = lib.genAttrs ["ad" "wifi" "netbird" "rustdesk" "monitoring"] (name:
lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether the ${name} integration is enabled for this Thin Client.";
});
ageIdentityPath = lib.mkOption {
type = lib.types.str;
default = "default";
description = ''
Site identifier (e.g. "BER", "MUC"). Currently informational;
reserved for per-site printer maps or branding variations.
'';
default = "/var/lib/agenix/identity.age";
readOnly = true;
description = "Dedicated per-host age identity injected during provisioning.";
};
};
@@ -69,7 +75,13 @@ in {
nix = {
settings = {
experimental-features = "nix-command flakes";
trusted-users = ["root"];
# @wheel is required so admins can deploy via
# `nixos-rebuild --target-host ... --sudo` — the SSH user copies
# the closure as themselves (not root), and the remote daemon
# rejects unsigned locally-built paths (e.g. etc files) unless
# the receiving user is trusted. Both break-glass admins are in
# wheel (see identity/local-users.nix).
trusted-users = ["root" "@wheel"];
};
gc = {
automatic = true;
@@ -82,6 +94,8 @@ in {
# Thin Clients are managed centrally; users do not run nix commands.
users.defaultUserShell = pkgs.bash;
age.identityPaths = lib.mkForce [cfg.ageIdentityPath];
# Console / i18n / time — matches AZ-LT-NIX conventions.
i18n.defaultLocale = "de_DE.UTF-8";
time.timeZone = "Europe/Berlin";
@@ -114,7 +128,7 @@ in {
message = "az.tc.enable requires networking.hostName to be set (e.g. 'AZ-TC-01').";
}
{
assertion = cfg.enable -> config.az.tc.wifi.ssid != "AZ-CORP" || config.az.tc.site == "staging";
assertion = (!cfg.features.wifi) || config.az.tc.wifi.ssid != "AZ-CORP";
message = ''
az.tc.wifi.ssid is still the placeholder 'AZ-CORP'. Set the
real corp WiFi SSID in hosts/AZ-TC-NN/default.nix (or set
@@ -122,11 +136,11 @@ in {
'';
}
{
assertion = cfg.enable -> config.az.tc.branding.hotline != "+49 30 1234567" || config.az.tc.site == "staging";
assertion = cfg.site == "staging" || config.az.tc.branding.hotline != "+49 30 1234567";
message = "az.tc.branding.hotline is still the placeholder — set the real IT-Hotline number.";
}
{
assertion = cfg.enable -> config.az.tc.branding.company != "AzIntec GmbH" || config.az.tc.site == "staging";
assertion = cfg.site == "staging" || config.az.tc.branding.company != "AzIntec GmbH";
message = "az.tc.branding.company is still the placeholder 'AzIntec GmbH' — set the real company name.";
}
];
@@ -2,7 +2,11 @@
#
# Q18 decision: Auto-Upgrade pro Host daily, Generation-Picker + BTRFS-
# Snapshot für Rollback, Auto-Reboot nach Kernel-Update.
{config, lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib) mkIf;
cfg = config.az.tc;
in {
@@ -14,7 +18,6 @@ in {
flake = "git+https://code.m3ta.dev/m3tam3re/AZ-NIX-CLIENTS";
flags = [
"--no-write-lock-file"
"--refresh"
];
allowReboot = true;
rebootWindow = {
+8 -1
View File
@@ -11,7 +11,11 @@
#
# This module sets `disko.devices` so the config can be referenced both
# for partitioning (nixos-anywhere --disko) and for fstab generation.
{config, lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib) mkIf mkOption types;
cfg = config.az.tc;
in {
@@ -37,6 +41,9 @@ in {
disk.main = {
type = "disk";
device = config.az.tc.deployment.diskDevice;
# Disko's VM test defaults to a 2 GiB image. That cannot contain
# our 512 MiB ESP, 4 GiB swap and BTRFS root partition.
imageSize = "8G";
content = {
type = "gpt";
partitions = {
@@ -20,7 +20,7 @@
loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true;
initrd.kernelModules = ["i915" "snd_hda_intel"];
kernelModules = ["i915" "thinkpad_acpi" "coretemp"];
kernelModules = ["i915" "coretemp"];
kernelParams = [
# Quiet boot for kiosk-like feel
"quiet"
@@ -28,7 +28,6 @@
# Avoid rare i915 glitches on Skylake
"i915.enable_guc=2"
];
kernelPackages = pkgs.linuxPackages_latest;
};
services.xserver.videoDrivers = ["modesetting"];
@@ -3,7 +3,11 @@
# Fallback hardware class for any UEFI-bootable x86_64 mini-PC that isn't
# explicitly listed. Used during pilot if a new SKU shows up, prevents
# deploy from blocking.
{config, lib, pkgs, ...}: {
{
config,
lib,
...
}: {
config = lib.mkIf (config.az.tc.enable && config.az.tc.hardwareClass == "generic-x86_64-uefi") {
boot = {
loader.systemd-boot.enable = true;
@@ -11,7 +15,6 @@
initrd.kernelModules = ["i915" "amdgpu" "snd_hda_intel"];
kernelModules = ["kvm-intel" "kvm-amd" "coretemp"];
kernelParams = ["quiet"];
kernelPackages = pkgs.linuxPackages_latest;
};
services.xserver.videoDrivers = ["modesetting" "amdgpu"];
+39 -10
View File
@@ -36,10 +36,33 @@
}: let
cfg = config.az.tc;
hostname = config.networking.hostName;
domain = "az-group.local";
realm = "AZ-GROUP";
domain = cfg.ad.domain;
realm = cfg.ad.realm;
in {
options.az.tc.ad = {
domain = lib.mkOption {
type = lib.types.str;
default = "az-group.local";
description = "Active Directory DNS domain.";
};
realm = lib.mkOption {
type = lib.types.str;
default = "AZ-GROUP";
description = "Kerberos realm.";
};
domainControllers = lib.mkOption {
type = lib.types.listOf (lib.types.submodule {
options = {
host = lib.mkOption {type = lib.types.str;};
address = lib.mkOption {type = lib.types.str;};
};
});
default = [];
description = "AD domain controllers with bootstrap-safe IP addresses.";
};
ou = lib.mkOption {
type = lib.types.str;
default = "OU=ThinClients,DC=az-group,DC=local";
@@ -51,7 +74,13 @@ in {
};
};
config = lib.mkIf cfg.enable {
config = lib.mkIf (cfg.enable && cfg.features.ad) {
assertions = [
{
assertion = cfg.ad.domainControllers != [];
message = "az.tc.features.ad requires az.tc.ad.domainControllers with host names and IP addresses.";
}
];
environment.systemPackages = with pkgs; [
adcli # AD computer-account precreate + join helper
sssd # AD client daemon
@@ -82,8 +111,8 @@ in {
};
realms = {
"${realm}" = {
kdc = ["az-dc01.az-group.local" "az-dc02.az-group.local"];
admin_server = "az-dc01.az-group.local";
kdc = map (dc: dc.host) cfg.ad.domainControllers;
admin_server = (builtins.head cfg.ad.domainControllers).host;
};
};
};
@@ -113,9 +142,9 @@ in {
access_provider = ad
chpass_provider = ad
ad_domain = ${domain}
ad_server = az-dc01.az-group.local, az-dc02.az-group.local
ad_server = ${lib.concatMapStringsSep ", " (dc: dc.host) cfg.ad.domainControllers}
krb5_realm = ${realm}
krb5_server = az-dc01.az-group.local, az-dc02.az-group.local
krb5_server = ${lib.concatMapStringsSep ", " (dc: dc.host) cfg.ad.domainControllers}
krb5_keytab = /etc/krb5.keytab
krb5_store_password_if_offline = True
cache_credentials = True
@@ -124,14 +153,14 @@ in {
override_shell = /run/current-system/sw/bin/bash
default_shell = /run/current-system/sw/bin/bash
ad_gpo_access_control = permissive
enumerate = true
ldap_id_mapping = false
enumerate = false
ldap_id_mapping = true
'';
};
# DNS — Thin Clients use AD DCs as resolver (NetBird DNS overlays
# for corp-VPN-only domains via systemd-resolved; see network/dns.nix)
networking.nameservers = lib.mkDefault ["az-dc01.az-group.local" "az-dc02.az-group.local"];
networking.nameservers = lib.mkDefault (map (dc: dc.address) cfg.ad.domainControllers);
networking.domain = lib.mkDefault domain;
networking.search = lib.mkDefault [domain];
+7 -2
View File
@@ -2,7 +2,12 @@
#
# Q19 decisions: Prometheus node_exporter + Loki promtail (now: Alloy) +
# NetBird Inventory + Asset-Management-Tool (default: Snipe-IT).
{config, lib, pkgs, ...}: let
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf mkOption types;
cfg = config.az.tc;
in {
@@ -43,7 +48,7 @@ in {
# Stored in agenix under secrets/snipeit-api-token.age.
};
config = mkIf cfg.enable {
config = mkIf (cfg.enable && cfg.features.monitoring) {
services.prometheus.exporters.node = {
enable = true;
enabledCollectors = ["systemd" "processes" "tcpstat"];
+10 -5
View File
@@ -4,17 +4,22 @@
# for NetBird-managed domains via systemd-resolved.
#
# Q15 decision: "Corp DNS + NetBird DNS parallel".
{config, lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib) mkIf;
cfg = config.az.tc;
in {
config = mkIf cfg.enable {
config = mkIf (cfg.enable && cfg.features.ad) {
services.resolved = {
enable = true;
domains = ["~${cfg.ad.domain}"];
fallbackDns = ["9.9.9.9" "1.1.1.1"];
llmnr = "false";
settings.Resolve = {
Domains = ["az-group.local"];
FallbackDNS = ["9.9.9.9" "1.1.1.1"];
LLMNR = "no";
DNS = lib.concatStringsSep " " (map (dc: dc.address) cfg.ad.domainControllers);
MulticastDNS = "no";
};
};
+6 -2
View File
@@ -1,7 +1,11 @@
# roles/thin-client/network/firewall.nix
#
# Hardened firewall: deny all inbound except NetBird interface and ICMP.
{config, lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib) mkIf;
cfg = config.az.tc;
in {
@@ -15,7 +19,7 @@ in {
# NetBird's WireGuard port (allowed by NetBird service itself,
# but make explicit here).
interfaces."wt0".allowedTCPPorts = []; # NetBird userspace daemon
interfaces."wt0".allowedTCPPorts = lib.mkIf cfg.features.netbird [22];
trustedInterfaces = ["lo"];
checkReversePath = "loose";
};
+9 -4
View File
@@ -5,7 +5,12 @@
# Client-only + accept-routes.
#
# SSH via NetBird: enabled (Q7).
{config, lib, pkgs, ...}: let
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf mkOption types;
cfg = config.az.tc;
hostname = config.networking.hostName;
@@ -29,7 +34,7 @@ in {
};
};
config = mkIf cfg.enable {
config = mkIf (cfg.enable && cfg.features.netbird) {
services.netbird.enable = true;
systemd.services.netbird = {
@@ -40,8 +45,8 @@ in {
};
path = with pkgs; [shadow util-linux];
after = ["age-identity.service" "network-online.target"];
wants = ["age-identity.service" "network-online.target"];
after = ["age-identity.service" "NetworkManager-wait-online.service"];
wants = ["age-identity.service" "NetworkManager-wait-online.service"];
};
# Per-host setup key (agenix)
+153 -69
View File
@@ -13,12 +13,23 @@
# CA cert is NOT secret — checked into the repo as a public file under
# roles/thin-client/network/assets/corp-wifi-ca.pem. Replace placeholder
# with real AD CS root cert.
{config, lib, pkgs, ...}: let
inherit (lib) mkIf mkOption types;
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf mkMerge mkOption types;
cfg = config.az.tc;
hostname = config.networking.hostName;
in {
options.az.tc.wifi = {
mode = mkOption {
type = types.enum ["psk" "eap-tls"];
default = "eap-tls";
description = "WiFi authentication mode: temporary WPA-Personal PSK or machine EAP-TLS.";
};
ssid = mkOption {
type = types.str;
default = "AZ-CORP"; # TODO: real SSID
@@ -36,82 +47,155 @@ in {
};
};
config = mkIf cfg.enable {
# Disable iwd explicitly — wpa_supplicant is the backend we use.
# Note: NetworkManager with `wifi.backend = "wpa_supplicant"` automatically
# sets networking.wireless.enable = true (it owns wpa_supplicant).
networking.wireless.iwd.enable = false;
config = mkIf (cfg.enable && cfg.features.wifi) (mkMerge [
{
# Disable iwd explicitly — wpa_supplicant is the backend we use.
# Note: NetworkManager with `wifi.backend = "wpa_supplicant"` automatically
# sets networking.wireless.enable = true (it owns wpa_supplicant).
networking.wireless.iwd.enable = false;
networking.networkmanager = {
enable = true;
wifi.backend = "wpa_supplicant";
};
networking.networkmanager = {
enable = true;
wifi.backend = "wpa_supplicant";
};
# Declarative NetworkManager profile for corp WiFi (EAP-TLS).
# NixOS has no built-in `ensureProfiles` option in the
# `networking.networkmanager` namespace, so we write the
# `.nmconnection` file directly to the system-connections dir.
# NetworkManager picks it up on restart.
environment.etc."NetworkManager/system-connections/${config.az.tc.wifi.ssid}.nmconnection".source =
pkgs.writeText "${config.az.tc.wifi.ssid}.nmconnection" ''
[connection]
id=${config.az.tc.wifi.ssid}
type=wifi
autoconnect=true
permissions=
systemd.tmpfiles.rules = [
"d /etc/wifi 0700 root root -"
"d /run/NetworkManager/system-connections 0700 root root -"
];
[wifi]
mode=infrastructure
ssid=${config.az.tc.wifi.ssid}
# Directory for the cert — NetworkManager reads it as root.
# Ensure wpa_supplicant doesn't try to use the cert/PSK before
# agenix decrypted it.
systemd.services.NetworkManager = {
after = ["age-identity.service"];
wants = ["age-identity.service"];
};
}
[wifi-security]
key-mgmt=wpa-eap
(mkIf (cfg.wifi.mode == "eap-tls") {
# Declarative NetworkManager profile for corp WiFi (EAP-TLS).
# NixOS has no built-in `ensureProfiles` option in the
# `networking.networkmanager` namespace, so we write the
# `.nmconnection` file directly to the system-connections dir.
# NetworkManager picks it up on restart.
environment.etc."NetworkManager/system-connections/${cfg.wifi.ssid}.nmconnection" = {
mode = "0600";
source = pkgs.writeText "${cfg.wifi.ssid}.nmconnection" ''
[connection]
id=${cfg.wifi.ssid}
type=wifi
autoconnect=true
permissions=
[802-1x]
eap=tls
identity=${hostname}$
ca-cert=${config.az.tc.wifi.caCert}
client-cert=/etc/wifi/client.pem
private-key=/etc/wifi/client.pem
private-key-password=
phase2-auth=
[wifi]
mode=infrastructure
ssid=${cfg.wifi.ssid}
[ipv4]
method=auto
[wifi-security]
key-mgmt=wpa-eap
[ipv6]
method=auto
'';
[802-1x]
eap=tls
identity=${hostname}$
ca-cert=${cfg.wifi.caCert}
client-cert=/etc/wifi/client.pem
private-key=/etc/wifi/client.pem
private-key-password=
phase2-auth=
# `environment.etc` files are owned by root but world-readable by
# default — make this profile root-only since it references the cert
# path (the cert itself is root-only via agenix).
systemd.tmpfiles.rules = [
"d /etc/wifi 0700 root root -"
];
[ipv4]
method=auto
# NOTE: We intentionally do NOT add the WiFi CA to
# security.pki.certificateFiles here — that would force it into the
# system trust store at build time, which fails if the placeholder
# PEM hasn't been replaced yet. NetworkManager references the CA
# directly via the `ca-cert=` key in the .nmconnection profile, which
# is sufficient for 802.1X EAP-TLS. Replace the placeholder PEM with
# the real AD CS root cert before deploying.
[ipv6]
method=auto
'';
};
# Per-host client cert (via agenix)
age.secrets."${hostname}-wifi-client-cert" = {
file = ../../../secrets/${hostname}-wifi-client-cert.age;
path = "/etc/wifi/client.pem";
mode = "0600";
owner = "root";
group = "root";
};
# `environment.etc` files are owned by root but world-readable by
# default — make this profile root-only since it references the cert
# path (the cert itself is root-only via agenix).
# Directory for the cert — NetworkManager reads it as root.
# Ensure wpa_supplicant doesn't try to use the cert before agenix decrypted it.
systemd.services.NetworkManager-wait-online = {
after = ["age-identity.service"];
wants = ["age-identity.service"];
};
};
# NOTE: We intentionally do NOT add the WiFi CA to
# security.pki.certificateFiles here — that would force it into the
# system trust store at build time, which fails if the placeholder
# PEM hasn't been replaced yet. NetworkManager references the CA
# directly via the `ca-cert=` key in the .nmconnection profile, which
# is sufficient for 802.1X EAP-TLS. Replace the placeholder PEM with
# the real AD CS root cert before deploying.
# Per-host client cert (via agenix)
age.secrets."${hostname}-wifi-client-cert" = {
file = ../../../secrets/${hostname}-wifi-client-cert.age;
path = "/etc/wifi/client.pem";
mode = "0600";
owner = "root";
group = "root";
};
})
(mkIf (cfg.wifi.mode == "psk") {
# Temporary WPA-Personal PSK for pilot bootstrap (deferred EAP-TLS
# certificate). The keyfile is generated at runtime under /run,
# root-only, and never enters the Nix store. The PSK is read from
# the agenix runtime file and is never passed as a command-line
# argument.
age.secrets."${hostname}-wifi-psk" = {
file = ../../../secrets/${hostname}-wifi-psk.age;
mode = "0400";
owner = "root";
group = "root";
};
systemd.services.wifi-psk-provision = {
description = "Provision the ${cfg.wifi.ssid} WPA-Personal connection";
wantedBy = ["multi-user.target"];
after = ["NetworkManager.service" "age-identity.service"];
wants = ["NetworkManager.service" "age-identity.service"];
path = [pkgs.coreutils pkgs.networkmanager];
environment = {
WIFI_CONNECTION = "az-tc-${cfg.wifi.ssid}";
WIFI_SSID = cfg.wifi.ssid;
WIFI_PSK_FILE = config.age.secrets."${hostname}-wifi-psk".path;
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
script = ''
set -eu
test -s "$WIFI_PSK_FILE"
install -d -m 0700 /run/NetworkManager/system-connections
profile="/run/NetworkManager/system-connections/$WIFI_CONNECTION.nmconnection"
umask 077
{
printf '%s\n' \
'[connection]' \
"id=$WIFI_CONNECTION" \
'type=wifi' \
'autoconnect=true' \
''' \
'[wifi]' \
'mode=infrastructure' \
"ssid=$WIFI_SSID" \
''' \
'[wifi-security]' \
'key-mgmt=wpa-psk'
printf 'psk='
cat "$WIFI_PSK_FILE"
printf '%s\n' \
''' \
'[ipv4]' \
'method=auto' \
''' \
'[ipv6]' \
'method=auto'
} > "$profile"
chmod 0600 "$profile"
nmcli connection reload
nmcli connection up id "$WIFI_CONNECTION"
'';
};
})
]);
}
+6 -2
View File
@@ -1,7 +1,11 @@
# roles/thin-client/peripherals/default.nix
{config, lib, ...}: {
{
config,
lib,
...
}: {
imports = [
./printing.nix
# ./printing.nix
./smb-mounts.nix
];
}
+1 -1
View File
@@ -68,7 +68,7 @@ in {
environment.systemPackages = with pkgs; [
# Thin-client baseline utilities
kitty
ark
kdePackages.ark
kdePackages.kcalc
kdePackages.spectacle
kdePackages.filelight