1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

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)
This commit is contained in:
Gaurav Juvekar 2024-05-29 15:02:35 -07:00 committed by GitHub
parent 04bc391a90
commit 1b589257f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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