2021-10-25 16:53:01 +03:00
|
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
|
///@file
|
2021-10-25 16:53:01 +03:00
|
|
|
|
|
|
|
|
|
#include "comparator.hh"
|
|
|
|
|
#include "error.hh"
|
2023-06-16 22:19:14 +03:00
|
|
|
|
#include "json-utils.hh"
|
2021-10-25 16:53:01 +03:00
|
|
|
|
#include "types.hh"
|
|
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The list of available experimental features.
|
|
|
|
|
*
|
2023-04-03 01:11:16 +03:00
|
|
|
|
* If you update this, don’t forget to also change the map defining
|
|
|
|
|
* their string representation and documentation in the corresponding
|
|
|
|
|
* `.cc` file as well.
|
2023-03-27 04:12:25 +03:00
|
|
|
|
*/
|
2021-10-25 16:53:01 +03:00
|
|
|
|
enum struct ExperimentalFeature
|
|
|
|
|
{
|
|
|
|
|
CaDerivations,
|
2022-03-30 17:31:01 +03:00
|
|
|
|
ImpureDerivations,
|
2021-10-25 16:53:01 +03:00
|
|
|
|
Flakes,
|
|
|
|
|
NixCommand,
|
|
|
|
|
RecursiveNix,
|
2022-03-01 01:54:20 +02:00
|
|
|
|
NoUrlLiterals,
|
2022-03-24 22:33:20 +02:00
|
|
|
|
FetchClosure,
|
2022-05-20 15:20:00 +03:00
|
|
|
|
ReplFlake,
|
2022-03-01 01:54:20 +02:00
|
|
|
|
AutoAllocateUids,
|
2022-11-18 11:39:28 +02:00
|
|
|
|
Cgroups,
|
2023-04-17 16:41:39 +03:00
|
|
|
|
DaemonTrustOverride,
|
2023-04-18 02:02:45 +03:00
|
|
|
|
DynamicDerivations,
|
2023-06-09 12:53:18 +03:00
|
|
|
|
ParseTomlTimestamps,
|
2023-06-20 12:34:09 +03:00
|
|
|
|
ReadOnlyLocalStore,
|
2023-10-11 14:58:42 +03:00
|
|
|
|
ConfigurableImpureEnv,
|
2023-10-20 22:16:56 +03:00
|
|
|
|
VerifiedFetches,
|
2021-10-25 16:53:01 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Just because writing `ExperimentalFeature::CaDerivations` is way too long
|
|
|
|
|
*/
|
|
|
|
|
using Xp = ExperimentalFeature;
|
|
|
|
|
|
2023-04-03 01:57:46 +03:00
|
|
|
|
/**
|
|
|
|
|
* Parse an experimental feature (enum value) from its name. Experimental
|
|
|
|
|
* feature flag names are hyphenated and do not contain spaces.
|
|
|
|
|
*/
|
2021-10-25 16:53:01 +03:00
|
|
|
|
const std::optional<ExperimentalFeature> parseExperimentalFeature(
|
|
|
|
|
const std::string_view & name);
|
2023-04-03 01:57:46 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the name of an experimental feature. This is the opposite of
|
|
|
|
|
* parseExperimentalFeature().
|
|
|
|
|
*/
|
2021-10-25 16:53:01 +03:00
|
|
|
|
std::string_view showExperimentalFeature(const ExperimentalFeature);
|
2023-04-03 01:57:46 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Compute the documentation of all experimental features.
|
|
|
|
|
*
|
2023-04-05 05:57:11 +03:00
|
|
|
|
* See `doc/manual` for how this information is used.
|
2023-04-03 01:57:46 +03:00
|
|
|
|
*/
|
2023-04-05 05:57:11 +03:00
|
|
|
|
nlohmann::json documentExperimentalFeatures();
|
2021-10-25 16:53:01 +03:00
|
|
|
|
|
2023-04-03 01:57:46 +03:00
|
|
|
|
/**
|
|
|
|
|
* Shorthand for `str << showExperimentalFeature(feature)`.
|
|
|
|
|
*/
|
2021-10-25 16:53:01 +03:00
|
|
|
|
std::ostream & operator<<(
|
|
|
|
|
std::ostream & str,
|
|
|
|
|
const ExperimentalFeature & feature);
|
|
|
|
|
|
|
|
|
|
/**
|
2023-04-03 01:57:46 +03:00
|
|
|
|
* Parse a set of strings to the corresponding set of experimental
|
|
|
|
|
* features, ignoring (but warning for) any unknown feature.
|
2021-10-25 16:53:01 +03:00
|
|
|
|
*/
|
|
|
|
|
std::set<ExperimentalFeature> parseFeatures(const std::set<std::string> &);
|
|
|
|
|
|
2023-04-03 01:57:46 +03:00
|
|
|
|
/**
|
|
|
|
|
* An experimental feature was required for some (experimental)
|
|
|
|
|
* operation, but was not enabled.
|
|
|
|
|
*/
|
2021-10-25 16:53:01 +03:00
|
|
|
|
class MissingExperimentalFeature : public Error
|
|
|
|
|
{
|
|
|
|
|
public:
|
2023-04-03 01:57:46 +03:00
|
|
|
|
/**
|
|
|
|
|
* The experimental feature that was required but not enabled.
|
|
|
|
|
*/
|
2021-10-25 16:53:01 +03:00
|
|
|
|
ExperimentalFeature missingFeature;
|
|
|
|
|
|
2023-04-03 01:57:46 +03:00
|
|
|
|
MissingExperimentalFeature(ExperimentalFeature missingFeature);
|
2021-10-25 16:53:01 +03:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-20 16:41:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Semi-magic conversion to and from json.
|
|
|
|
|
* See the nlohmann/json readme for more details.
|
|
|
|
|
*/
|
2022-05-03 15:37:28 +03:00
|
|
|
|
void to_json(nlohmann::json &, const ExperimentalFeature &);
|
|
|
|
|
void from_json(const nlohmann::json &, ExperimentalFeature &);
|
2022-04-20 16:41:01 +03:00
|
|
|
|
|
2023-06-16 22:19:14 +03:00
|
|
|
|
/**
|
|
|
|
|
* It is always rendered as a string
|
|
|
|
|
*/
|
|
|
|
|
template<>
|
|
|
|
|
struct json_avoids_null<ExperimentalFeature> : std::true_type {};
|
|
|
|
|
|
2021-10-25 16:53:01 +03:00
|
|
|
|
}
|