Skip to content

Commit

Permalink
detect-hostname-change: improve installer detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzime committed Jan 21, 2025
1 parent db87013 commit 8141ef1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nixos/common/detect-hostname-change.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

config = lib.mkIf (config.srvos.detect-hostname-change.enable && config.networking.hostName != "") {
system.preSwitchChecks.detectHostnameChange = ''
actual=$(< /proc/sys/kernel/hostname)
# Ignore if the system is getting installed
if [[ ! -e /run/current-system ]]; then
# https://github.com/nix-community/nixos-anywhere/blob/97b45ac774699b1cfd267e98a8bdecb74bace593/src/get-facts.sh#L12
if grep -Eq 'VARIANT_ID="?installer"?' /etc/os-release || [[ ! -e /run/current-system ]]; then
exit
fi
actual=$(< /proc/sys/kernel/hostname)
desired=${config.networking.hostName}
if [[ "$actual" = "$desired" ]]; then
exit
fi
Expand Down

0 comments on commit 8141ef1

Please sign in to comment.