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
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" 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. # This module configures the network for the stateless kiosk using base networking (no systemd-networkd).
# 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)
networking = { networking = {
useNetworkd = true; useNetworkd = false;
networkmanager.enable = false; networkmanager.enable = false;
dhcpcd.enable = false; dhcpcd.enable = true;
useDHCP = false; useDHCP = false;
useHostResolvConf = false; useHostResolvConf = false;
};
systemd.network = { # Set up VLAN 5 on the primary interface (assume eth0, adjust if needed)
enable = true; vlans.vlan5 = {
wait-online.enable = true; id = 5;
interface = "eth0";
networks."10-wired" = {
matchConfig.Type = "ether";
networkConfig = {
LinkLocalAddressing = false;
DHCP = "no";
VLAN = [ "vlan5" ];
};
linkConfig.RequiredForOnline = "no";
}; };
netdevs."20-vlan5" = { interfaces.vlan5 = {
netdevConfig = { useDHCP = true;
Kind = "vlan";
Name = "vlan5";
};
vlanConfig.Id = 5;
};
networks."30-vlan5" = {
matchConfig.Name = "vlan5";
networkConfig = {
DHCP = "ipv4";
IPv6AcceptRA = true;
};
linkConfig.RequiredForOnline = "routable";
}; };
}; };
# Disable systemd-networkd and systemd-hostnamed
systemd.network.enable = false;
} }

View File

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