1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 02:39:48 +01:00

home-manager: use hostname from GNU inetutils

This partially reverts commit 89670e27e1.

Co-authored-by: Johannes Maier <johannes.maier@mailbox.org>
This commit is contained in:
Bryan Lai 2024-08-17 14:10:12 +08:00 committed by Robert Helgesson
parent 2b1957a0a3
commit c82fc8cf3f
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
2 changed files with 3 additions and 12 deletions

View file

@ -1,5 +1,5 @@
{ runCommand, lib, bash, callPackage, coreutils, findutils, gettext, gnused, jq
, less, ncurses, unixtools
, less, ncurses, inetutils
# used for pkgs.path for nixos-option
, pkgs
@ -38,7 +38,7 @@ in runCommand "home-manager" {
less
ncurses
nixos-option
unixtools.hostname
inetutils # for `hostname`
]
}" \
--subst-var-by HOME_MANAGER_LIB '${../lib/bash/home-manager.sh}' \

View file

@ -198,18 +198,9 @@ function setFlakeAttribute() {
;;
*)
local name="$USER"
local hostnameArray=()
# FQDN lookup can fail depending on the resolver.
local fqdn
if fqdn="$(hostname -f 2> /dev/null)"; then
hostnameArray+=( "$USER@$fqdn" )
fi
# Check FQDN, long, and short hostnames; long first to preserve
# pre-existing behaviour in case both happen to be defined.
hostnameArray+=( "$USER@$(hostname)" "$USER@$(hostname -s)" )
for n in "${hostnameArray[@]}"; do
for n in "$USER@$(hostname -f)" "$USER@$(hostname)" "$USER@$(hostname -s)"; do
if [[ "$(nix eval "$flake#homeConfigurations" --apply "x: x ? \"$n\"")" == "true" ]]; then
name="$n"
if [[ -v VERBOSE ]]; then