1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-08 18:11:02 +01:00

Merge pull request #14702 from NixOS/fix-mingw

Fix mingw build
This commit is contained in:
Eelco Dolstra 2025-12-03 19:55:03 +00:00 committed by GitHub
commit 5b95745bc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 32 additions and 30 deletions

View file

@ -142,7 +142,7 @@ NixRepl::NixRepl(
, getValues(getValues)
, staticEnv(new StaticEnv(nullptr, state->staticBaseEnv))
, runNixPtr{runNix}
, interacter(make_unique<ReadlineLikeInteracter>(getDataDir() + "/repl-history"))
, interacter(make_unique<ReadlineLikeInteracter>((getDataDir() / "repl-history").string()))
{
}

View file

@ -38,7 +38,7 @@ struct CacheImpl : Cache
{
auto state(_state.lock());
auto dbPath = getCacheDir() + "/fetcher-cache-v4.sqlite";
auto dbPath = (getCacheDir() / "fetcher-cache-v4.sqlite").string();
createDirs(dirOf(dbPath));
state->db = SQLite(dbPath);

View file

@ -212,7 +212,7 @@ static void initRepoAtomically(std::filesystem::path & path, bool bare)
AutoDelete delTmpDir(tmpDir, true);
Repository tmpRepo;
if (git_repository_init(Setter(tmpRepo), tmpDir.c_str(), bare))
if (git_repository_init(Setter(tmpRepo), tmpDir.string().c_str(), bare))
throw Error("creating Git repository %s: %s", path, git_error_last()->message);
try {
std::filesystem::rename(tmpDir, path);

View file

@ -61,7 +61,7 @@ std::optional<std::string> readHead(const std::filesystem::path & path)
RunOptions{
.program = "git",
// FIXME: use 'HEAD' to avoid returning all refs
.args = {"ls-remote", "--symref", path},
.args = {"ls-remote", "--symref", path.string()},
.isInteractive = true,
});
if (status != 0)
@ -88,7 +88,7 @@ bool storeCachedHead(const std::string & actualUrl, bool shallow, const std::str
{
std::filesystem::path cacheDir = getCachePath(actualUrl, shallow);
try {
runProgram("git", true, {"-C", cacheDir, "--git-dir", ".", "symbolic-ref", "--", "HEAD", headRef});
runProgram("git", true, {"-C", cacheDir.string(), "--git-dir", ".", "symbolic-ref", "--", "HEAD", headRef});
} catch (ExecError & e) {
if (
#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
time_t now = time(0);
struct stat st;
std::optional<std::string> cachedRef;
if (stat(headRefFile.c_str(), &st) == 0) {
if (stat(headRefFile.string().c_str(), &st) == 0) {
cachedRef = readHead(cacheDir);
if (cachedRef != std::nullopt && *cachedRef != gitInitialBranch && isCacheFileWithinTtl(now, st)) {
debug("using cached HEAD ref '%s' for repo '%s'", *cachedRef, actualUrl);
@ -450,7 +450,7 @@ struct GitInputScheme : InputScheme
if (input.getRev())
throw UnimplementedError("cloning a specific revision is not implemented");
args.push_back(destDir);
args.push_back(destDir.string());
runProgram("git", true, args, {}, true);
}

View file

@ -281,27 +281,28 @@ struct MercurialInputScheme : InputScheme
/* If this is a commit hash that we already have, we don't
have to pull again. */
if (!(input.getRev() && pathExists(cacheDir)
&& runProgram(hgOptions({"log", "-R", cacheDir, "-r", input.getRev()->gitRev(), "--template", "1"}))
&& runProgram(
hgOptions({"log", "-R", cacheDir.string(), "-r", input.getRev()->gitRev(), "--template", "1"}))
.second
== "1")) {
Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Mercurial repository '%s'", actualUrl));
if (pathExists(cacheDir)) {
try {
runHg({"pull", "-R", cacheDir, "--", actualUrl});
runHg({"pull", "-R", cacheDir.string(), "--", actualUrl});
} catch (ExecError & e) {
auto transJournal = cacheDir / ".hg" / "store" / "journal";
/* hg throws "abandoned transaction" error only if this file exists */
if (pathExists(transJournal)) {
runHg({"recover", "-R", cacheDir});
runHg({"pull", "-R", cacheDir, "--", actualUrl});
runHg({"recover", "-R", cacheDir.string()});
runHg({"pull", "-R", cacheDir.string(), "--", actualUrl});
} else {
throw ExecError(e.status, "'hg pull' %s", statusToString(e.status));
}
}
} else {
createDirs(dirOf(cacheDir.string()));
runHg({"clone", "--noupdate", "--", actualUrl, cacheDir});
runHg({"clone", "--noupdate", "--", actualUrl, cacheDir.string()});
}
}
@ -309,7 +310,7 @@ struct MercurialInputScheme : InputScheme
auto tokens = tokenizeString<std::vector<std::string>>(runHg(
{"log",
"-R",
cacheDir,
cacheDir.string(),
"-r",
input.getRev() ? input.getRev()->gitRev() : *input.getRef(),
"--template",
@ -329,7 +330,7 @@ struct MercurialInputScheme : InputScheme
std::filesystem::path tmpDir = createTempDir();
AutoDelete delTmpDir(tmpDir, true);
runHg({"archive", "-R", cacheDir, "-r", rev.gitRev(), tmpDir});
runHg({"archive", "-R", cacheDir.string(), "-r", rev.gitRev(), tmpDir.string()});
deletePath(tmpDir / ".hg_archival.txt");

View file

@ -150,7 +150,7 @@ static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, St
if (!isAbsolute(path)) {
auto storePath = downloadFile(store, settings, path, "flake-registry.json").storePath;
if (auto store2 = dynamic_cast<LocalFSStore *>(&store))
store2->addPermRoot(storePath, getCacheDir() + "/flake-registry.json");
store2->addPermRoot(storePath, (getCacheDir() / "flake-registry.json").string());
return {store.requireStoreObjectAccessor(storePath)};
} else {
return SourcePath{getFSSourceAccessor(), CanonPath{path}}.resolveSymlinks();

View file

@ -304,7 +304,7 @@ void printVersion(const std::string & programName)
std::cout << "System type: " << settings.thisSystem << "\n";
std::cout << "Additional system types: " << concatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n";
std::cout << "System configuration file: " << settings.nixConfDir + "/nix.conf" << "\n";
std::cout << "System configuration file: " << (settings.nixConfDir / "nix.conf") << "\n";
std::cout << "User configuration files: " << concatStringsSep(":", settings.nixUserConfFiles) << "\n";
std::cout << "Store directory: " << settings.nixStore << "\n";
std::cout << "State directory: " << settings.nixStateDir << "\n";

View file

@ -116,7 +116,7 @@ void loadConfFile(AbstractConfig & config)
}
};
applyConfigFile(settings.nixConfDir + "/nix.conf");
applyConfigFile((settings.nixConfDir / "nix.conf").string());
/* We only want to send overrides to the daemon, i.e. stuff from
~/.nix/nix.conf or the command line. */
@ -145,7 +145,7 @@ std::vector<Path> getUserConfigFiles()
std::vector<Path> files;
auto dirs = getConfigDirs();
for (auto & dir : dirs) {
files.insert(files.end(), dir + "/nix.conf");
files.insert(files.end(), (dir / "nix.conf").string());
}
return files;
}

View file

@ -86,7 +86,7 @@ public:
Sync<State> _state;
NarInfoDiskCacheImpl(Path dbPath = getCacheDir() + "/binary-cache-v7.sqlite")
NarInfoDiskCacheImpl(Path dbPath = (getCacheDir() / "binary-cache-v7.sqlite").string())
{
auto state(_state.lock());

View file

@ -687,7 +687,7 @@ std::filesystem::path createTempDir(const std::filesystem::path & tmpRoot, const
checkInterrupt();
std::filesystem::path tmpDir = makeTempPath(tmpRoot, prefix);
if (mkdir(
tmpDir.c_str()
tmpDir.string().c_str()
#ifndef _WIN32 // TODO abstract mkdir perms for Windows
,
mode
@ -734,7 +734,7 @@ AutoCloseFD createAnonymousTempFile()
std::pair<AutoCloseFD, Path> createTempFile(const Path & prefix)
{
Path tmpl(defaultTempDir() + "/" + prefix + ".XXXXXX");
Path tmpl(defaultTempDir().string() + "/" + prefix + ".XXXXXX");
// Strictly speaking, this is UB, but who cares...
// FIXME: use O_TMPFILE.
// FIXME: Windows should use FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE

View file

@ -206,8 +206,9 @@ void FdSource::restart()
if (!isSeekable)
throw Error("can't seek to the start of a file");
buffer.reset();
read = bufPosOut = bufPosOut = 0;
if (lseek(fd, 0, SEEK_SET) == -1)
read = bufPosIn = bufPosOut = 0;
int fd_ = fromDescriptorReadOnly(fd);
if (lseek(fd_, 0, SEEK_SET) == -1)
throw SysError("seeking to the start of a file");
}

View file

@ -90,7 +90,7 @@ std::string expandTilde(std::string_view path)
// TODO: expand ~user ?
auto tilde = path.substr(0, 2);
if (tilde == "~/" || tilde == "~")
return getHome() + std::string(path.substr(1));
return getHome().string() + std::string(path.substr(1));
else
return std::string(path);
}

View file

@ -40,7 +40,7 @@ std::filesystem::path getHome()
static std::filesystem::path homeDir = []() {
std::filesystem::path homeDir = getEnv("USERPROFILE").value_or("C:\\Users\\Default");
assert(!homeDir.empty());
return canonPath(homeDir);
return canonPath(homeDir.string());
}();
return homeDir;
}

View file

@ -1261,7 +1261,7 @@ static void opSwitchProfile(Globals & globals, Strings opFlags, Strings opArgs)
throw UsageError("exactly one argument expected");
Path profile = absPath(opArgs.front());
Path profileLink = settings.useXDGBaseDirectories ? createNixStateDir() + "/profile" : getHome() + "/.nix-profile";
auto profileLink = settings.useXDGBaseDirectories ? createNixStateDir() / "profile" : getHome() / ".nix-profile";
switchLink(profileLink, profile);
}

View file

@ -247,13 +247,13 @@ struct ProfileManifest
}
}
buildProfile(tempDir, std::move(pkgs));
buildProfile(tempDir.string(), std::move(pkgs));
writeFile(tempDir + "/manifest.json", toJSON(*store).dump());
writeFile(tempDir / "manifest.json", toJSON(*store).dump());
/* Add the symlink tree to the store. */
StringSink sink;
dumpPath(tempDir, sink);
dumpPath(tempDir.string(), sink);
auto narHash = hashString(HashAlgorithm::SHA256, sink.s);

View file

@ -43,7 +43,7 @@ public:
Path getRegistryPath()
{
if (registry_path.empty()) {
return fetchers::getUserRegistryPath();
return fetchers::getUserRegistryPath().string();
} else {
return registry_path;
}