Skip to content

Commit

Permalink
Merge pull request #601 from Enzime/improve-installer-detection
Browse files Browse the repository at this point in the history
detect-hostname-change: improve installer detection
  • Loading branch information
phaer authored Jan 21, 2025
2 parents db87013 + 3351e1b commit a3bf377
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-images/blob/2fc023e024c0a5e8e98ae94363dbf2962da10886/nix/installer.nix#L12-L13
if [[ ! -e /run/booted-system || "$actual" == "nixos-installer" ]]; then
exit
fi
actual=$(< /proc/sys/kernel/hostname)
desired=${config.networking.hostName}
if [[ "$actual" = "$desired" ]]; then
exit
fi
Expand Down

0 comments on commit a3bf377

Please sign in to comment.