From 1b589257f72c9c54e92d1d631e988e5346156736 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Wed, 29 May 2024 15:02:35 -0700 Subject: [PATCH] home-manager: check FQDN for '--flake .' attribute Since nixpkgs commit 993baa587c4b82e791686f6ce711bcd4ee8ef933, `networking.hostName` is not allowed to be a FQDN. Add `hostname --fqdn` to the default flake attribute names that are searched. If netorking.hostname = "hostname"; networking.domain = "example.com"; is set in the system NixOS configuration, this allows defining homeConfigurations."username@hostname.example.com" = ... and still use home-manager switch --flake . instead of having to type out home-manager switch --flake .#$(whoami)@$(hostname --fqdn) --- home-manager/home-manager | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 1c3b87f0..612df6f4 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -198,9 +198,9 @@ function setFlakeAttribute() { ;; *) local name="$USER" - # Check both long and short hostnames; long first to preserve + # Check FQDN, long, and short hostnames; long first to preserve # pre-existing behaviour in case both happen to be defined. - for n in "$USER@$(hostname)" "$USER@$(hostname -s)"; do + for n in "$USER@$(hostname --fqdn)" "$USER@$(hostname)" "$USER@$(hostname -s)"; do if [[ "$(nix eval "$flake#homeConfigurations" --apply "x: x ? \"$n\"")" == "true" ]]; then name="$n" if [[ -v VERBOSE ]]; then