diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-24 14:26:13 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-24 14:34:47 +0100 |
commit | 0a10854f857e519d1455ff0f0be1f8401c40a11c (patch) | |
tree | 64cd9b1c0727eb0642574e4535c5ba61af497c3a /src/libstore/profiles.cc | |
parent | c85097da7c1ef06e2f1912c922110ff358de3aa2 (diff) |
Misc changes from the flakes branch
Diffstat (limited to 'src/libstore/profiles.cc')
-rw-r--r-- | src/libstore/profiles.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc index dae3f2d32..2bef51878 100644 --- a/src/libstore/profiles.cc +++ b/src/libstore/profiles.cc @@ -256,4 +256,22 @@ string optimisticLockProfile(const Path & profile) } +Path getDefaultProfile() +{ + Path profileLink = getHome() + "/.nix-profile"; + try { + if (!pathExists(profileLink)) { + replaceSymlink( + getuid() == 0 + ? settings.nixStateDir + "/profiles/default" + : fmt("%s/profiles/per-user/%s/profile", settings.nixStateDir, getUserName()), + profileLink); + } + return absPath(readLink(profileLink), dirOf(profileLink)); + } catch (Error &) { + return profileLink; + } +} + + } |