Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
auto localStore = state->store.dynamic_pointer_cast<LocalFSStore>();
if (localStore && command == ":bl") {
std::string symlink = "repl-result-" + outputName;
localStore->addPermRoot(outputPath, absPath(symlink).string());
localStore->addPermRoot(outputPath, absPath(symlink));
logger->cout(" ./%s -> %s", symlink, state->store->printStorePath(outputPath));
} else {
logger->cout(" %s -> %s", outputName, state->store->printStorePath(outputPath));
Expand Down
17 changes: 9 additions & 8 deletions src/libfetchers/git-lfs-fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,27 @@ static LfsApiInfo getLfsApi(const ParsedURL & url)
auto args = getNixSshOpts();

if (url.authority->port)
args.push_back(fmt("-p%d", *url.authority->port));
args.push_back(string_to_os_string(fmt("-p%d", *url.authority->port)));

std::ostringstream hostnameAndUser;
if (url.authority->user)
hostnameAndUser << *url.authority->user << "@";
hostnameAndUser << url.authority->host;
args.push_back(std::move(hostnameAndUser).str());
args.push_back(string_to_os_string(std::move(hostnameAndUser).str()));

args.push_back("--");
args.push_back("git-lfs-authenticate");
args.push_back(OS_STR("--"));
args.push_back(OS_STR("git-lfs-authenticate"));
// FIXME %2F encode slashes? Does this command take/accept percent encoding?
args.push_back(url.renderPath(/*encode=*/false));
args.push_back("download");
args.push_back(string_to_os_string(url.renderPath(/*encode=*/false)));
args.push_back(OS_STR("download"));

auto [status, output] = runProgram({.program = "ssh", .args = toOsStrings(args)});
auto [status, output] = runProgram({.program = "ssh", .args = args});

if (output.empty())
throw Error(
"git-lfs-authenticate: no output (cmd: 'ssh %s')",
concatMapStringsSep(" ", args, escapeShellArgAlways));
concatMapStringsSep(
" ", args, [](const OsString & s) { return escapeShellArgAlways(os_string_to_string(s)); }));

auto queryResp = nlohmann::json::parse(output);
auto headerIt = queryResp.find("header");
Expand Down
2 changes: 1 addition & 1 deletion src/libflake-c/nix_api_flake_internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct nix_flake_settings

struct nix_flake_reference_parse_flags
{
std::optional<nix::Path> baseDirectory;
std::optional<std::filesystem::path> baseDirectory;
};

struct nix_flake_reference
Expand Down
2 changes: 1 addition & 1 deletion src/libstore-c/nix_api_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ nix_err nix_store_real_path(
context->last_err_code = NIX_OK;
try {
auto store2 = store->ptr.dynamic_pointer_cast<nix::LocalFSStore>();
auto res = store2 ? store2->toRealPath(path->path) : store->ptr->printStorePath(path->path);
auto res = store2 ? store2->toRealPath(path->path).string() : store->ptr->printStorePath(path->path);
return call_nix_get_string_callback(res, callback, user_data);
}
NIXC_CATCH_ERRS
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/machines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(machines, getMachinesUriOnly)
ASSERT_THAT(actual, SizeIs(1));
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq(StoreReference::parse("ssh://nix@scratchy.labs.cs.uu.nl"))));
EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("TEST_ARCH-TEST_OS")));
EXPECT_THAT(actual[0], Field(&Machine::sshKey, SizeIs(0)));
EXPECT_THAT(actual[0], Field(&Machine::sshKey, Eq(std::filesystem::path{})));
EXPECT_THAT(actual[0], Field(&Machine::maxJobs, Eq(1)));
EXPECT_THAT(actual[0], Field(&Machine::speedFactor, Eq(1)));
EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, SizeIs(0)));
Expand All @@ -49,7 +49,7 @@ TEST(machines, getMachinesDefaults)
ASSERT_THAT(actual, SizeIs(1));
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq(StoreReference::parse("ssh://nix@scratchy.labs.cs.uu.nl"))));
EXPECT_THAT(actual[0], Field(&Machine::systemTypes, ElementsAre("TEST_ARCH-TEST_OS")));
EXPECT_THAT(actual[0], Field(&Machine::sshKey, SizeIs(0)));
EXPECT_THAT(actual[0], Field(&Machine::sshKey, Eq(std::filesystem::path{})));
EXPECT_THAT(actual[0], Field(&Machine::maxJobs, Eq(1)));
EXPECT_THAT(actual[0], Field(&Machine::speedFactor, Eq(1)));
EXPECT_THAT(actual[0], Field(&Machine::supportedFeatures, SizeIs(0)));
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/nar-info-disk-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST(NarInfoDiskCacheImpl, create_and_read)

{
auto cache = NarInfoDiskCache::getTest(
settings.getNarInfoDiskCacheSettings(), {.useWAL = settings.useSQLiteWAL}, dbPath.string());
settings.getNarInfoDiskCacheSettings(), {.useWAL = settings.useSQLiteWAL}, dbPath);

// Set up "background noise" and check that different caches receive different ids
{
Expand Down Expand Up @@ -76,7 +76,7 @@ TEST(NarInfoDiskCacheImpl, create_and_read)
// We can't clear the in-memory cache, so we use a new cache object. This is
// more realistic anyway.
auto cache2 = NarInfoDiskCache::getTest(
settings.getNarInfoDiskCacheSettings(), {.useWAL = settings.useSQLiteWAL}, dbPath.string());
settings.getNarInfoDiskCacheSettings(), {.useWAL = settings.useSQLiteWAL}, dbPath);

{
auto r = cache2->upToDateCacheExists("http://foo");
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ namespace nix {
BinaryCacheStore::BinaryCacheStore(Config & config)
: config{config}
{
if (config.secretKeyFile != "")
if (!config.secretKeyFile.get().empty())
signers.push_back(std::make_unique<LocalSigner>(SecretKey{readFile(config.secretKeyFile.get())}));

if (config.secretKeyFiles != "") {
std::stringstream ss(config.secretKeyFiles);
Path keyPath;
std::string keyPath;
while (std::getline(ss, keyPath, ',')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xokdvium we should probably replace with one our split/tokenize functions?

signers.push_back(std::make_unique<LocalSigner>(SecretKey{readFile(keyPath)}));
}
Expand Down
7 changes: 5 additions & 2 deletions src/libstore/build/derivation-building-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,11 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)
for (auto & i : drv->outputsAndOptPaths(worker.store)) {
if (i.second.second)
lockFiles.insert(localStore->toRealPath(*i.second.second));
else
lockFiles.insert(localStore->toRealPath(drvPath) + "." + i.first);
else {
auto lockPath = localStore->toRealPath(drvPath);
lockPath += "." + i.first;
lockFiles.insert(std::move(lockPath));
}
}
}

Expand Down
33 changes: 20 additions & 13 deletions src/libstore/builtins/buildenv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ namespace {

struct State
{
std::map<Path, int> priorities;
std::map<std::filesystem::path, int> priorities;
unsigned long symlinks = 0;
};

} // namespace

/* For each activated package, create symlinks */
static void createLinks(State & state, const Path & srcDir, const Path & dstDir, int priority)
static void
createLinks(State & state, const std::filesystem::path & srcDir, const std::filesystem::path & dstDir, int priority)
{
DirectoryIterator srcFiles;

try {
srcFiles = DirectoryIterator{srcDir};
} catch (SystemError & e) {
if (e.is(std::errc::not_a_directory)) {
warn("not including '%s' in the user environment because it's not a directory", srcDir);
warn("not including %s in the user environment because it's not a directory", PathFmt(srcDir));
return;
}
throw;
Expand Down Expand Up @@ -76,11 +77,14 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir,
createLinks(state, srcFile, dstFile, priority);
continue;
} else if (S_ISLNK(dstSt.st_mode)) {
auto target = canonPath(dstFile, true).string();
auto target = canonPath(dstFile, true);
if (!S_ISDIR(lstat(target).st_mode))
throw Error("collision between %1% and non-directory %2%", PathFmt(srcFile), PathFmt(target));
if (unlink(dstFile.c_str()) == -1)
throw SysError("unlinking %1%", PathFmt(dstFile));
try {
std::filesystem::remove(dstFile);
} catch (std::filesystem::filesystem_error & e) {
throw SystemError(e.code(), "unlinking %s", PathFmt(dstFile));
}
if (mkdir(
dstFile.c_str()
#ifndef _WIN32 // TODO abstract mkdir perms for Windows
Expand All @@ -104,11 +108,14 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir,
if (S_ISLNK(dstSt.st_mode)) {
auto prevPriority = state.priorities[dstFile];
if (prevPriority == priority)
throw BuildEnvFileConflictError(readLink(dstFile).string(), srcFile, priority);
throw BuildEnvFileConflictError(readLink(dstFile), srcFile, priority);
if (prevPriority < priority)
continue;
if (unlink(dstFile.c_str()) == -1)
throw SysError("unlinking %1%", PathFmt(dstFile));
try {
std::filesystem::remove(dstFile);
} catch (std::filesystem::filesystem_error & e) {
throw SystemError(e.code(), "unlinking %s", PathFmt(dstFile));
}
} else if (S_ISDIR(dstSt.st_mode))
throw Error("collision between non-directory '%1%' and directory '%2%'", srcFile, dstFile);
}
Expand All @@ -120,20 +127,20 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir,
}
}

void buildProfile(const Path & out, Packages && pkgs)
void buildProfile(const std::filesystem::path & out, Packages && pkgs)
{
State state;

PathSet done, postponed;

auto addPkg = [&](const Path & pkgDir, int priority) {
if (!done.insert(pkgDir).second)
auto addPkg = [&](const std::filesystem::path & pkgDir, int priority) {
if (!done.insert(pkgDir.string()).second)
return;
createLinks(state, pkgDir, out, priority);

try {
for (const auto & p : tokenizeString<std::vector<std::string>>(
readFile(pkgDir + "/nix-support/propagated-user-env-packages"), " \n"))
readFile(pkgDir / "nix-support" / "propagated-user-env-packages"), " \n"))
if (!done.count(p))
postponed.insert(p);
} catch (SystemError & e) {
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -680,17 +680,17 @@ static void performOp(
"you are not privileged to create perm roots\n\n"
"hint: you can just do this client-side without special privileges, and probably want to do that instead.");
auto storePath = WorkerProto::Serialise<StorePath>::read(*store, rconn);
Path gcRoot = absPath(readString(conn.from)).string();
std::filesystem::path gcRoot = absPath(readString(conn.from));
logger->startWork();
auto & localFSStore = require<LocalFSStore>(*store);
localFSStore.addPermRoot(storePath, gcRoot);
logger->stopWork();
conn.to << gcRoot;
conn.to << gcRoot.string();
break;
}

case WorkerProto::Op::AddIndirectRoot: {
Path path = absPath(readString(conn.from)).string();
std::filesystem::path path = absPath(readString(conn.from));

logger->startWork();
auto & indirectRootStore = require<IndirectRootStore>(*store);
Expand Down
Loading
Loading