From e388739098cfb14a166923cd24b6140674b176f8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 3 Jul 2018 19:52:32 +0200 Subject: [PATCH] nix-daemon: Respect --store For example, this allows you to do run nix-daemon as a non-privileged user: eelco$ NIX_STATE_DIR=~/my-nix/nix/var nix-daemon --store ~/my-nix/ The NIX_STATE_DIR is still needed because settings.nixDaemonSocketFile is not derived from settings.storeUri (and we can't derive it from the store's state directory because we don't want to open the store in the parent process). --- src/nix-daemon/nix-daemon.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index 423e6bb67..a2e54b93c 100644 --- a/src/nix-daemon/nix-daemon.cc +++ b/src/nix-daemon/nix-daemon.cc @@ -233,7 +233,7 @@ struct RetrieveRegularNARSink : ParseSink }; -static void performOp(TunnelLogger * logger, ref store, +static void performOp(TunnelLogger * logger, ref store, bool trusted, unsigned int clientVersion, Source & from, Sink & to, unsigned int op) { @@ -362,7 +362,11 @@ static void performOp(TunnelLogger * logger, ref store, logger->startWork(); if (!savedRegular.regular) throw Error("regular file expected"); - Path path = store->addToStoreFromDump(recursive ? *savedNAR.data : savedRegular.s, baseName, recursive, hashAlgo); + + auto store2 = store.dynamic_pointer_cast(); + if (!store2) throw Error("operation is only supported by LocalStore"); + + Path path = store2->addToStoreFromDump(recursive ? *savedNAR.data : savedRegular.s, baseName, recursive, hashAlgo); logger->stopWork(); to << path; @@ -776,7 +780,7 @@ static void processConnection(bool trusted) Store::Params params; // FIXME: get params from somewhere // Disable caching since the client already does that. params["path-info-cache-size"] = "0"; - auto store = make_ref(params); + auto store = openStore(settings.storeUri, params); tunnelLogger->stopWork(); to.flush();