Skip to content

Commit

Permalink
Add `Settings::nixDaemonSocketFile'.
Browse files Browse the repository at this point in the history
  • Loading branch information
civodul authored and edolstra committed Feb 19, 2013
1 parent 5ea138d commit 3e067ac
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/libstore/globals.cc
Expand Up @@ -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;


Expand Down Expand Up @@ -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") {
Expand Down
3 changes: 3 additions & 0 deletions src/libstore/globals.hh
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/libstore/remote-store.cc
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/libstore/worker-protocol.hh
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/nix-daemon/nix-daemon.cc
Expand Up @@ -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));

Expand Down

0 comments on commit 3e067ac

Please sign in to comment.