aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/experimental-features.hh
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2022-03-01 13:58:17 +0100
committerGitHub <noreply@github.com>2022-03-01 13:58:17 +0100
commit47dec825c5daeeb9d615eb4d1eead3dbaa06c7c9 (patch)
tree9d4426dfe847570906487649c32c5b320697705c /src/libutil/experimental-features.hh
parent79152e307e7eef667c3de9c21571d017654a7c32 (diff)
parentdc92b01885c0c49d094148b1c4dc871ccdd265ad (diff)
Merge pull request #6181 from obsidiansystems/auto-uid-allocation
Auto uid allocation -- update with latest master
Diffstat (limited to 'src/libutil/experimental-features.hh')
-rw-r--r--src/libutil/experimental-features.hh58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libutil/experimental-features.hh b/src/libutil/experimental-features.hh
new file mode 100644
index 000000000..00df8b165
--- /dev/null
+++ b/src/libutil/experimental-features.hh
@@ -0,0 +1,58 @@
+#pragma once
+
+#include "comparator.hh"
+#include "error.hh"
+#include "nlohmann/json_fwd.hpp"
+#include "types.hh"
+
+namespace nix {
+
+/**
+ * The list of available experimental features.
+ *
+ * If you update this, don’t forget to also change the map defining their
+ * string representation in the corresponding `.cc` file.
+ **/
+enum struct ExperimentalFeature
+{
+ CaDerivations,
+ Flakes,
+ NixCommand,
+ RecursiveNix,
+ NoUrlLiterals,
+ AutoAllocateUids,
+ SystemdCgroup,
+};
+
+/**
+ * Just because writing `ExperimentalFeature::CaDerivations` is way too long
+ */
+using Xp = ExperimentalFeature;
+
+const std::optional<ExperimentalFeature> parseExperimentalFeature(
+ const std::string_view & name);
+std::string_view showExperimentalFeature(const ExperimentalFeature);
+
+std::ostream & operator<<(
+ std::ostream & str,
+ const ExperimentalFeature & feature);
+
+/**
+ * Parse a set of strings to the corresponding set of experimental features,
+ * ignoring (but warning for) any unkwown feature.
+ */
+std::set<ExperimentalFeature> parseFeatures(const std::set<std::string> &);
+
+class MissingExperimentalFeature : public Error
+{
+public:
+ ExperimentalFeature missingFeature;
+
+ MissingExperimentalFeature(ExperimentalFeature);
+ virtual const char * sname() const override
+ {
+ return "MissingExperimentalFeature";
+ }
+};
+
+}