forked from lix-project/lix
Merge pull request #8735 from obsidiansystems/defexpr
Factor out `nix-defexpr` path computation
This commit is contained in:
commit
584ff408a4
|
@ -63,7 +63,7 @@ Strings EvalSettings::getDefaultNixPath()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!evalSettings.restrictEval && !evalSettings.pureEval) {
|
if (!evalSettings.restrictEval && !evalSettings.pureEval) {
|
||||||
add(settings.useXDGBaseDirectories ? getStateDir() + "/nix/defexpr/channels" : getHome() + "/.nix-defexpr/channels");
|
add(getNixDefExpr() + "/channels");
|
||||||
add(rootChannelsDir() + "/nixpkgs", "nixpkgs");
|
add(rootChannelsDir() + "/nixpkgs", "nixpkgs");
|
||||||
add(rootChannelsDir());
|
add(rootChannelsDir());
|
||||||
}
|
}
|
||||||
|
@ -92,4 +92,11 @@ EvalSettings evalSettings;
|
||||||
|
|
||||||
static GlobalConfig::Register rEvalSettings(&evalSettings);
|
static GlobalConfig::Register rEvalSettings(&evalSettings);
|
||||||
|
|
||||||
|
Path getNixDefExpr()
|
||||||
|
{
|
||||||
|
return settings.useXDGBaseDirectories
|
||||||
|
? getStateDir() + "/nix/defexpr"
|
||||||
|
: getHome() + "/.nix-defexpr";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,4 +95,9 @@ struct EvalSettings : Config
|
||||||
|
|
||||||
extern EvalSettings evalSettings;
|
extern EvalSettings evalSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conventionally part of the default nix path in impure mode.
|
||||||
|
*/
|
||||||
|
Path getNixDefExpr();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "legacy.hh"
|
#include "legacy.hh"
|
||||||
#include "fetchers.hh"
|
#include "fetchers.hh"
|
||||||
|
#include "eval-settings.hh" // for defexpr
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -165,7 +166,7 @@ static int main_nix_channel(int argc, char ** argv)
|
||||||
// Figure out the name of the `.nix-channels' file to use
|
// Figure out the name of the `.nix-channels' file to use
|
||||||
auto home = getHome();
|
auto home = getHome();
|
||||||
channelsList = settings.useXDGBaseDirectories ? createNixStateDir() + "/channels" : home + "/.nix-channels";
|
channelsList = settings.useXDGBaseDirectories ? createNixStateDir() + "/channels" : home + "/.nix-channels";
|
||||||
nixDefExpr = settings.useXDGBaseDirectories ? createNixStateDir() + "/defexpr" : home + "/.nix-defexpr";
|
nixDefExpr = getNixDefExpr();
|
||||||
|
|
||||||
// Figure out the name of the channels profile.
|
// Figure out the name of the channels profile.
|
||||||
profile = profilesDir() + "/channels";
|
profile = profilesDir() + "/channels";
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "value-to-json.hh"
|
#include "value-to-json.hh"
|
||||||
#include "xml-writer.hh"
|
#include "xml-writer.hh"
|
||||||
#include "legacy.hh"
|
#include "legacy.hh"
|
||||||
|
#include "eval-settings.hh" // for defexpr
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -1399,7 +1400,7 @@ static int main_nix_env(int argc, char * * argv)
|
||||||
globals.instSource.type = srcUnknown;
|
globals.instSource.type = srcUnknown;
|
||||||
globals.instSource.systemFilter = "*";
|
globals.instSource.systemFilter = "*";
|
||||||
|
|
||||||
Path nixExprPath = settings.useXDGBaseDirectories ? createNixStateDir() + "/defexpr" : getHome() + "/.nix-defexpr";
|
Path nixExprPath = getNixDefExpr();
|
||||||
|
|
||||||
if (!pathExists(nixExprPath)) {
|
if (!pathExists(nixExprPath)) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue