aboutsummaryrefslogtreecommitdiff
path: root/src/nix-channel/nix-channel.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-channel/nix-channel.cc')
-rwxr-xr-xsrc/nix-channel/nix-channel.cc31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/nix-channel/nix-channel.cc b/src/nix-channel/nix-channel.cc
index ec9a7174e..c34f1d4b4 100755
--- a/src/nix-channel/nix-channel.cc
+++ b/src/nix-channel/nix-channel.cc
@@ -10,8 +10,8 @@ using namespace nix;
typedef std::map<string,string> Channels;
-static auto channels = Channels{};
-static auto channelsList = Path{};
+static Channels channels;
+static Path channelsList;
// Reads the list of channels.
static void readChannels()
@@ -52,7 +52,7 @@ static void addChannel(const string & url, const string & name)
writeChannels();
}
-static auto profile = Path{};
+static Path profile;
// Remove a channel.
static void removeChannel(const string & name)
@@ -64,7 +64,7 @@ static void removeChannel(const string & name)
runProgram(settings.nixBinDir + "/nix-env", true, { "--profile", profile, "--uninstall", name });
}
-static auto nixDefExpr = Path{};
+static Path nixDefExpr;
// Fetch Nix expressions and binary cache URLs from the subscribed channels.
static void update(const StringSet & channelNames)
@@ -74,7 +74,7 @@ static void update(const StringSet & channelNames)
auto store = openStore();
// Download each channel.
- auto exprs = Strings{};
+ Strings exprs;
for (const auto & channel : channels) {
auto name = channel.first;
auto url = channel.second;
@@ -84,7 +84,7 @@ static void update(const StringSet & channelNames)
// We want to download the url to a file to see if it's a tarball while also checking if we
// got redirected in the process, so that we can grab the various parts of a nix channel
// definition from a consistent location if the redirect changes mid-download.
- auto effectiveUrl = string{};
+ std::string effectiveUrl;
auto dl = getDownloader();
auto filename = dl->downloadCached(store, url, false, "", Hash(), &effectiveUrl);
url = chomp(std::move(effectiveUrl));
@@ -99,9 +99,9 @@ static void update(const StringSet & channelNames)
cname = cname + (string) match[1];
}
- auto extraAttrs = string{};
+ std::string extraAttrs;
- auto unpacked = false;
+ bool unpacked = false;
if (std::regex_search(filename, std::regex("\\.tar\\.(gz|bz2|xz)$"))) {
runProgram(settings.nixBinDir + "/nix-build", false, { "--no-out-link", "--expr", "import <nix/unpack-channel.nix> "
"{ name = \"" + cname + "\"; channelName = \"" + name + "\"; src = builtins.storePath \"" + filename + "\"; }" });
@@ -136,7 +136,7 @@ static void update(const StringSet & channelNames)
// Unpack the channel tarballs into the Nix store and install them
// into the channels profile.
std::cerr << "unpacking channels...\n";
- auto envArgs = Strings{ "--profile", profile, "--file", "<nix/unpack-channel.nix>", "--install", "--from-expression" };
+ Strings envArgs{ "--profile", profile, "--file", "<nix/unpack-channel.nix>", "--install", "--from-expression" };
for (auto & expr : exprs)
envArgs.push_back(std::move(expr));
envArgs.push_back("--quiet");
@@ -173,12 +173,9 @@ int main(int argc, char ** argv)
nixDefExpr = home + "/.nix-defexpr";
// Figure out the name of the channels profile.
- auto name = string{};
+ ;
auto pw = getpwuid(getuid());
- if (!pw)
- name = getEnv("USER", "");
- else
- name = pw->pw_name;
+ std::string name = pw ? pw->pw_name : getEnv("USER", "");
if (name.empty())
throw Error("cannot figure out user name");
profile = settings.nixStateDir + "/profiles/per-user/" + name + "/channels";
@@ -192,7 +189,7 @@ int main(int argc, char ** argv)
cUpdate,
cRollback
} cmd = cNone;
- auto args = std::vector<string>{};
+ std::vector<string> args;
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
if (*arg == "--help") {
showManPage("nix-channel");
@@ -224,7 +221,7 @@ int main(int argc, char ** argv)
throw UsageError("'--add' requires one or two arguments");
{
auto url = args[0];
- auto name = string{};
+ std::string name;
if (args.size() == 2) {
name = args[1];
} else {
@@ -253,7 +250,7 @@ int main(int argc, char ** argv)
case cRollback:
if (args.size() > 1)
throw UsageError("'--rollback' has at most one argument");
- auto envArgs = Strings{"--profile", profile};
+ Strings envArgs{"--profile", profile};
if (args.size() == 1) {
envArgs.push_back("--switch-generation");
envArgs.push_back(args[0]);