unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: 18747@debbugs.gnu.org, Eelco Dolstra <eelco.dolstra@logicblox.com>
Cc: nix-dev@lists.science.uu.nl
Subject: bug#18747: [PATCH] Distinguish between “offloadability” and “substitutability”
Date: Wed, 01 Jul 2015 17:21:51 +0200	[thread overview]
Message-ID: <87d20boqcw.fsf_-___13911.6687736989$1435764204$gmane$org@gnu.org> (raw)
In-Reply-To: <87lhog3tmd.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 16 Oct 2014 17:46:18 +0200")

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]

Hi again,

Nix commit 55586527 (June 2013) changed the semantics of
‘preferLocalBuild’ from “avoid offloading this derivation” to “avoid
offloading *or substituting* this derivation” (see
<http://bugs.gnu.org/18747>.)

This patch introduces a new special key, ‘substitution’, to specify
whether a derivation should be substituted.  ‘preferLocalBuild’ is kept,
but its initial semantics is restored.

As a consequence, existing uses of ‘preferLocalBuild’ must be audited to
check what exactly is intended.

WDYT?

Thanks,
Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1636 bytes --]

diff --git a/nix/libstore/misc.cc b/nix/libstore/misc.cc
index 6ecf878..bdb7a6d 100644
--- a/nix/libstore/misc.cc
+++ b/nix/libstore/misc.cc
@@ -67,6 +67,15 @@ Path findOutput(const Derivation & drv, string id)
 }
 
 
+/* Return true if we are allowed to substitute DRV.  This is the case, unless
+   DRV specifies 'substitution = "0"' in its environment.  */
+static bool substitutionAllowed(const Derivation & drv)
+{
+    auto env = drv.env;
+    auto i = env.find("substitution");
+    return i == env.end() || i->second != "0";
+}
+
 void queryMissing(StoreAPI & store, const PathSet & targets,
     PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
     unsigned long long & downloadSize, unsigned long long & narSize)
@@ -120,7 +129,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
                 if (invalid.empty()) continue;
 
                 todoDrv.insert(*i);
-                if (settings.useSubstitutes && !willBuildLocally(drv))
+                if (settings.useSubstitutes && substitutionAllowed(drv))
                     query.insert(invalid.begin(), invalid.end());
             }
 
@@ -144,7 +153,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
 
             PathSet outputs;
             bool mustBuild = false;
-            if (settings.useSubstitutes && !willBuildLocally(drv)) {
+            if (settings.useSubstitutes && substitutionAllowed(drv)) {
                 foreach (DerivationOutputs::iterator, j, drv.outputs) {
                     if (!wantOutput(j->first, i2.second)) continue;
                     if (!store.isValidPath(j->second.path)) {

  reply	other threads:[~2015-07-01 15:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-16 15:26 bug#18747: Fixed-output derivations are not substituted Ludovic Courtès
2014-10-16 15:43 ` Ludovic Courtès
2014-10-16 15:46   ` Ludovic Courtès
2015-07-01 15:21     ` Ludovic Courtès [this message]
     [not found]     ` <87d20boqcw.fsf_-_@gnu.org>
2015-07-01 15:27       ` bug#18747: [PATCH] Distinguish between “offloadability” and “substitutability” Eelco Dolstra
     [not found]       ` <559406C6.7040209@logicblox.com>
2015-07-01 21:14         ` Ludovic Courtès
2015-07-02 22:33     ` bug#18747: Fixed-output derivations are not substituted Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='87d20boqcw.fsf_-___13911.6687736989$1435764204$gmane$org@gnu.org' \
    --to=ludo@gnu.org \
    --cc=18747@debbugs.gnu.org \
    --cc=eelco.dolstra@logicblox.com \
    --cc=nix-dev@lists.science.uu.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).