diff --git a/lix/nix/main.cc b/lix/nix/main.cc index 9fb620abb..053df9b01 100644 --- a/lix/nix/main.cc +++ b/lix/nix/main.cc @@ -26,6 +26,7 @@ #include "nix-instantiate.hh" #include "nix-store.hh" #include "prefetch-command.hh" +#include "run.hh" #include #include @@ -35,10 +36,6 @@ #include -extern std::string chrootHelperName; - -void chrootHelper(int argc, char * * argv); - namespace nix { void registerLegacyCommands() diff --git a/lix/nix/run.cc b/lix/nix/run.cc index 02fa1a306..2953bdf91 100644 --- a/lix/nix/run.cc +++ b/lix/nix/run.cc @@ -11,6 +11,7 @@ #include "lix/libexpr/eval.hh" #include "lix/libstore/build/personality.hh" #include "lix/libutil/current-process.hh" +#include "run.hh" #if __linux__ #include "lix/libstore/temporary-dir.hh" @@ -19,10 +20,6 @@ #include -using namespace nix; - -std::string chrootHelperName = "__run_in_chroot"; - namespace nix { void runProgramInStore(ref store, @@ -50,7 +47,7 @@ void runProgramInStore(ref store, if (store->config().storeDir != store2->getRealStoreDir()) { Strings helperArgs = { - chrootHelperName, + std::string(chrootHelperName), store->config().storeDir, store2->getRealStoreDir(), std::string(system.value_or("")), @@ -74,8 +71,6 @@ void runProgramInStore(ref store, throw SysError("unable to execute '%s'", program); } -} - struct CmdShell : InstallablesCommand, MixEnvironment { @@ -306,3 +301,5 @@ void chrootHelper(int argc, char * * argv) throw Error("mounting the Nix store on '%s' is not supported on this platform", storeDir); #endif } + +} diff --git a/lix/nix/run.hh b/lix/nix/run.hh index a169734ae..3f1baf1bd 100644 --- a/lix/nix/run.hh +++ b/lix/nix/run.hh @@ -5,15 +5,18 @@ namespace nix { -enum struct UseSearchPath { - Use, - DontUse -}; +static constexpr std::string_view chrootHelperName = "__run_in_chroot"; -void runProgramInStore(ref store, +void chrootHelper(int argc, char ** argv); + +enum struct UseSearchPath { Use, DontUse }; + +void runProgramInStore( + ref store, UseSearchPath useSearchPath, const std::string & program, const Strings & args, - std::optional system = std::nullopt); + std::optional system = std::nullopt +); }