working on the stateless kiosk, dynamic hostnames work now!

This commit is contained in:
UGA Innovation Factory
2025-12-12 16:46:31 -05:00
parent d583fac582
commit 5ba8dce77b
3 changed files with 27 additions and 37 deletions

View File

@@ -56,7 +56,17 @@ let
fi
fi
sleep 2
# Wait for the URL to resolve, up to 30 seconds
timeout=30
elapsed=0
while ! ${pkgs.curl}/bin/curl -sf --max-time 2 "$URL" >/dev/null; do
sleep 1
elapsed=$((elapsed+1))
if [ "$elapsed" -ge "$timeout" ]; then
echo "ERROR: $URL did not resolve after $timeout seconds" >&2
exit 1
fi
done
exec ${pkgs.chromium}/bin/chromium --kiosk --noerrdialogs --disable-infobars --disable-session-crashed-bubble "$URL"
'';

View File

@@ -1,45 +1,24 @@
# This module configures the network for the stateless kiosk.
# It uses systemd-networkd to set up a VLAN (ID 5) on the primary interface.
# This module configures the network for the stateless kiosk using base networking (no systemd-networkd).
{ config, lib, pkgs, inputs, ... }:
{
# Minimal container networking (systemd-networkd)
networking = {
useNetworkd = true;
useNetworkd = false;
networkmanager.enable = false;
dhcpcd.enable = false;
dhcpcd.enable = true;
useDHCP = false;
useHostResolvConf = false;
};
systemd.network = {
enable = true;
wait-online.enable = true;
networks."10-wired" = {
matchConfig.Type = "ether";
networkConfig = {
LinkLocalAddressing = false;
DHCP = "no";
VLAN = [ "vlan5" ];
};
linkConfig.RequiredForOnline = "no";
# Set up VLAN 5 on the primary interface (assume eth0, adjust if needed)
vlans.vlan5 = {
id = 5;
interface = "eth0";
};
netdevs."20-vlan5" = {
netdevConfig = {
Kind = "vlan";
Name = "vlan5";
};
vlanConfig.Id = 5;
};
networks."30-vlan5" = {
matchConfig.Name = "vlan5";
networkConfig = {
DHCP = "ipv4";
IPv6AcceptRA = true;
};
linkConfig.RequiredForOnline = "routable";
interfaces.vlan5 = {
useDHCP = true;
};
};
# Disable systemd-networkd and systemd-hostnamed
systemd.network.enable = false;
}

View File

@@ -30,8 +30,8 @@ in
systemd.services.dynamic-hostname = {
description = "Set hostname based on MAC address";
wantedBy = [ "sysinit.target" ];
wants = [ "default.target" ];
after = [ "default.target" ];
before = [ "network-pre.target" ];
wants = [ "network-pre.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
@@ -44,10 +44,11 @@ in
case "$MAC" in
${shellCases}
*) NEW_HOST="nix-station-unregistered" ;;
*) NEW_HOST="nix-station-anon" ;;
esac
${pkgs.nettools}/bin/hostname "$NEW_HOST"
'';
};
};