Merge branch 'master' of github.com:NixOS/nix into validPathInfo-ca-proper-datatype
This commit is contained in:
commit
744ce9ce16
|
@ -227,10 +227,15 @@ MultiCommand::MultiCommand(const Commands & commands)
|
||||||
{
|
{
|
||||||
expectedArgs.push_back(ExpectedArg{"command", 1, true, [=](std::vector<std::string> ss) {
|
expectedArgs.push_back(ExpectedArg{"command", 1, true, [=](std::vector<std::string> ss) {
|
||||||
assert(!command);
|
assert(!command);
|
||||||
auto i = commands.find(ss[0]);
|
auto cmd = ss[0];
|
||||||
|
if (auto alias = get(deprecatedAliases, cmd)) {
|
||||||
|
warn("'%s' is a deprecated alias for '%s'", cmd, *alias);
|
||||||
|
cmd = *alias;
|
||||||
|
}
|
||||||
|
auto i = commands.find(cmd);
|
||||||
if (i == commands.end())
|
if (i == commands.end())
|
||||||
throw UsageError("'%s' is not a recognised command", ss[0]);
|
throw UsageError("'%s' is not a recognised command", cmd);
|
||||||
command = {ss[0], i->second()};
|
command = {cmd, i->second()};
|
||||||
}});
|
}});
|
||||||
|
|
||||||
categories[Command::catDefault] = "Available commands";
|
categories[Command::catDefault] = "Available commands";
|
||||||
|
|
|
@ -235,6 +235,8 @@ public:
|
||||||
|
|
||||||
std::map<Command::Category, std::string> categories;
|
std::map<Command::Category, std::string> categories;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> deprecatedAliases;
|
||||||
|
|
||||||
// Selected command, if any.
|
// Selected command, if any.
|
||||||
std::optional<std::pair<std::string, ref<Command>>> command;
|
std::optional<std::pair<std::string, ref<Command>>> command;
|
||||||
|
|
||||||
|
|
|
@ -459,8 +459,7 @@ string base64Encode(const string & s);
|
||||||
string base64Decode(const string & s);
|
string base64Decode(const string & s);
|
||||||
|
|
||||||
|
|
||||||
/* Get a value for the specified key from an associate container, or a
|
/* Get a value for the specified key from an associate container. */
|
||||||
default value if the key doesn't exist. */
|
|
||||||
template <class T>
|
template <class T>
|
||||||
std::optional<typename T::mapped_type> get(const T & map, const typename T::key_type & key)
|
std::optional<typename T::mapped_type> get(const T & map, const typename T::key_type & key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,7 +110,7 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
|
||||||
|
|
||||||
auto builder = baseNameOf(drv.builder);
|
auto builder = baseNameOf(drv.builder);
|
||||||
if (builder != "bash")
|
if (builder != "bash")
|
||||||
throw Error("'nix dev-shell' only works on derivations that use 'bash' as their builder");
|
throw Error("'nix develop' only works on derivations that use 'bash' as their builder");
|
||||||
|
|
||||||
auto getEnvShPath = store->addTextToStore("get-env.sh", getEnvSh, {});
|
auto getEnvShPath = store->addTextToStore("get-env.sh", getEnvSh, {});
|
||||||
|
|
||||||
|
@ -233,11 +233,11 @@ struct Common : InstallableCommand, MixProfile
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmdDevShell : Common, MixEnvironment
|
struct CmdDevelop : Common, MixEnvironment
|
||||||
{
|
{
|
||||||
std::vector<std::string> command;
|
std::vector<std::string> command;
|
||||||
|
|
||||||
CmdDevShell()
|
CmdDevelop()
|
||||||
{
|
{
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "command",
|
.longName = "command",
|
||||||
|
@ -261,15 +261,15 @@ struct CmdDevShell : Common, MixEnvironment
|
||||||
return {
|
return {
|
||||||
Example{
|
Example{
|
||||||
"To get the build environment of GNU hello:",
|
"To get the build environment of GNU hello:",
|
||||||
"nix dev-shell nixpkgs.hello"
|
"nix develop nixpkgs.hello"
|
||||||
},
|
},
|
||||||
Example{
|
Example{
|
||||||
"To store the build environment in a profile:",
|
"To store the build environment in a profile:",
|
||||||
"nix dev-shell --profile /tmp/my-shell nixpkgs.hello"
|
"nix develop --profile /tmp/my-shell nixpkgs.hello"
|
||||||
},
|
},
|
||||||
Example{
|
Example{
|
||||||
"To use a build environment previously recorded in a profile:",
|
"To use a build environment previously recorded in a profile:",
|
||||||
"nix dev-shell /tmp/my-shell"
|
"nix develop /tmp/my-shell"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -343,4 +343,4 @@ struct CmdPrintDevEnv : Common
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto r1 = registerCommand<CmdPrintDevEnv>("print-dev-env");
|
static auto r1 = registerCommand<CmdPrintDevEnv>("print-dev-env");
|
||||||
static auto r2 = registerCommand<CmdDevShell>("dev-shell");
|
static auto r2 = registerCommand<CmdDevelop>("develop");
|
|
@ -28,4 +28,4 @@ $(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote))
|
||||||
|
|
||||||
src/nix-env/user-env.cc: src/nix-env/buildenv.nix.gen.hh
|
src/nix-env/user-env.cc: src/nix-env/buildenv.nix.gen.hh
|
||||||
|
|
||||||
src/nix/dev-shell.cc: src/nix/get-env.sh.gen.hh
|
src/nix/develop.cc: src/nix/get-env.sh.gen.hh
|
||||||
|
|
|
@ -110,6 +110,8 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
||||||
.description = "consider all previously downloaded files out-of-date",
|
.description = "consider all previously downloaded files out-of-date",
|
||||||
.handler = {[&]() { refresh = true; }},
|
.handler = {[&]() { refresh = true; }},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deprecatedAliases.insert({"dev-shell", "develop"});
|
||||||
}
|
}
|
||||||
|
|
||||||
void printFlags(std::ostream & out) override
|
void printFlags(std::ostream & out) override
|
||||||
|
|
Loading…
Reference in a new issue