home-manager: fix early exit due to FQDN error

Since 89670e27e1, FQDN lookup errors
from `hostname -f` may cause an early exit of the whole program.

This commit fixes the problem by absorbing the FQDN query inside the
`if` statement.
This commit is contained in:
Bryan Lai 2024-08-16 13:42:11 +08:00 committed by Robert Helgesson
parent da8406a6ff
commit 2b1957a0a3
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -202,8 +202,7 @@ function setFlakeAttribute() {
local hostnameArray=()
# FQDN lookup can fail depending on the resolver.
local fqdn
fqdn="$(hostname -f 2> /dev/null)"
if [[ $? -eq 0 ]]; then
if fqdn="$(hostname -f 2> /dev/null)"; then
hostnameArray+=( "$USER@$fqdn" )
fi
# Check FQDN, long, and short hostnames; long first to preserve