mirror of
https://github.com/NixOS/nix.git
synced 2025-12-07 17:41:00 +01:00
For example, instead of doing
#include "nix/store-config.hh"
#include "nix/derived-path.hh"
Now do
#include "nix/store/config.hh"
#include "nix/store/derived-path.hh"
This was originally planned in the issue, and also recent requested by
Eelco.
Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.
Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!
Progress on #7876
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
#include "nix/store/indirect-root-store.hh"
|
|
|
|
namespace nix {
|
|
|
|
void IndirectRootStore::makeSymlink(const Path & link, const Path & target)
|
|
{
|
|
/* Create directories up to `gcRoot'. */
|
|
createDirs(dirOf(link));
|
|
|
|
/* Create the new symlink. */
|
|
Path tempLink = fmt("%1%.tmp-%2%-%3%", link, getpid(), rand());
|
|
createSymlink(target, tempLink);
|
|
|
|
/* Atomically replace the old one. */
|
|
std::filesystem::rename(tempLink, link);
|
|
}
|
|
|
|
Path IndirectRootStore::addPermRoot(const StorePath & storePath, const Path & _gcRoot)
|
|
{
|
|
Path gcRoot(canonPath(_gcRoot));
|
|
|
|
if (isInStore(gcRoot))
|
|
throw Error(
|
|
"creating a garbage collector root (%1%) in the Nix store is forbidden "
|
|
"(are you running nix-build inside the store?)",
|
|
gcRoot);
|
|
|
|
/* Register this root with the garbage collector, if it's
|
|
running. This should be superfluous since the caller should
|
|
have registered this root yet, but let's be on the safe
|
|
side. */
|
|
addTempRoot(storePath);
|
|
|
|
/* Don't clobber the link if it already exists and doesn't
|
|
point to the Nix store. */
|
|
if (pathExists(gcRoot) && (!std::filesystem::is_symlink(gcRoot) || !isInStore(readLink(gcRoot))))
|
|
throw Error("cannot create symlink '%1%'; already exists", gcRoot);
|
|
|
|
makeSymlink(gcRoot, printStorePath(storePath));
|
|
addIndirectRoot(gcRoot);
|
|
|
|
return gcRoot;
|
|
}
|
|
|
|
}
|