From b03d4acfe24e63308195ac841a311a0c856582e6 Mon Sep 17 00:00:00 2001 From: Jean-Pierre PRUNARET Date: Sat, 13 May 2017 17:13:23 +0200 Subject: [PATCH] add assertions on base --- options.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/options.nix b/options.nix index c56d4d5..9466eb4 100644 --- a/options.nix +++ b/options.nix @@ -128,6 +128,10 @@ let }; }; }; + + annuaire = config.r6d.machines; + currentMachine = annuaire."${config.networking.hostName}"; + flags = currentMachine.configuration-flags; in { @@ -139,4 +143,33 @@ in ''; }; }; + + config = { + /** + prototype : (expression A ) && tests || !(expression A) -> réalise le test si A est satisfait, et continue sinon = pas de politique + */ + assertions = [ + { + assertion = (currentMachine.profiles.isWorkstation && (currentMachine.profiles.isDesktopEnvironment == true)) + || (!currentMachine.profiles.isWorkstation); + message = "A workstation requires a graphical environement."; + } + { + assertion = (currentMachine.profiles.isDesktopEnvironment && (config.services.xserver.enable == true)) + || (!currentMachine.profiles.isDesktopEnvironment); + message = "You need to enable xserver manually."; + } + { + assertion = (currentMachine.profiles.isServer && (currentMachine.profiles.isDesktopEnvironment == false)) + || (!currentMachine.profiles.isServer); + message = "A graphical environment is not required for a server."; + } + { + /* authorité xor resolveur */ + assertion = (flags.dns_autorite && ! flags.dns_resolveur) + || (!flags.dns_autorite && flags.dns_resolveur); + message = "Both authoritative and recursor DNS services can't be live simultaneously. Choose only one!"; + } + ]; + }; }