home-manager: make sure Nix profiles path exists

The Nix profiles path may not exist right after installing Nix. In
that case, it is created on demand by the Nix CLI tools. However, Home
Manager assumes it exists and fails if it doesn't.

This change makes sure to trigger the creation of the Nix profiles
path before attempting to access it.
This commit is contained in:
midchildan 2023-04-14 02:03:41 +09:00 committed by Robert Helgesson
parent 28698126bd
commit fe1e2dee19
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -105,6 +105,9 @@ _i "Starting Home Manager activation"
$VERBOSE_RUN _i "Sanity checking Nix"
nix-build --expr '{}' --no-out-link
# Also make sure that the Nix profiles path is created.
nix-env -q > /dev/null 2>&1
migrateProfile
setupVars