mirror of
https://github.com/NixOS/nix
synced 2025-06-26 07:31:15 +02:00
Relax store path canonicalization
This commit is contained in:
parent
b529d91902
commit
1063aa502a
2 changed files with 19 additions and 2 deletions
|
@ -49,7 +49,13 @@ static GlobalConfig::Register rSettings(&settings);
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
: nixPrefix(NIX_PREFIX)
|
: nixPrefix(NIX_PREFIX)
|
||||||
, nixStore(canonPath(getEnvNonEmpty("NIX_STORE_DIR").value_or(getEnvNonEmpty("NIX_STORE").value_or(NIX_STORE_DIR))))
|
, nixStore(
|
||||||
|
#ifndef _WIN32
|
||||||
|
// On Windows `/nix/store` is not a canonical path, but we dont'
|
||||||
|
// want to deal with that yet.
|
||||||
|
canonPath
|
||||||
|
#endif
|
||||||
|
(getEnvNonEmpty("NIX_STORE_DIR").value_or(getEnvNonEmpty("NIX_STORE").value_or(NIX_STORE_DIR))))
|
||||||
, nixDataDir(canonPath(getEnvNonEmpty("NIX_DATA_DIR").value_or(NIX_DATA_DIR)))
|
, nixDataDir(canonPath(getEnvNonEmpty("NIX_DATA_DIR").value_or(NIX_DATA_DIR)))
|
||||||
, nixLogDir(canonPath(getEnvNonEmpty("NIX_LOG_DIR").value_or(NIX_LOG_DIR)))
|
, nixLogDir(canonPath(getEnvNonEmpty("NIX_LOG_DIR").value_or(NIX_LOG_DIR)))
|
||||||
, nixStateDir(canonPath(getEnvNonEmpty("NIX_STATE_DIR").value_or(NIX_STATE_DIR)))
|
, nixStateDir(canonPath(getEnvNonEmpty("NIX_STATE_DIR").value_or(NIX_STATE_DIR)))
|
||||||
|
|
|
@ -63,7 +63,18 @@ StorePath StorePath::random(std::string_view name)
|
||||||
|
|
||||||
StorePath StoreDirConfig::parseStorePath(std::string_view path) const
|
StorePath StoreDirConfig::parseStorePath(std::string_view path) const
|
||||||
{
|
{
|
||||||
auto p = canonPath(std::string(path));
|
// On Windows, `/nix/store` is not a canonical path. More broadly it
|
||||||
|
// is unclear whether this function should be using the native
|
||||||
|
// notion of a canonical path at all. For example, it makes to
|
||||||
|
// support remote stores whose store dir is a non-native path (e.g.
|
||||||
|
// Windows <-> Unix ssh-ing).
|
||||||
|
auto p =
|
||||||
|
#ifdef _WIN32
|
||||||
|
path
|
||||||
|
#else
|
||||||
|
canonPath(std::string(path))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
if (dirOf(p) != storeDir)
|
if (dirOf(p) != storeDir)
|
||||||
throw BadStorePath("path '%s' is not in the Nix store", p);
|
throw BadStorePath("path '%s' is not in the Nix store", p);
|
||||||
return StorePath(baseNameOf(p));
|
return StorePath(baseNameOf(p));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue