Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f93e890b4d19
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 30370f168fef
Choose a head ref
  • 5 commits
  • 12 files changed
  • 2 contributors

Commits on Jan 26, 2018

  1. HttpBinaryCacheStore: Support upsertFile with PUT.

    Some servers, such as Artifactory, allow uploading with PUT and BASIC
    auth. This allows nix copy to work to upload binaries to those
    servers.
    
    Worked on together with @adelbertc
    shlevy committed Jan 26, 2018
    Copy the full SHA
    1d5d277 View commit details

Commits on Jan 31, 2018

  1. Indent properly

    edolstra committed Jan 31, 2018
    Copy the full SHA
    478e3e4 View commit details
  2. Manual: Remove old cruft

    edolstra committed Jan 31, 2018
    Copy the full SHA
    f8e8dd8 View commit details
  3. Copy the full SHA
    6270b2e View commit details
  4. Cleanup

    edolstra committed Jan 31, 2018
    Copy the full SHA
    30370f1 View commit details
34 changes: 0 additions & 34 deletions doc/manual/expressions/debug-build.xml

This file was deleted.

2 changes: 0 additions & 2 deletions doc/manual/expressions/simple-building-testing.xml
Original file line number Diff line number Diff line change
@@ -81,6 +81,4 @@ Just pass the option <link linkend='opt-max-jobs'><option>-j
in parallel, or set. Typically this should be the number of
CPUs.</para>

<xi:include href="debug-build.xml" />

</section>
10 changes: 0 additions & 10 deletions doc/manual/installation/installing-binary.xml
Original file line number Diff line number Diff line change
@@ -79,16 +79,6 @@ alice$ ./install

</para>

<para>Nix can be uninstalled using <command>rpm -e nix</command> or
<command>dpkg -r nix</command> on RPM- and Dpkg-based systems,
respectively. After this you should manually remove the Nix store and
other auxiliary data, if desired:

<screen>
$ rm -rf /nix</screen>

</para>

<para>You can uninstall Nix simply by running:

<screen>
3 changes: 0 additions & 3 deletions doc/manual/installation/supported-platforms.xml
Original file line number Diff line number Diff line change
@@ -33,7 +33,4 @@

</para>

<para>Nix is fairly portable, so it should work on most platforms that
support POSIX threads and have a C++11 compiler.</para>

</chapter>
2 changes: 1 addition & 1 deletion doc/manual/introduction/quick-start.xml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ to subsequent chapters.</para>
<step><para>Install single-user Nix by running the following:

<screen>
$ curl https://nixos.org/nix/install | sh
$ bash &lt;(curl https://nixos.org/nix/install)
</screen>

This will install Nix in <filename>/nix</filename>. The install script
6 changes: 1 addition & 5 deletions doc/manual/manual.xml
Original file line number Diff line number Diff line change
@@ -12,14 +12,11 @@
<firstname>Eelco</firstname>
<surname>Dolstra</surname>
</personname>
<affiliation>
<orgname>LogicBlox</orgname>
</affiliation>
<contrib>Author</contrib>
</author>

<copyright>
<year>2004-2014</year>
<year>2004-2017</year>
<holder>Eelco Dolstra</holder>
</copyright>

@@ -41,7 +38,6 @@
<xi:include href="expressions/writing-nix-expressions.xml" />
<xi:include href="advanced-topics/advanced-topics.xml" />
<xi:include href="command-ref/command-ref.xml" />
<xi:include href="troubleshooting/troubleshooting.xml" />
<xi:include href="glossary/glossary.xml" />
<xi:include href="hacking.xml" />
<xi:include href="release-notes/release-notes.xml" />
38 changes: 0 additions & 38 deletions doc/manual/troubleshooting/collisions-nixenv.xml

This file was deleted.

43 changes: 0 additions & 43 deletions doc/manual/troubleshooting/links-nix-store.xml

This file was deleted.

16 changes: 0 additions & 16 deletions doc/manual/troubleshooting/troubleshooting.xml

This file was deleted.

34 changes: 30 additions & 4 deletions src/libstore/download.cc
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
#include <thread>
#include <cmath>
#include <random>
#include <algorithm>

using namespace std::string_literals;

@@ -91,6 +92,8 @@ struct CurlDownloader : public Downloader
{
if (!request.expectedETag.empty())
requestHeaders = curl_slist_append(requestHeaders, ("If-None-Match: " + request.expectedETag).c_str());
if (!request.mimeType.empty())
requestHeaders = curl_slist_append(requestHeaders, ("Content-Type: " + request.mimeType).c_str());
}

~DownloadItem()
@@ -185,6 +188,22 @@ struct CurlDownloader : public Downloader
return 0;
}

size_t readOffset = 0;
int readCallback(char *buffer, size_t size, size_t nitems)
{
if (readOffset == request.data->length())
return 0;
auto count = std::min(size * nitems, request.data->length() - readOffset);
memcpy(buffer, request.data->data() + readOffset, count);
readOffset += count;
return count;
}

static int readCallbackWrapper(char *buffer, size_t size, size_t nitems, void * userp)
{
return ((DownloadItem *) userp)->readCallback(buffer, size, nitems);
}

long lowSpeedTimeout = 300;

void init()
@@ -225,6 +244,13 @@ struct CurlDownloader : public Downloader
if (request.head)
curl_easy_setopt(req, CURLOPT_NOBODY, 1);

if (request.data) {
curl_easy_setopt(req, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(req, CURLOPT_READFUNCTION, readCallbackWrapper);
curl_easy_setopt(req, CURLOPT_READDATA, this);
curl_easy_setopt(req, CURLOPT_INFILESIZE_LARGE, (curl_off_t) request.data->length());
}

if (request.verifyTLS) {
if (settings.caFile != "")
curl_easy_setopt(req, CURLOPT_CAINFO, settings.caFile.c_str());
@@ -265,7 +291,7 @@ struct CurlDownloader : public Downloader
}

if (code == CURLE_OK &&
(httpStatus == 200 || httpStatus == 304 || httpStatus == 226 /* FTP */ || httpStatus == 0 /* other protocol */))
(httpStatus == 200 || httpStatus == 201 || httpStatus == 204 || httpStatus == 304 || httpStatus == 226 /* FTP */ || httpStatus == 0 /* other protocol */))
{
result.cached = httpStatus == 304;
done = true;
@@ -312,10 +338,10 @@ struct CurlDownloader : public Downloader
case CURLE_BAD_FUNCTION_ARGUMENT:
case CURLE_INTERFACE_FAILED:
case CURLE_UNKNOWN_OPTION:
err = Misc;
break;
err = Misc;
break;
default: // Shut up warnings
break;
break;
}
}

2 changes: 2 additions & 0 deletions src/libstore/download.hh
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@ struct DownloadRequest
unsigned int baseRetryTimeMs = 250;
ActivityId parentAct;
bool decompress = true;
std::shared_ptr<std::string> data;
std::string mimeType;

DownloadRequest(const std::string & uri)
: uri(uri), parentAct(curActivity) { }
11 changes: 9 additions & 2 deletions src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ class HttpBinaryCacheStore : public BinaryCacheStore
try {
BinaryCacheStore::init();
} catch (UploadToHTTP &) {
throw Error(format("'%s' does not appear to be a binary cache") % cacheUri);
throw Error("'%s' does not appear to be a binary cache", cacheUri);
}
diskCache->createCache(cacheUri, storeDir, wantMassQuery_, priority);
}
@@ -67,7 +67,14 @@ class HttpBinaryCacheStore : public BinaryCacheStore
const std::string & data,
const std::string & mimeType) override
{
throw UploadToHTTP("uploading to an HTTP binary cache is not supported");
auto req = DownloadRequest(cacheUri + "/" + path);
req.data = std::make_shared<string>(data); // FIXME: inefficient
req.mimeType = mimeType;
try {
getDownloader()->download(req);
} catch (DownloadError & e) {
throw UploadToHTTP(format("uploading to HTTP binary cache at %1% not supported: %2%") % cacheUri % e.msg());
}
}

void getFile(const std::string & path,