aboutsummaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-06-08 14:46:24 +0200
committerLudovic Courtès <ludo@gnu.org>2022-06-08 14:46:24 +0200
commit8c3e9da13a3c92a7db308db8c0d81cb474ad7799 (patch)
tree88d06952aa5cc3a9c4991d9c43eb7950ff174fe1 /nix
parent5439c04ebdb7b6405f5ea2446b375f1d155a8d95 (diff)
parent0c5299200ffcd16370f047b7ccb187c60f30da34 (diff)
downloadguix-8c3e9da13a3c92a7db308db8c0d81cb474ad7799.tar
guix-8c3e9da13a3c92a7db308db8c0d81cb474ad7799.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/build.cc5
-rw-r--r--nix/nix-daemon/guix-daemon.cc42
2 files changed, 39 insertions, 8 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index f6431bb726..10a6093bd5 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -979,7 +979,7 @@ void DerivationGoal::outputsSubstituted()
return;
}
if (buildMode == bmCheck && nrInvalid > 0)
- throw Error(format("some outputs of `%1%' are not valid, so checking is not possible") % drvPath);
+ throw Error(format("`%1%' is missing outputs; build it normally before using `--check'") % drvPath);
/* Otherwise, at least one of the output paths could not be
produced using a substitute. So we have to build instead. */
@@ -2057,7 +2057,6 @@ void DerivationGoal::runChild()
Path source = i->second;
Path target = chrootRootDir + i->first;
if (source == "/proc") continue; // backwards compatibility
- debug(format("bind mounting `%1%' to `%2%'") % source % target);
if (stat(source.c_str(), &st) == -1)
throw SysError(format("getting attributes of path `%1%'") % source);
if (S_ISDIR(st.st_mode))
@@ -2423,7 +2422,7 @@ void DerivationGoal::registerOutputs()
if (pathExists(dst)) deletePath(dst);
if (rename(actualPath.c_str(), dst.c_str()))
throw SysError(format("renaming `%1%' to `%2%'") % actualPath % dst);
- throw Error(format("derivation `%1%' may not be deterministic: output `%2%' differs from ‘%3%’")
+ throw Error(format("derivation `%1%' may not be deterministic: output `%2%' differs from `%3%'")
% drvPath % path % dst);
} else
throw Error(format("derivation `%1%' may not be deterministic: output `%2%' differs")
diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc
index 36a06a3fae..d7ab9c5e64 100644
--- a/nix/nix-daemon/guix-daemon.cc
+++ b/nix/nix-daemon/guix-daemon.cc
@@ -1,5 +1,5 @@
/* GNU Guix --- Functional package management for GNU
- Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
+ Copyright (C) 2012-2019, 2021-2022 Ludovic Courtès <ludo@gnu.org>
Copyright (C) 2006, 2010, 2012, 2014 Eelco Dolstra <e.dolstra@tudelft.nl>
This file is part of GNU Guix.
@@ -434,6 +434,31 @@ listening_sockets (const std::list<std::string> &options)
return result;
}
+/* First file descriptor provided at startup using systemd-style socket
+ activation. */
+#define SD_LISTEN_FDS_START 3
+
+/* Return a list of file descriptors of listening sockets provided following
+ the systemd "socket activation" protocol. Return the empty list if we are
+ not being socket-activated. */
+static std::vector<int>
+systemd_activation_sockets ()
+{
+ std::vector<int> result;
+
+ if (getEnv ("LISTEN_PID") == std::to_string (getpid ()))
+ {
+ unsigned int fdCount;
+ if (string2Int (getEnv ("LISTEN_FDS"), fdCount))
+ {
+ for (unsigned int i = 0; i < fdCount; i++)
+ result.push_back (SD_LISTEN_FDS_START + i);
+ }
+ }
+
+ return result;
+}
+
int
main (int argc, char *argv[])
@@ -494,7 +519,17 @@ main (int argc, char *argv[])
argp_parse (&argp, argc, argv, 0, 0, 0);
- auto sockets = listening_sockets (listen_options);
+ auto sockets = systemd_activation_sockets ();
+ if (sockets.empty ())
+ /* We were not "socket-activated" so open the sockets specified by
+ LISTEN_OPTIONS. */
+ sockets = listening_sockets (listen_options);
+ else
+ printMsg (lvlInfo,
+ format (ngettext ("socket-activated with %1% socket",
+ "socket-activated with %1% sockets",
+ sockets.size ()))
+ % sockets.size ());
/* Effect all the changes made via 'settings.set'. */
settings.update ();
@@ -531,9 +566,6 @@ using `--build-users-group' is highly recommended\n"));
format ("automatic deduplication set to %1%")
% settings.autoOptimiseStore);
- printMsg (lvlDebug,
- format ("listening on `%1%'") % settings.nixDaemonSocketFile);
-
run (sockets);
}
catch (std::exception &e)