From b277551d6a387d0372b8ea9d81bf5af3e2fb5844 Mon Sep 17 00:00:00 2001 From: Jean-Pierre PRUNARET Date: Sat, 9 Jul 2016 21:12:20 +0200 Subject: [PATCH] =?UTF-8?q?moulinette=20de=20configuration=20par=20flags?= =?UTF-8?q?=20de=20fonctionalit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-generator.nix | 129 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 config-generator.nix diff --git a/config-generator.nix b/config-generator.nix new file mode 100644 index 0000000..61c24e4 --- /dev/null +++ b/config-generator.nix @@ -0,0 +1,129 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkEnableOption mkIf mkMerge mkOption singleton types; + #inherit (pkgs) bird; + cfg = config.r6d.config-generator; + + # configFile = pkgs.writeText "bird.conf" '' + # ${cfg.config} + #''; +in + +{ + imports = [ + ]; + + ###### interface + + options = { + + r6d.config-generator = { + + enable = mkEnableOption "Generation de la configuration d'une machine"; + + auto-upgrade = mkOption { + type = types.bool; + default = true; + description = '' + Profil pour activer les mises à jour automatiques. + ''; + }; + + docker = mkOption { + type = types.bool; + default = false; + description = '' + Profil pour l'utilisation de Docker. + ''; + }; + + jeux = mkOption { + type = types.bool; + default = false; + description = '' + Profil pour les jeux vidéos. + ''; + }; + + laptop = mkOption { + type = types.bool; + default = false; + description = '' + Profil pour les outils spécifiques aux ordinateurs portables.. + ''; + }; + + locate = mkOption { + type = types.bool; + default = true; + description = '' + Profil pour activer la fonction locate. + ''; + }; + + nix-serve-server = mkOption { + type = types.bool; + default = false; + description = '' + Profil pour que la machine soit un serveur de cache nix. + ''; + }; + + swap = mkOption { + type = types.bool; + default = false; + description = '' + Profil pour que le swap soit activé. + ''; + }; + + virtualbox = mkOption { + type = types.bool; + default = false; + description = '' + Profil pour l'utilisation de VirtualBox. + ''; + }; + }; + }; + + + ###### implementation + # https://nixos.org/releases/nixos/14.12-small/nixos-14.12.374.61adf9e/manual/sec-writing-modules.html + # https://nixos.org/wiki/NixOS:extend_NixOS + config = mkMerge + [ # Unconditional stuff. + { + #environment.systemPackages = [ ... ]; + r6d.config-generator.enable = true; + } + + # Conditional stuff. + ## Affectation des profils aux machines + (mkIf (config.networking.hostName == "radx.prunetwork.fr") { + r6d.config-generator = { + docker = true; + jeux = true; + laptop = true; + nix-serve-server = true; + swap = true; + virtualbox = true; + }; + }) + + (mkIf (config.networking.hostName == "phenom.dubronetwork.fr") { + r6d.config-generator = { + docker = true; + jeux = true; + laptop = true; + nix-serve-server = true; + swap = true; + virtualbox = true; + }; + }) + + ## Contenu des Profils + # -> voir les sources des dépots base & desktop + ]; +}