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/libexpr-c/nix_api_external.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class NixCExternalValue : public nix::ExternalValueBase
bool location,
nix::XMLWriter & doc,
nix::NixStringContext & context,
nix::PathSet & drvsSeen,
nix::StringSet & drvsSeen,
const nix::PosIdx pos) const override
{
if (!desc.printValueAsXML) {
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ EvalState::EvalState(

EvalState::~EvalState() {}

void EvalState::allowPathLegacy(const Path & path)
void EvalState::allowPathLegacy(const std::string & path)
{
if (auto rootFS2 = rootFS.dynamic_pointer_cast<AllowListSourceAccessor>())
rootFS2->allowPrefix(CanonPath(path));
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/include/nix/expr/eval-settings.hh
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ struct EvalSettings : Config
See [Using the `eval-profiler`](@docroot@/advanced-topics/eval-profiler.md).
)"};

Setting<Path> evalProfileFile{
Setting<std::filesystem::path> evalProfileFile{
this,
"nix.profile",
"eval-profile-file",
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/include/nix/expr/eval.hh
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public:
/**
* Variant which accepts relative paths too.
*/
SourcePath rootPath(PathView path);
SourcePath rootPath(std::string_view path);

/**
* Return a `SourcePath` that refers to `path` in the store.
Expand All @@ -565,7 +565,7 @@ public:
* Only for restrict eval: pure eval just whitelist store paths,
* never arbitrary paths.
*/
void allowPathLegacy(const Path & path);
void allowPathLegacy(const std::string & path);

/**
* Allow access to a store path. Note that this gets remapped to
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/include/nix/expr/value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public:
bool location,
XMLWriter & doc,
NixStringContext & context,
PathSet & drvsSeen,
StringSet & drvsSeen,
const PosIdx pos) const;

virtual ~ExternalValueBase() {};
Expand Down
3 changes: 2 additions & 1 deletion src/libexpr/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ path_start
.pos = state->positions[CUR_POS]
});
});

/* Absolute paths are always interpreted relative to the
root filesystem accessor, rather than the accessor of the
current Nix expression. */
Expand Down Expand Up @@ -463,7 +464,7 @@ path_start
.pos = state->positions[CUR_POS]
});
});
Path path(getHome().string() + std::string($1.p + 1, $1.l - 1));
auto path(getHome().string() + std::string($1.p + 1, $1.l - 1));
$$ = state->exprs.add<ExprPath>(state->exprs.alloc, state->rootFS, path);
}
;
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/paths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SourcePath EvalState::rootPath(CanonPath path)
return {rootFS, std::move(path)};
}

SourcePath EvalState::rootPath(PathView path)
SourcePath EvalState::rootPath(std::string_view path)
{
return {rootFS, CanonPath(absPath(path).string())};
}
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@ static void addPath(

std::unique_ptr<PathFilter> filter;
if (filterFun)
filter = std::make_unique<PathFilter>([&](const Path & p) {
filter = std::make_unique<PathFilter>([&](const std::string & p) {
auto p2 = CanonPath(p);
return state.callPathFilter(filterFun, {path.accessor, p2}, pos);
});
Expand Down
12 changes: 6 additions & 6 deletions src/libexpr/value-to-xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static void printValueAsXML(
Value & v,
XMLWriter & doc,
NixStringContext & context,
PathSet & drvsSeen,
StringSet & drvsSeen,
const PosIdx pos);

static void posToXML(EvalState & state, XMLAttrs & xmlAttrs, const Pos & pos)
Expand All @@ -39,7 +39,7 @@ static void showAttrs(
const Bindings & attrs,
XMLWriter & doc,
NixStringContext & context,
PathSet & drvsSeen)
StringSet & drvsSeen)
{
StringSet names;

Expand All @@ -61,7 +61,7 @@ static void printValueAsXML(
Value & v,
XMLWriter & doc,
NixStringContext & context,
PathSet & drvsSeen,
StringSet & drvsSeen,
const PosIdx pos)
{
checkInterrupt();
Expand Down Expand Up @@ -99,7 +99,7 @@ static void printValueAsXML(
if (state.isDerivation(v)) {
XMLAttrs xmlAttrs;

Path drvPath;
std::string drvPath;
if (auto a = v.attrs()->get(state.s.drvPath)) {
if (strict)
state.forceValue(*a->value, a->pos);
Expand Down Expand Up @@ -185,7 +185,7 @@ void ExternalValueBase::printValueAsXML(
bool location,
XMLWriter & doc,
NixStringContext & context,
PathSet & drvsSeen,
StringSet & drvsSeen,
const PosIdx pos) const
{
doc.writeEmptyElement("unevaluated");
Expand All @@ -202,7 +202,7 @@ void printValueAsXML(
{
XMLWriter doc(true, out);
XMLOpenElement root(doc, "expr");
PathSet drvsSeen;
StringSet drvsSeen;
printValueAsXML(state, strict, location, v, doc, context, drvsSeen, pos);
}

Expand Down
6 changes: 4 additions & 2 deletions src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,9 @@ struct GitInputScheme : InputScheme

// Why are we checking for bare repository?
// well if it's a bare repository we want to force a git fetch rather than copying the folder
auto isBareRepository = [](PathView path) { return pathExists(path) && !pathExists(path + "/.git"); };
auto isBareRepository = [](const std::filesystem::path & path) {
return pathExists(path) && !pathExists(path / ".git");
};

// FIXME: here we turn a possibly relative path into an absolute path.
// This allows relative git flake inputs to be resolved against the
Expand All @@ -647,7 +649,7 @@ struct GitInputScheme : InputScheme
//
auto maybeUrlFsPathForFileUrl =
url.scheme == "file" ? std::make_optional(urlPathToPath(url.path)) : std::nullopt;
if (maybeUrlFsPathForFileUrl && !forceHttp && !isBareRepository(maybeUrlFsPathForFileUrl->string())) {
if (maybeUrlFsPathForFileUrl && !forceHttp && !isBareRepository(*maybeUrlFsPathForFileUrl)) {
auto & path = *maybeUrlFsPathForFileUrl;

if (!path.is_absolute()) {
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/mercurial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ struct MercurialInputScheme : InputScheme

auto actualPath = absPath(localPath);

PathFilter filter = [&](const Path & p) -> bool {
PathFilter filter = [&](const std::string & p) -> bool {
assert(hasPrefix(p, actualPath.string()));
std::string file(p, actualPath.string().size() + 1);

Expand Down
2 changes: 1 addition & 1 deletion src/libflake-c/nix_api_flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ nix_err nix_flake_reference_parse_flags_set_base_directory(
{
nix_clear_err(context);
try {
flags->baseDirectory.emplace(nix::Path{std::string(baseDirectory, baseDirectoryLen)});
flags->baseDirectory.emplace(std::string(baseDirectory, baseDirectoryLen));
return NIX_OK;
}
NIXC_CATCH_ERRS
Expand Down
6 changes: 4 additions & 2 deletions src/libflake/include/nix/flake/flakeref.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ struct FlakeRef

/**
* sub-path within the fetched input that represents this input
*
* @todo Should probably use `CanonPath` instead of `std::string`?
*/
Path subdir;
std::string subdir;

bool operator==(const FlakeRef & other) const = default;

Expand All @@ -60,7 +62,7 @@ struct FlakeRef
return std::tie(input, subdir) < std::tie(other.input, other.subdir);
}

FlakeRef(fetchers::Input && input, const Path & subdir)
FlakeRef(fetchers::Input && input, const std::string & subdir)
: input(std::move(input))
, subdir(subdir)
{
Expand Down
10 changes: 5 additions & 5 deletions src/libstore-test-support/include/nix/store/tests/protocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class ProtoTest : public CharacterizationTest
}

public:
Path storeDir = "/nix/store";
std::string storeDir = "/nix/store";
StoreDirConfig store{storeDir};

/**
* Golden test for `T` JSON reading
*/
template<typename T>
void readJsonTest(PathView testStem, const T & expected)
void readJsonTest(std::string_view testStem, const T & expected)
{
nix::readJsonTest(*this, testStem, expected);
}
Expand All @@ -37,7 +37,7 @@ public:
* Golden test for `T` JSON write
*/
template<typename T>
void writeJsonTest(PathView testStem, const T & decoded)
void writeJsonTest(std::string_view testStem, const T & decoded)
{
nix::writeJsonTest(*this, testStem, decoded);
}
Expand All @@ -51,7 +51,7 @@ public:
* Golden test for `T` reading
*/
template<typename T>
void readProtoTest(PathView testStem, typename Proto::Version version, T expected)
void readProtoTest(std::string_view testStem, typename Proto::Version version, T expected)
{
CharacterizationTest::readTest(std::string{testStem + ".bin"}, [&](const auto & encoded) {
T got = ({
Expand All @@ -72,7 +72,7 @@ public:
* Golden test for `T` write
*/
template<typename T>
void writeProtoTest(PathView testStem, typename Proto::Version version, const T & decoded)
void writeProtoTest(std::string_view testStem, typename Proto::Version version, const T & decoded)
{
CharacterizationTest::writeTest(std::string{testStem + ".bin"}, [&]() {
StringSink to;
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/common-protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CommonProtoTest : public ProtoTest<CommonProto, commonProtoDir>
* Golden test for `T` reading
*/
template<typename T>
void readProtoTest(PathView testStem, const T & expected)
void readProtoTest(std::string_view testStem, const T & expected)
{
CharacterizationTest::readTest(std::string{testStem + ".bin"}, [&](const auto & encoded) {
T got = ({
Expand All @@ -37,7 +37,7 @@ class CommonProtoTest : public ProtoTest<CommonProto, commonProtoDir>
* Golden test for `T` write
*/
template<typename T>
void writeProtoTest(PathView testStem, const T & decoded)
void writeProtoTest(std::string_view testStem, const T & decoded)
{
CharacterizationTest::writeTest(std::string{testStem + ".bin"}, [&]() -> std::string {
StringSink to;
Expand Down
22 changes: 11 additions & 11 deletions src/libstore-tests/derivation/external-formats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ TEST_F(DynDerivationTest, BadATerm_oldVersionDynDeps)
FormatError);
}

#define MAKE_OUTPUT_JSON_TEST_P(FIXTURE) \
TEST_P(FIXTURE, from_json) \
{ \
const auto & [name, expected] = GetParam(); \
readJsonTest(Path{"output-"} + name, expected, mockXpSettings); \
} \
\
TEST_P(FIXTURE, to_json) \
{ \
const auto & [name, value] = GetParam(); \
writeJsonTest("output-" + name, value); \
#define MAKE_OUTPUT_JSON_TEST_P(FIXTURE) \
TEST_P(FIXTURE, from_json) \
{ \
const auto & [name, expected] = GetParam(); \
readJsonTest(std::string{"output-"} + name, expected, mockXpSettings); \
} \
\
TEST_P(FIXTURE, to_json) \
{ \
const auto & [name, value] = GetParam(); \
writeJsonTest(std::string{"output-"} + name, value); \
}

struct DerivationOutputJsonTest : DerivationTest,
Expand Down
2 changes: 1 addition & 1 deletion src/libstore-tests/dummy-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST_P(DummyStoreJsonTest, from_json)
using namespace nlohmann;
/* Cannot use `readJsonTest` because need to dereference the stores
for equality. */
readTest(Path{name} + ".json", [&](const auto & encodedRaw) {
readTest(std::string{name} + ".json", [&](const auto & encodedRaw) {
auto encoded = json::parse(encodedRaw);
ref<DummyStore> decoded = adl_serializer<ref<DummyStore>>::from_json(encoded);
ASSERT_EQ(*decoded, *expected);
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/nar-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NarInfoTestV1 : public CharacterizationTest, public LibStoreTest
{
std::filesystem::path unitTestData = getUnitTestData() / "nar-info" / "json-1";

std::filesystem::path goldenMaster(PathView testStem) const override
std::filesystem::path goldenMaster(std::string_view testStem) const override
{
return unitTestData / (testStem + ".json");
}
Expand All @@ -25,7 +25,7 @@ class NarInfoTestV2 : public CharacterizationTest, public LibStoreTest
{
std::filesystem::path unitTestData = getUnitTestData() / "nar-info" / "json-2";

std::filesystem::path goldenMaster(PathView testStem) const override
std::filesystem::path goldenMaster(std::string_view testStem) const override
{
return unitTestData / (testStem + ".json");
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/path-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PathInfoTestV1 : public CharacterizationTest, public LibStoreTest
{
std::filesystem::path unitTestData = getUnitTestData() / "path-info" / "json-1";

std::filesystem::path goldenMaster(PathView testStem) const override
std::filesystem::path goldenMaster(std::string_view testStem) const override
{
return unitTestData / (testStem + ".json");
}
Expand All @@ -24,7 +24,7 @@ class PathInfoTestV2 : public CharacterizationTest, public LibStoreTest
{
std::filesystem::path unitTestData = getUnitTestData() / "path-info" / "json-2";

std::filesystem::path goldenMaster(PathView testStem) const override
std::filesystem::path goldenMaster(std::string_view testStem) const override
{
return unitTestData / (testStem + ".json");
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstore-tests/store-reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StoreReferenceTest : public CharacterizationTest, public LibStoreTest
{
std::filesystem::path unitTestData = getUnitTestData() / "store-reference";

std::filesystem::path goldenMaster(PathView testStem) const override
std::filesystem::path goldenMaster(std::string_view testStem) const override
{
return unitTestData / (testStem + ".txt");
}
Expand Down
10 changes: 8 additions & 2 deletions src/libstore/build/derivation-building-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution(bool storeDerivation)
/* Second, the input sources. */
worker.store.computeFSClosure(drv->inputSrcs, inputPaths);

debug("added input paths %s", worker.store.showPaths(inputPaths));
debug("added input paths %s", concatMapStringsSep(", ", inputPaths, [&](auto & p) {
return "'" + worker.store.printStorePath(p) + "'";
}));

/* Okay, try to build. Note that here we don't wait for a build
slot to become available, since we don't need one if there is a
Expand Down Expand Up @@ -397,7 +399,11 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)

if (!outputLocks.lockPaths(lockFiles, "", false)) {
Activity act(
*logger, lvlWarn, actBuildWaiting, fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
*logger,
lvlWarn,
actBuildWaiting,
fmt("waiting for lock on %s",
Magenta(concatMapStringsSep(", ", lockFiles, [](auto & p) { return "'" + p.string() + "'"; }))));

/* Wait then try locking again, repeat until success (returned
boolean is true). */
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/build/derivation-check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ void checkOutputs(
const decltype(DerivationOptions<StorePath>::outputChecks) & outputChecks,
const std::map<std::string, ValidPathInfo> & outputs)
{
std::map<Path, const ValidPathInfo &> outputsByPath;
std::map<StorePath, const ValidPathInfo &> outputsByPath;
for (auto & output : outputs)
outputsByPath.emplace(store.printStorePath(output.second.path), output.second);
outputsByPath.emplace(output.second.path, output.second);

for (auto & pair : outputs) {
// We can't use auto destructuring here because
Expand Down Expand Up @@ -69,7 +69,7 @@ void checkOutputs(
if (!pathsDone.insert(path).second)
continue;

auto i = outputsByPath.find(store.printStorePath(path));
auto i = outputsByPath.find(path);
if (i != outputsByPath.end()) {
closureSize += i->second.narSize;
for (auto & ref : i->second.references)
Expand Down
Loading
Loading