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, 8 insertions, 23 deletions
diff --git a/src/nix-channel/nix-channel.cc b/src/nix-channel/nix-channel.cc
index 8b66cc7e3..70aa5c966 100755
--- a/src/nix-channel/nix-channel.cc
+++ b/src/nix-channel/nix-channel.cc
@@ -86,10 +86,12 @@ 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.
- std::string effectiveUrl;
+ CachedDownloadRequest request(url);
+ request.ttl = 0;
auto dl = getDownloader();
- auto filename = dl->downloadCached(store, url, false, "", Hash(), &effectiveUrl, 0);
- url = chomp(std::move(effectiveUrl));
+ auto result = dl->downloadCached(store, request);
+ auto filename = result.path;
+ url = chomp(result.effectiveUri);
// If the URL contains a version number, append it to the name
// attribute (so that "nix-env -q" on the channels profile
@@ -111,22 +113,11 @@ static void update(const StringSet & channelNames)
}
if (!unpacked) {
- // The URL doesn't unpack directly, so let's try treating it like a full channel folder with files in it
- // Check if the channel advertises a binary cache.
- DownloadRequest request(url + "/binary-cache-url");
- try {
- auto dlRes = dl->download(request);
- extraAttrs = "binaryCacheURL = \"" + *dlRes.data + "\";";
- } catch (DownloadError & e) {
- }
-
// Download the channel tarball.
- auto fullURL = url + "/nixexprs.tar.xz";
try {
- filename = dl->downloadCached(store, fullURL, false);
+ filename = dl->downloadCached(store, CachedDownloadRequest(url + "/nixexprs.tar.xz")).path;
} catch (DownloadError & e) {
- fullURL = url + "/nixexprs.tar.bz2";
- filename = dl->downloadCached(store, fullURL, false);
+ filename = dl->downloadCached(store, CachedDownloadRequest(url + "/nixexprs.tar.bz2")).path;
}
chomp(filename);
}
@@ -168,13 +159,7 @@ static int _main(int argc, char ** argv)
nixDefExpr = home + "/.nix-defexpr";
// Figure out the name of the channels profile.
- ;
- auto pw = getpwuid(geteuid());
- 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";
- createDirs(dirOf(profile));
+ profile = fmt("%s/profiles/per-user/%s/channels", settings.nixStateDir, getUserName());
enum {
cNone,