Skip to content

Commit 5b95745

Browse files
authored
Merge pull request #14702 from NixOS/fix-mingw
Fix mingw build
2 parents c7801fc + 8d0e289 commit 5b95745

File tree

16 files changed

+32
-30
lines changed

16 files changed

+32
-30
lines changed

src/libcmd/repl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ NixRepl::NixRepl(
142142
, getValues(getValues)
143143
, staticEnv(new StaticEnv(nullptr, state->staticBaseEnv))
144144
, runNixPtr{runNix}
145-
, interacter(make_unique<ReadlineLikeInteracter>(getDataDir() + "/repl-history"))
145+
, interacter(make_unique<ReadlineLikeInteracter>((getDataDir() / "repl-history").string()))
146146
{
147147
}
148148

src/libfetchers/cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct CacheImpl : Cache
3838
{
3939
auto state(_state.lock());
4040

41-
auto dbPath = getCacheDir() + "/fetcher-cache-v4.sqlite";
41+
auto dbPath = (getCacheDir() / "fetcher-cache-v4.sqlite").string();
4242
createDirs(dirOf(dbPath));
4343

4444
state->db = SQLite(dbPath);

src/libfetchers/git-utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void initRepoAtomically(std::filesystem::path & path, bool bare)
212212
AutoDelete delTmpDir(tmpDir, true);
213213
Repository tmpRepo;
214214

215-
if (git_repository_init(Setter(tmpRepo), tmpDir.c_str(), bare))
215+
if (git_repository_init(Setter(tmpRepo), tmpDir.string().c_str(), bare))
216216
throw Error("creating Git repository %s: %s", path, git_error_last()->message);
217217
try {
218218
std::filesystem::rename(tmpDir, path);

src/libfetchers/git.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ std::optional<std::string> readHead(const std::filesystem::path & path)
6161
RunOptions{
6262
.program = "git",
6363
// FIXME: use 'HEAD' to avoid returning all refs
64-
.args = {"ls-remote", "--symref", path},
64+
.args = {"ls-remote", "--symref", path.string()},
6565
.isInteractive = true,
6666
});
6767
if (status != 0)
@@ -88,7 +88,7 @@ bool storeCachedHead(const std::string & actualUrl, bool shallow, const std::str
8888
{
8989
std::filesystem::path cacheDir = getCachePath(actualUrl, shallow);
9090
try {
91-
runProgram("git", true, {"-C", cacheDir, "--git-dir", ".", "symbolic-ref", "--", "HEAD", headRef});
91+
runProgram("git", true, {"-C", cacheDir.string(), "--git-dir", ".", "symbolic-ref", "--", "HEAD", headRef});
9292
} catch (ExecError & e) {
9393
if (
9494
#ifndef WIN32 // TODO abstract over exit status handling on Windows
@@ -115,7 +115,7 @@ std::optional<std::string> readHeadCached(const std::string & actualUrl, bool sh
115115
time_t now = time(0);
116116
struct stat st;
117117
std::optional<std::string> cachedRef;
118-
if (stat(headRefFile.c_str(), &st) == 0) {
118+
if (stat(headRefFile.string().c_str(), &st) == 0) {
119119
cachedRef = readHead(cacheDir);
120120
if (cachedRef != std::nullopt && *cachedRef != gitInitialBranch && isCacheFileWithinTtl(now, st)) {
121121
debug("using cached HEAD ref '%s' for repo '%s'", *cachedRef, actualUrl);
@@ -450,7 +450,7 @@ struct GitInputScheme : InputScheme
450450
if (input.getRev())
451451
throw UnimplementedError("cloning a specific revision is not implemented");
452452

453-
args.push_back(destDir);
453+
args.push_back(destDir.string());
454454

455455
runProgram("git", true, args, {}, true);
456456
}

src/libfetchers/mercurial.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,35 +281,36 @@ struct MercurialInputScheme : InputScheme
281281
/* If this is a commit hash that we already have, we don't
282282
have to pull again. */
283283
if (!(input.getRev() && pathExists(cacheDir)
284-
&& runProgram(hgOptions({"log", "-R", cacheDir, "-r", input.getRev()->gitRev(), "--template", "1"}))
284+
&& runProgram(
285+
hgOptions({"log", "-R", cacheDir.string(), "-r", input.getRev()->gitRev(), "--template", "1"}))
285286
.second
286287
== "1")) {
287288
Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Mercurial repository '%s'", actualUrl));
288289

289290
if (pathExists(cacheDir)) {
290291
try {
291-
runHg({"pull", "-R", cacheDir, "--", actualUrl});
292+
runHg({"pull", "-R", cacheDir.string(), "--", actualUrl});
292293
} catch (ExecError & e) {
293294
auto transJournal = cacheDir / ".hg" / "store" / "journal";
294295
/* hg throws "abandoned transaction" error only if this file exists */
295296
if (pathExists(transJournal)) {
296-
runHg({"recover", "-R", cacheDir});
297-
runHg({"pull", "-R", cacheDir, "--", actualUrl});
297+
runHg({"recover", "-R", cacheDir.string()});
298+
runHg({"pull", "-R", cacheDir.string(), "--", actualUrl});
298299
} else {
299300
throw ExecError(e.status, "'hg pull' %s", statusToString(e.status));
300301
}
301302
}
302303
} else {
303304
createDirs(dirOf(cacheDir.string()));
304-
runHg({"clone", "--noupdate", "--", actualUrl, cacheDir});
305+
runHg({"clone", "--noupdate", "--", actualUrl, cacheDir.string()});
305306
}
306307
}
307308

308309
/* Fetch the remote rev or ref. */
309310
auto tokens = tokenizeString<std::vector<std::string>>(runHg(
310311
{"log",
311312
"-R",
312-
cacheDir,
313+
cacheDir.string(),
313314
"-r",
314315
input.getRev() ? input.getRev()->gitRev() : *input.getRef(),
315316
"--template",
@@ -329,7 +330,7 @@ struct MercurialInputScheme : InputScheme
329330
std::filesystem::path tmpDir = createTempDir();
330331
AutoDelete delTmpDir(tmpDir, true);
331332

332-
runHg({"archive", "-R", cacheDir, "-r", rev.gitRev(), tmpDir});
333+
runHg({"archive", "-R", cacheDir.string(), "-r", rev.gitRev(), tmpDir.string()});
333334

334335
deletePath(tmpDir / ".hg_archival.txt");
335336

src/libfetchers/registry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, St
150150
if (!isAbsolute(path)) {
151151
auto storePath = downloadFile(store, settings, path, "flake-registry.json").storePath;
152152
if (auto store2 = dynamic_cast<LocalFSStore *>(&store))
153-
store2->addPermRoot(storePath, getCacheDir() + "/flake-registry.json");
153+
store2->addPermRoot(storePath, (getCacheDir() / "flake-registry.json").string());
154154
return {store.requireStoreObjectAccessor(storePath)};
155155
} else {
156156
return SourcePath{getFSSourceAccessor(), CanonPath{path}}.resolveSymlinks();

src/libmain/shared.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void printVersion(const std::string & programName)
304304
std::cout << "System type: " << settings.thisSystem << "\n";
305305
std::cout << "Additional system types: " << concatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
306306
std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n";
307-
std::cout << "System configuration file: " << settings.nixConfDir + "/nix.conf" << "\n";
307+
std::cout << "System configuration file: " << (settings.nixConfDir / "nix.conf") << "\n";
308308
std::cout << "User configuration files: " << concatStringsSep(":", settings.nixUserConfFiles) << "\n";
309309
std::cout << "Store directory: " << settings.nixStore << "\n";
310310
std::cout << "State directory: " << settings.nixStateDir << "\n";

src/libstore/globals.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void loadConfFile(AbstractConfig & config)
116116
}
117117
};
118118

119-
applyConfigFile(settings.nixConfDir + "/nix.conf");
119+
applyConfigFile((settings.nixConfDir / "nix.conf").string());
120120

121121
/* We only want to send overrides to the daemon, i.e. stuff from
122122
~/.nix/nix.conf or the command line. */
@@ -145,7 +145,7 @@ std::vector<Path> getUserConfigFiles()
145145
std::vector<Path> files;
146146
auto dirs = getConfigDirs();
147147
for (auto & dir : dirs) {
148-
files.insert(files.end(), dir + "/nix.conf");
148+
files.insert(files.end(), (dir / "nix.conf").string());
149149
}
150150
return files;
151151
}

src/libstore/nar-info-disk-cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache
8686

8787
Sync<State> _state;
8888

89-
NarInfoDiskCacheImpl(Path dbPath = getCacheDir() + "/binary-cache-v7.sqlite")
89+
NarInfoDiskCacheImpl(Path dbPath = (getCacheDir() / "binary-cache-v7.sqlite").string())
9090
{
9191
auto state(_state.lock());
9292

src/libutil/file-system.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ std::filesystem::path createTempDir(const std::filesystem::path & tmpRoot, const
687687
checkInterrupt();
688688
std::filesystem::path tmpDir = makeTempPath(tmpRoot, prefix);
689689
if (mkdir(
690-
tmpDir.c_str()
690+
tmpDir.string().c_str()
691691
#ifndef _WIN32 // TODO abstract mkdir perms for Windows
692692
,
693693
mode
@@ -734,7 +734,7 @@ AutoCloseFD createAnonymousTempFile()
734734

735735
std::pair<AutoCloseFD, Path> createTempFile(const Path & prefix)
736736
{
737-
Path tmpl(defaultTempDir() + "/" + prefix + ".XXXXXX");
737+
Path tmpl(defaultTempDir().string() + "/" + prefix + ".XXXXXX");
738738
// Strictly speaking, this is UB, but who cares...
739739
// FIXME: use O_TMPFILE.
740740
// FIXME: Windows should use FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE

0 commit comments

Comments
 (0)