1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 06:53:54 +02:00

Fix some portability issues with the new C bindings

Build without GC is unbroken

Fix #10403

Also building tests with Windows (assuming rest of Windows fixes) is
unbroken.
This commit is contained in:
John Ericson 2024-04-04 15:24:42 -04:00
parent 19016c7b52
commit c1e0769355
7 changed files with 25 additions and 13 deletions

View file

@ -2,6 +2,8 @@
///@file
#include "tests/nix_api_util.hh"
#include "file-system.hh"
#include "nix_api_store.h"
#include "nix_api_store_internal.h"
@ -37,8 +39,18 @@ public:
protected:
void init_local_store()
{
auto tmpl = nix::getEnv("TMPDIR").value_or("/tmp") + "/tests_nix-store.XXXXXX";
#ifdef _WIN32
// no `mkdtemp` with MinGW
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.";
for (size_t i = 0; true; ++i) {
nixDir = tmpl + std::string { i };
if (fs::create_directory(nixDir)) break;
}
#else
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.XXXXXX";
nixDir = mkdtemp((char *) tmpl.c_str());
#endif
nixStoreDir = nixDir + "/my_nix_store";
// Options documented in `nix help-stores`