forked from lix-project/lix
make profile querying logic more consistent (?)
Change-Id: I00a4a8ba7f3a33aa191383f745f5a1395602e938
This commit is contained in:
parent
06eaea6ea3
commit
a93667433f
|
@ -169,7 +169,7 @@ static int main_nix_channel(int argc, char ** argv)
|
|||
nixDefExpr = getNixDefExpr();
|
||||
|
||||
// Figure out the name of the channels profile.
|
||||
profile = profilesDir() + "/channels";
|
||||
profile = defaultChannelsDir();
|
||||
createDirs(dirOf(profile));
|
||||
|
||||
enum {
|
||||
|
|
|
@ -503,7 +503,7 @@ static bool keep(DrvInfo & drv)
|
|||
static void installDerivations(Globals & globals,
|
||||
const Strings & args, const Path & profile)
|
||||
{
|
||||
debug("installing derivations");
|
||||
debug("installing derivations into profile %s", profile);
|
||||
|
||||
/* Get the set of user environment elements to be installed. */
|
||||
DrvInfos newElems, newElemsTmp;
|
||||
|
@ -554,8 +554,17 @@ static void installDerivations(Globals & globals,
|
|||
|
||||
if (globals.dryRun) return;
|
||||
|
||||
if (createUserEnv(*globals.state, allElems,
|
||||
profile, settings.envKeepDerivations, lockToken)) break;
|
||||
bool success = createUserEnv(
|
||||
*globals.state,
|
||||
allElems,
|
||||
profile,
|
||||
settings.envKeepDerivations,
|
||||
lockToken
|
||||
);
|
||||
|
||||
if (success) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1306,7 @@ static void opSwitchProfile(Globals & globals, Strings opFlags, Strings opArgs)
|
|||
throw UsageError("exactly one argument expected");
|
||||
|
||||
Path profile = absPath(opArgs.front());
|
||||
Path profileLink = settings.useXDGBaseDirectories ? createNixStateDir() + "/profile" : getHome() + "/.nix-profile";
|
||||
Path profileLink = getDefaultProfileLink();
|
||||
|
||||
switchLink(profileLink, profile);
|
||||
}
|
||||
|
@ -1463,8 +1472,10 @@ static int main_nix_env(int argc, char * * argv)
|
|||
op = opQuery;
|
||||
opName = "-query";
|
||||
}
|
||||
else if (*arg == "--profile" || *arg == "-p")
|
||||
else if (*arg == "--profile" || *arg == "-p") {
|
||||
// XXX: check
|
||||
globals.profile = absPath(getArg(*arg, arg, end));
|
||||
}
|
||||
else if (*arg == "--file" || *arg == "-f")
|
||||
file = getArg(*arg, arg, end);
|
||||
else if (*arg == "--switch-profile" || *arg == "-S") {
|
||||
|
@ -1528,11 +1539,15 @@ static int main_nix_env(int argc, char * * argv)
|
|||
|
||||
globals.instSource.autoArgs = myArgs.getAutoArgs(*globals.state);
|
||||
|
||||
if (globals.profile == "")
|
||||
if (globals.profile == "") {
|
||||
// XXX: refactor?
|
||||
globals.profile = getEnv("NIX_PROFILE").value_or("");
|
||||
}
|
||||
|
||||
if (globals.profile == "")
|
||||
globals.profile = getDefaultProfile();
|
||||
if (globals.profile == "") {
|
||||
// XXX: check
|
||||
globals.profile = ensureDefaultProfile();
|
||||
}
|
||||
|
||||
op(globals, std::move(opFlags), std::move(opArgs));
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
const Path & profile, bool keepDerivations,
|
||||
const std::string & lockToken)
|
||||
{
|
||||
debug("asked to create a user env %s for %u drvs", profile, elems.size());
|
||||
/* Build the components in the user environment, if they don't
|
||||
exist already. */
|
||||
std::vector<StorePathWithOutputs> drvsToBuild;
|
||||
|
@ -131,10 +132,11 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
state.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Switch the current user environment to the output path. */
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
auto localStore = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
|
||||
if (store2) {
|
||||
if (localStore) {
|
||||
PathLocks lock;
|
||||
debug("locking profile %s", profile);
|
||||
lockProfile(lock, profile);
|
||||
|
||||
Path lockTokenCur = optimisticLockProfile(profile);
|
||||
|
@ -144,7 +146,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
}
|
||||
|
||||
debug("switching to new user environment");
|
||||
Path generation = createGeneration(*store2, profile, topLevelOut);
|
||||
Path generation = createGeneration(*localStore, profile, topLevelOut);
|
||||
switchLink(profile, generation);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue