1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

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