summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/build.cc28
-rw-r--r--nix/libstore/builtins.cc10
-rw-r--r--nix/libstore/builtins.hh5
-rw-r--r--nix/local.mk24
4 files changed, 44 insertions, 23 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index e823001788..cebc404d1c 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1680,7 +1680,11 @@ void DerivationGoal::startBuilder()
             % drv.platform % settings.thisSystem % drvPath);
     }
 
-    useChroot = settings.useChroot;
+    /* Note: built-in builders are *not* running in a chroot environment so
+       that we can easily implement them in Guile without having it as a
+       derivation input (they are running under a separate build user,
+       though).  */
+    useChroot = settings.useChroot && !isBuiltin(drv);
 
     /* Construct the environment passed to the builder. */
     env.clear();
@@ -2048,12 +2052,7 @@ void DerivationGoal::runChild()
         commonChildInit(builderOut);
 
 #if CHROOT_ENABLED
-	/* Note: built-in builders are *not* running in a chroot environment
-	   so that we can easily implement them in Guile without having it as
-	   a derivation input (they are running under a separate build user,
-	   though).  */
-
-        if (useChroot && !isBuiltin(drv)) {
+        if (useChroot) {
             /* Initialise the loopback interface. */
             AutoCloseFD fd(socket(PF_INET, SOCK_DGRAM, IPPROTO_IP));
             if (fd == -1) throw SysError("cannot open IP socket");
@@ -2272,8 +2271,17 @@ void DerivationGoal::runChild()
                 logType = ltFlat;
 
 		auto buildDrv = lookupBuiltinBuilder(drv.builder);
-                if (buildDrv != NULL)
-                    buildDrv(drv, drvPath);
+                if (buildDrv != NULL) {
+		    /* Check what the output file name is.  When doing a
+		       'bmCheck' build, the output file name is different from
+		       that specified in DRV due to hash rewriting.  */
+		    Path output = drv.outputs["out"].path;
+		    auto redirected = redirectedOutputs.find(output);
+		    if (redirected != redirectedOutputs.end())
+			output = redirected->second;
+
+                    buildDrv(drv, drvPath, output);
+		}
                 else
                     throw Error(format("unsupported builtin function '%1%'") % string(drv.builder, 8));
                 _exit(0);
@@ -2743,6 +2751,8 @@ Path DerivationGoal::addHashRewrite(const Path & path)
     rewritesToTmp[h1] = h2;
     rewritesFromTmp[h2] = h1;
     redirectedOutputs[path] = p;
+    printMsg(lvlChatty, format("output '%1%' redirected to '%2%'")
+	     % path % p);
     return p;
 }
 
diff --git a/nix/libstore/builtins.cc b/nix/libstore/builtins.cc
index 32af767dc4..7ed75e5079 100644
--- a/nix/libstore/builtins.cc
+++ b/nix/libstore/builtins.cc
@@ -1,5 +1,5 @@
 /* GNU Guix --- Functional package management for GNU
-   Copyright (C) 2016 Ludovic Courtès <ludo@gnu.org>
+   Copyright (C) 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 
    This file is part of GNU Guix.
 
@@ -25,7 +25,8 @@
 namespace nix {
 
 static void builtinDownload(const Derivation &drv,
-			    const std::string &drvPath)
+			    const std::string &drvPath,
+			    const std::string &output)
 {
     /* Invoke 'guix perform-download'.  */
     Strings args;
@@ -35,7 +36,10 @@ static void builtinDownload(const Derivation &drv,
     /* Close all other file descriptors. */
     closeMostFDs(set<int>());
 
-    const char *const argv[] = { "download", drvPath.c_str(), NULL };
+    const char *const argv[] =
+      {
+	"download", drvPath.c_str(), output.c_str(), NULL
+      };
 
     /* XXX: Hack our way to use the 'download' script from 'LIBEXECDIR/guix'
        or just 'LIBEXECDIR', depending on whether we're running uninstalled or
diff --git a/nix/libstore/builtins.hh b/nix/libstore/builtins.hh
index 79171fcb6c..396ea14ebc 100644
--- a/nix/libstore/builtins.hh
+++ b/nix/libstore/builtins.hh
@@ -1,5 +1,5 @@
 /* GNU Guix --- Functional package management for GNU
-   Copyright (C) 2016 Ludovic Courtès <ludo@gnu.org>
+   Copyright (C) 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 
    This file is part of GNU Guix.
 
@@ -33,7 +33,8 @@ namespace nix {
 
     /* Build DRV, which lives at DRVPATH.  */
     typedef void (*derivationBuilder) (const Derivation &drv,
-				       const std::string &drvPath);
+				       const std::string &drvPath,
+				       const std::string &output);
 
     /* Return the built-in builder called BUILDER, or NULL if none was
        found.  */
diff --git a/nix/local.mk b/nix/local.mk
index 79667ed49e..eb70d266fb 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -22,7 +22,7 @@
 #
 
 BUILT_SOURCES += %D%/libstore/schema.sql.hh
-CLEANFILES += $(BUILT_SOURCES) etc/guix-daemon.service etc/guix-daemon.conf
+CLEANFILES += $(BUILT_SOURCES)
 
 noinst_LIBRARIES = libformat.a libutil.a libstore.a
 
@@ -189,9 +189,9 @@ nodist_systemdservice_DATA = etc/guix-daemon.service etc/guix-publish.service
 
 etc/guix-%.service: etc/guix-%.service.in	\
 			 $(top_builddir)/config.status
-	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";				\
-	$(SED) -e 's|@''bindir''@|$(bindir)|' <				\
-	       "$(srcdir)/$<" > "$@.tmp";	\
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''bindir''@|$(bindir)|' <	\
+	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
 # The '.conf' jobs for Upstart.
@@ -200,17 +200,23 @@ nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
 
 etc/guix-%.conf: etc/guix-%.conf.in	\
 			 $(top_builddir)/config.status
-	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";				\
-	$(SED) -e 's|@''bindir''@|$(bindir)|' <				\
-	       "$(srcdir)/$<" > "$@.tmp";		\
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''bindir''@|$(bindir)|' <	\
+	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+CLEANFILES +=					\
+  $(nodist_systemdservice_DATA)			\
+  $(nodist_upstartjob_DATA)
+
 EXTRA_DIST +=					\
   %D%/libstore/schema.sql			\
   %D%/AUTHORS					\
   %D%/COPYING					\
-  etc/guix-daemon.service.in	\
-  etc/guix-daemon.conf.in
+  etc/guix-daemon.service.in			\
+  etc/guix-daemon.conf.in			\
+  etc/guix-publish.service.in			\
+  etc/guix-publish.conf.in
 
 if CAN_RUN_TESTS