Files
lix/lix/libutil/apply-config-options.hh
T
eldritch horrorsandjade b0d7a81613 fix tooling after include reorganization
clangd broke because it can't look through symlinks. compile_commands
manipulation does not fix it, clangd configuration does not fix it, a
vfs overlay does not fix it, and while a combination of those can fix
it with a bind mount in place that's just too cursed to even consider

clangd bug: https://github.com/llvm/llvm-project/issues/116877

Change-Id: I8e3e8489548eb3a7aa65ac9d12a5ec8abf814aec
2024-11-19 22:55:32 +00:00

54 lines
1.1 KiB
C++

#pragma once
/**
* @file
* @brief Options for applying `Config` settings.
*/
#include "lix/libutil/types.hh"
namespace nix {
/**
* Options for applying `Config` settings.
*/
struct ApplyConfigOptions
{
/**
* The configuration file being loaded.
*
* If set, relative paths are allowed and interpreted as relative to the
* directory of this path.
*/
std::optional<Path> path = std::nullopt;
/**
* If set, tilde paths (like `~/.config/repl.nix`) are allowed and the
* tilde is substituted for this directory.
*/
std::optional<Path> home = std::nullopt;
/**
* Is the configuration being loaded from the `$NIX_CONFIG` environment
* variable?
*
* Used for formatting error messages.
*/
bool fromEnvVar = false;
/**
* Display the `relative` path field, with a reasonable default if none is
* available.
*/
std::string relativeDisplay() const {
if (path) {
return *path;
} else if (fromEnvVar) {
return "$NIX_CONFIG";
} else {
return "<unknown>";
}
}
};
}