Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Jun 1, 2024
1 parent 9133bb5 commit a6b7dd8
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 61 deletions.
7 changes: 6 additions & 1 deletion src/libstore/build/derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,12 @@ void runPostBuildHook(
std::map<std::string, std::string> hookEnvironment = getEnv();

hookEnvironment.emplace("DRV_PATH", store.printStorePath(drvPath));
hookEnvironment.emplace("OUT_PATHS", chomp(concatStringsSep(" ", store.printStorePathSet(outputPaths))));
hookEnvironment.emplace("OUT_PATHS", chomp(concatStringsSep(" ", ({
StringSet paths;
for (auto & p : outPaths)
paths.insert(store.printStorePath(p));
paths
}))));
hookEnvironment.emplace("NIX_CONFIG", globalConfig.toKeyValue());

struct LogSink : Sink {
Expand Down
4 changes: 4 additions & 0 deletions src/libstore/common-protocol.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
///@file

#include <filesystem>

#include "serialise.hh"

namespace nix {
Expand Down Expand Up @@ -64,6 +66,8 @@ struct CommonProto
template<>
DECLARE_COMMON_SERIALISER(std::string);
template<>
DECLARE_COMMON_SERIALISER(std::filesystem::path);
template<>
DECLARE_COMMON_SERIALISER(StorePath);
template<>
DECLARE_COMMON_SERIALISER(ContentAddress);
Expand Down
3 changes: 2 additions & 1 deletion src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
gcStore.collectGarbage(options, results);
logger->stopWork();

to << results.paths << results.bytesFreed << 0 /* obsolete */;
WorkerProto::write(*store, wconn, results.paths);
to << results.bytesFreed << 0 /* obsolete */;

break;
}
Expand Down
7 changes: 5 additions & 2 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ Derivation parseDerivation(
}

expect(str, ",");
for (auto & i : parseStrings(str, true)) drv.inputSrcs.insert(i);
for (auto & i : parseStrings(str, true)) drv.inputSrcs.insert(store.parseStorePath(i));
expect(str, ","); drv.platform = parseString(str).toOwned();
expect(str, ","); drv.builder = parseString(str).toOwned();

Expand Down Expand Up @@ -639,7 +639,10 @@ std::string Derivation::unparse(const StoreDirConfig & store, bool maskOutputs,
}

s += "],";
auto paths = store.printStorePathSet(inputSrcs); // FIXME: slow
StringSet paths;
// FIXME: slow
for (auto & i : inputSrcs)
paths.insert(store.printStorePath(i));
printUnquotedStrings(s, paths.begin(), paths.end());

s += ','; printUnquotedString(s, platform);
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/gc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static std::string gcRootsDir = "gcroots";

void LocalStore::addIndirectRoot(const Path & path)
{
std::string hash = hashString(HashAlgorithm::SHA1, path).to_string(HashFormat::Nix32, false);
std::string hash = hashString(HashAlgorithm::SHA1, path.string()).to_string(HashFormat::Nix32, false);
Path realRoot = canonPath(fmt("%1%/%2%/auto/%3%", stateDir, gcRootsDir, hash));
makeSymlink(realRoot, path);
}
Expand Down Expand Up @@ -202,7 +202,7 @@ void LocalStore::findTempRoots(Roots & tempRoots, bool censor)

while ((end = contents.find((char) 0, pos)) != std::string::npos) {
Path root(contents, pos, end - pos);
debug("got temporary root '%s'", root);
debug("got temporary root '%s'", root.native());
tempRoots[parseStorePath(root)].emplace(censor ? censored : fmt("{temp:%d}", pid));
pos = end + 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/local-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class LocalBinaryCacheStore : public virtual LocalBinaryCacheStoreConfig, public
*/
LocalBinaryCacheStore(
std::string_view scheme,
PathView binaryCacheDir,
std::string_view binaryCacheDir,
const Params & params)
: StoreConfig(params)
, BinaryCacheStoreConfig(params)
, LocalBinaryCacheStoreConfig(params)
, Store(params)
, BinaryCacheStore(params)
, binaryCacheDir(binaryCacheDir)
, binaryCacheDir(std::filesystem::path{std::string{binaryCacheDir}})
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ LocalStore::LocalStore(const Params & params)

LocalStore::LocalStore(
std::string_view scheme,
PathView path,
std::string_view path,
const Params & _params)
: LocalStore([&]{
// Default `?root` from `path` if non set
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/local-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public:
LocalStore(const Params & params);
LocalStore(
std::string_view scheme,
PathView path,
std::string_view path,
const Params & params);

~LocalStore();
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/ssh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SSHMaster::SSHMaster(
bool useMaster, bool compress, Descriptor logFD)
: host(host)
, fakeSSH(host == "localhost")
, keyFile(keyFile)
, keyFile(pathNG(keyFile))
, sshPublicHostKey(sshPublicHostKey)
, useMaster(useMaster && !fakeSSH)
, compress(compress)
Expand Down
Loading

0 comments on commit a6b7dd8

Please sign in to comment.