Skip to content

Commit

Permalink
home-manager: check FQDN for '--flake .' attribute
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
gauravjuvekar authored May 29, 2024
1 parent 04bc391 commit 1b58925
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions home-manager/home-manager
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b58925

Please sign in to comment.