{ lib, config, ... }: let cfg = config.crans; inherit (lib) mkEnableOption mkOption mkIf types optional ; in { imports = [ ./age.nix ./grub.nix ./home.nix ./locale.nix ./networking.nix ./ntp.nix ./restic_client.nix ./monitoring.nix ./nullmailer.nix ./packages.nix ./ssh.nix ./store.nix ./users.nix ./vlans.nix ./virtualisation.nix ]; options.crans = { enable = mkEnableOption "Configuration commune à toutes les machines du Crans"; name = mkOption { type = types.str; example = "vm-test"; description = "Nom de la machine"; }; isVm = mkOption { type = types.bool; description = "Est-ce une machine virtuelle ?"; }; isDebian = mkOption { type = types.bool; default = false; example = "true"; description = "Est-ce une machine Debian ?"; }; description = mkOption { type = types.str; example = "VM de test"; description = "Description de la machine"; }; id = mkOption { type = types.int; example = 135; description = '' ID de la machine : - < 100 machine physique - >= 100 VM ( id de la VM dans proxmox ) ''; }; public-ssh = mkOption { type = types.str; description = "Clé ssh public de la machine"; }; }; config = mkIf cfg.enable { crans = { homeNounou.enable = lib.mkDefault true; monitoring.enable = true; networking = { enable = lib.mkDefault true; adm.enable = lib.mkDefault true; }; resticClient.enable = lib.mkDefault true; users = { ldap.enable = true; }; }; warnings = ( optional ( cfg.isVm != (cfg.id >= 100) ) "${cfg.name}: isVm (${toString cfg.isVm}) est incohérent avec son id (${toString cfg.id})" ); }; }