[Nix-dev] [PATCH 2/2] Add `Settings::nixDaemonSocketFile'.
ludo at gnu.org
ludo at gnu.org
Mon Feb 18 23:05:40 CET 2013
From: Ludovic Courtès <ludo at gnu.org>
---
src/libstore/globals.cc | 9 +++++++++
src/libstore/globals.hh | 3 +++
src/libstore/remote-store.cc | 2 +-
src/libstore/worker-protocol.hh | 8 --------
src/nix-daemon/nix-daemon.cc | 2 +-
5 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 596d477..b5a2a20 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -10,6 +10,14 @@
namespace nix {
+/* The default location of the daemon socket, relative to nixStateDir.
+ The socket is in a directory to allow you to control access to the
+ Nix daemon by setting the mode/ownership of the directory
+ appropriately. (This wouldn't work on the socket itself since it
+ must be deleted and recreated on startup.) */
+#define DEFAULT_SOCKET_PATH "/daemon-socket/socket"
+
+
Settings settings;
@@ -58,6 +66,7 @@ void Settings::processEnvironment()
nixConfDir = canonPath(getEnv("NIX_CONF_DIR", NIX_CONF_DIR));
nixLibexecDir = canonPath(getEnv("NIX_LIBEXEC_DIR", NIX_LIBEXEC_DIR));
nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR));
+ nixDaemonSocketFile = canonPath(nixStateDir + DEFAULT_SOCKET_PATH);
string subs = getEnv("NIX_SUBSTITUTERS", "default");
if (subs == "default") {
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index be28769..f129d9a 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -50,6 +50,9 @@ struct Settings {
/* The directory where the main programs are stored. */
Path nixBinDir;
+ /* File name of the socket the daemon listens to. */
+ Path nixDaemonSocketFile;
+
/* Whether to keep temporary directories of failed builds. */
bool keepFailed;
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 0e62914..2b5a932 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -91,7 +91,7 @@ void RemoteStore::connectToDaemon()
throw SysError("cannot create Unix domain socket");
closeOnExec(fdSocket);
- string socketPath = settings.nixStateDir + DEFAULT_SOCKET_PATH;
+ string socketPath = settings.nixDaemonSocketFile;
/* Urgh, sockaddr_un allows path names of only 108 characters. So
chdir to the socket directory so that we can pass a relative
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index 46035f4..07f825b 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -53,14 +53,6 @@ typedef enum {
#define STDERR_ERROR 0x63787470
-/* The default location of the daemon socket, relative to nixStateDir.
- The socket is in a directory to allow you to control access to the
- Nix daemon by setting the mode/ownership of the directory
- appropriately. (This wouldn't work on the socket itself since it
- must be deleted and recreated on startup.) */
-#define DEFAULT_SOCKET_PATH "/daemon-socket/socket"
-
-
Path readStorePath(Source & from);
template<class T> T readStorePaths(Source & from);
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 35e5c54..9c67665 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -774,7 +774,7 @@ static void daemonLoop()
if (fdSocket == -1)
throw SysError("cannot create Unix domain socket");
- string socketPath = settings.nixStateDir + DEFAULT_SOCKET_PATH;
+ string socketPath = settings.nixDaemonSocketFile;
createDirs(dirOf(socketPath));
--
1.7.10.4
More information about the nix-dev
mailing list