1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

nix-env: Create ~/.nix-profile automatically

This commit is contained in:
Eelco Dolstra 2019-10-09 19:21:07 +02:00
parent 26762ceb86
commit 9348f9291e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
9 changed files with 31 additions and 42 deletions

View file

@ -1422,9 +1422,14 @@ static int _main(int argc, char * * argv)
if (globals.profile == "") {
Path profileLink = getHome() + "/.nix-profile";
globals.profile = pathExists(profileLink)
? absPath(readLink(profileLink), dirOf(profileLink))
: canonPath(settings.nixStateDir + "/profiles/default");
if (!pathExists(profileLink)) {
replaceSymlink(
getuid() == 0
? settings.nixStateDir + "/profiles/default"
: fmt("%s/profiles/per-user/%s/profile", settings.nixStateDir, getUserName()),
profileLink);
}
globals.profile = absPath(readLink(profileLink), dirOf(profileLink));
}
op(globals, opFlags, opArgs);