forked from lix-project/lix
nix develop --phase: chdir to flake directory
For git+file and path flakes, chdir to flake directory so that phases that expect to be in the flake directory can run Fixes https://github.com/NixOS/nix/issues/3976
This commit is contained in:
parent
ffa629b2c0
commit
d7fe36116e
|
@ -9,6 +9,7 @@
|
||||||
#include "progress-bar.hh"
|
#include "progress-bar.hh"
|
||||||
#include "run.hh"
|
#include "run.hh"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
@ -505,6 +506,20 @@ struct CmdDevelop : Common, MixEnvironment
|
||||||
auto args = phase || !command.empty() ? Strings{std::string(baseNameOf(shell)), rcFilePath}
|
auto args = phase || !command.empty() ? Strings{std::string(baseNameOf(shell)), rcFilePath}
|
||||||
: Strings{std::string(baseNameOf(shell)), "--rcfile", rcFilePath};
|
: Strings{std::string(baseNameOf(shell)), "--rcfile", rcFilePath};
|
||||||
|
|
||||||
|
// Need to chdir since phases assume in flake directory
|
||||||
|
if (phase) {
|
||||||
|
// chdir if installable is a flake of type git+file or path
|
||||||
|
auto installableFlake = std::dynamic_pointer_cast<InstallableFlake>(installable);
|
||||||
|
if (installableFlake) {
|
||||||
|
auto sourcePath = installableFlake->getLockedFlake()->flake.resolvedRef.input.getSourcePath();
|
||||||
|
if (sourcePath) {
|
||||||
|
if (chdir(sourcePath->c_str()) == -1) {
|
||||||
|
throw SysError("chdir to '%s' failed", *sourcePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runProgramInStore(store, shell, args);
|
runProgramInStore(store, shell, args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue