-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP get settings info out of headers, out of libutil
- Loading branch information
1 parent
9300f85
commit 13d573b
Showing
25 changed files
with
184 additions
and
65 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace nix { | ||
|
||
#include "fs-sink.hh" | ||
#include "logging.hh" | ||
|
||
struct LoggerSettings : Config | ||
{ | ||
Setting<bool> showTrace{ | ||
this, false, "show-trace", | ||
R"( | ||
Whether Nix should print out a stack trace in case of Nix | ||
expression evaluation errors. | ||
)"}; | ||
}; | ||
|
||
static GlobalConfig::Register r1(&restoreSinkSettings); | ||
|
||
struct RestoreSinkSettings : Config | ||
{ | ||
Setting<bool> preallocateContents{this, false, "preallocate-contents", | ||
"Whether to preallocate files when writing objects with known size."}; | ||
}; | ||
|
||
static GlobalConfig::Register rLoggerSettings(&loggerSettings); | ||
|
||
struct ArchiveSettings : Config | ||
{ | ||
Setting<bool> useCaseHack{this, | ||
#if __APPLE__ | ||
true, | ||
#else | ||
false, | ||
#endif | ||
"use-case-hack", | ||
"Whether to enable a Darwin-specific hack for dealing with file name collisions."}; | ||
}; | ||
|
||
static GlobalConfig::Register rArchiveSettings(&archiveSettings); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
///@type | ||
|
||
namespace nix { | ||
|
||
template<typename T> | ||
struct JustValue { | ||
T value; | ||
|
||
operator const T &() const { return value; } | ||
operator T &() { return value; } | ||
const T & get() const { return value; } | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "experimental-feature-settings.hh" | ||
|
||
namespace nix { | ||
|
||
const extern ExperimentalFeatureSettings experimentalFeatureSettingsDefaults = { | ||
{ | ||
.experimentalFeatures = { | ||
.value = {} | ||
}, | ||
} | ||
}; | ||
|
||
ExperimentalFeatureSettings experimentalFeatureSettings = experimentalFeatureSettingsDefaults; | ||
|
||
bool ExperimentalFeatureSettings::isEnabled(const ExperimentalFeature & feature) const | ||
{ | ||
auto & f = experimentalFeatures.get(); | ||
return std::find(f.begin(), f.end(), feature) != f.end(); | ||
} | ||
|
||
void ExperimentalFeatureSettings::require(const ExperimentalFeature & feature) const | ||
{ | ||
if (!isEnabled(feature)) | ||
throw MissingExperimentalFeature(feature); | ||
} | ||
|
||
bool ExperimentalFeatureSettings::isEnabled(const std::optional<ExperimentalFeature> & feature) const | ||
{ | ||
return !feature || isEnabled(*feature); | ||
} | ||
|
||
void ExperimentalFeatureSettings::require(const std::optional<ExperimentalFeature> & feature) const | ||
{ | ||
if (feature) require(*feature); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
///@file | ||
|
||
#include "experimental-features.hh" | ||
|
||
namespace nix { | ||
|
||
template<template<typename> class R> | ||
struct ExperimentalFeatureSettingsT | ||
{ | ||
R<std::set<ExperimentalFeature>> experimentalFeatures; | ||
}; | ||
|
||
struct ExperimentalFeatureSettings : ExperimentalFeatureSettingsT<JustValue> | ||
{ | ||
/** | ||
* Check whether the given experimental feature is enabled. | ||
*/ | ||
bool isEnabled(const ExperimentalFeature &) const; | ||
|
||
/** | ||
* Require an experimental feature be enabled, throwing an error if it is | ||
* not. | ||
*/ | ||
void require(const ExperimentalFeature &) const; | ||
|
||
/** | ||
* `std::nullopt` pointer means no feature, which means there is nothing that could be | ||
* disabled, and so the function returns true in that case. | ||
*/ | ||
bool isEnabled(const std::optional<ExperimentalFeature> &) const; | ||
|
||
/** | ||
* `std::nullopt` pointer means no feature, which means there is nothing that could be | ||
* disabled, and so the function does nothing in that case. | ||
*/ | ||
void require(const std::optional<ExperimentalFeature> &) const; | ||
}; | ||
|
||
const extern ExperimentalFeatureSettings experimentalFeatureSettingsDefaults; | ||
|
||
// FIXME: don't use a global variable. | ||
extern ExperimentalFeatureSettings experimentalFeatureSettings; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.