You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
301 lines
10 KiB
Nix
301 lines
10 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) mkEnableOption mkIf mkMerge mkOption singleton types;
|
|
cfg = config.r6d.config-generator;
|
|
pfl = config.r6d.profiles;
|
|
comp = config.r6d.computers;
|
|
host = config.networking.hostName;
|
|
in
|
|
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
#* Utilisé pour afecter des capacités aux machines
|
|
r6d.profiles = {
|
|
# Domaine
|
|
isDubronetwork = mkEnableOption "Pour distinguer les machines dubronetwork.";
|
|
isPrunetwork = mkEnableOption "Pour distinguer les machines prunetwork.";
|
|
# Utilisation machine
|
|
isDesktop = mkEnableOption "Pour indiquer une machine avec interface graphique.";
|
|
isHome = mkEnableOption "Pour indiquer que la machine sert à la maison (divertissement & autre).";
|
|
isServer = mkEnableOption "Pour indiquer qu'il s'agit d'un serveur.";
|
|
isWorkstation = mkEnableOption "Pour indiquer que la machine sert à travailler.";
|
|
};
|
|
|
|
#* Utilisé dans les fichiers .nix
|
|
r6d.config-generator = {
|
|
enable = mkEnableOption "Génération de la configuration d'une machine.";
|
|
awesome = mkEnableOption "Profil pour activer le gestionnaire de fenêtre awesome.";
|
|
auto-upgrade = mkEnableOption "Profil pour activer les mises à jour automatiques.";
|
|
cartographie = mkEnableOption "Profil pour activer les outils de gestion de données géographiques.";
|
|
conception-assistee = mkEnableOption "Profil pour activer les outils de conception électronique & modélisation 3D";
|
|
database_postgres=mkEnableOption "Profil pour activer le SGBD PostgreSQL.";
|
|
developpement = mkEnableOption "Profil pour activer les outils de développement";
|
|
docker = mkEnableOption "Profil pour l'utilisation de Docker.";
|
|
dovecot = mkEnableOption "Profil pour activer le serveur Dovecot.";
|
|
dns_autorite = mkEnableOption "Profil pour servir les fichiers de zone DNS.";
|
|
dns_resolveur = mkEnableOption "Profil pour activer un résolveur DNS local.";
|
|
edition-musique = mkEnableOption "Profil pour la création/édition de musique.";
|
|
edition-photo = mkEnableOption "Profil pour la création/édition de photos.";
|
|
edition-video = mkEnableOption "Profil pour la création/édition de video.";
|
|
fail2ban = mkEnableOption "Profil pour activer Fail2ban.";
|
|
hydra-builder = mkEnableOption "Profil pour une machine qui compile pour hydra.";
|
|
hydra-core = mkEnableOption "Profil pour un serveur hydra.";
|
|
jeux = mkEnableOption "Profil pour les jeux vidéos.";
|
|
laptop = mkEnableOption "Profil pour les outils spécifiques aux ordinateurs portables..";
|
|
locate = mkEnableOption "Profil pour activer la fonction locate.";
|
|
mailboxes = mkEnableOption "Profil pour stocker les mails dans des boîtes aux lettres.";
|
|
murmur = mkEnableOption "Profil pour activer un serveur Mumble (murmur)";
|
|
nix-serve-client= mkEnableOption "Profil pour que la machine soit un client de cache nix.";
|
|
nix-serve-server= mkEnableOption "Profil pour que la machine soit un serveur de cache nix.";
|
|
nixStoreProxyCache = mkEnableOption "Profil pour activer le proxy cahce nginx pour le nix store";
|
|
online-ipv6 = mkEnableOption "Profil pour activer l'IPv6 de online.net";
|
|
print = mkEnableOption "Profil pour activer cups & pouvoir imprimer.";
|
|
rabbitmq = mkEnableOption "Profil pour activer le service de messagerie AMQP.";
|
|
radicale = mkEnableOption "Profil pour activer le service d'hébergement de calendrier + tâches & contacts.";
|
|
swap = mkEnableOption "Profil pour que le swap soit activé.";
|
|
virtualbox = mkEnableOption "Profil pour l'utilisation de VirtualBox.";
|
|
xmonad = mkEnableOption "Profil pour activer le gestionnaire de fenêtres xmonad.";
|
|
znc = mkEnableOption "Profil pour activer le relais IRC ZNC.";
|
|
|
|
tincAddress = mkOption {
|
|
default = "";
|
|
example = "192.168.1.1";
|
|
description = "Adresse du noeud tinc local";
|
|
type = lib.types.string;
|
|
};
|
|
tincExtraConfig = mkOption {
|
|
default = "";
|
|
example = ''
|
|
Mode = router
|
|
ConnecTo = bar
|
|
'';
|
|
description = "Configuration supplémentaire pour tinc";
|
|
type = lib.types.string;
|
|
};
|
|
};
|
|
#* Utilisé pour avoir des raccourcis de machine
|
|
r6d.computers = {
|
|
isLatitude = mkEnableOption "Identification du nom de machine.";
|
|
isMonstre = mkEnableOption "Identification du nom de machine.";
|
|
isNeoNomade = mkEnableOption "Identification du nom de machine.";
|
|
isNomade = mkEnableOption "Identification du nom de machine.";
|
|
isOcean = mkEnableOption "Identification du nom de machine.";
|
|
isPedro = mkEnableOption "Identification du nom de machine.";
|
|
isPhenom = mkEnableOption "Identification du nom de machine.";
|
|
isRadx = mkEnableOption "Identification du nom de machine.";
|
|
isRollo = mkEnableOption "Identification du nom de machine.";
|
|
isXray = mkEnableOption "Identification du nom de machine.";
|
|
};
|
|
};
|
|
|
|
###### 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.
|
|
{
|
|
r6d.config-generator.enable = true;
|
|
r6d.computers = {
|
|
isLatitude = host == "latitude.dubronetwork.fr";
|
|
isMonstre = host == "monstre.dubronetwork.fr";
|
|
isNeoNomade = host == "neo-nomade.dubronetwork.fr";
|
|
isNomade = host == "nomade.dubronetwork.fr";
|
|
isOcean = host == "ocean.prunetwork.fr";
|
|
isPedro = host == "pedro.dubronetwork.fr";
|
|
isPhenom = host == "phenom.dubronetwork.fr";
|
|
isRadx = host == "radx.prunetwork.fr";
|
|
isRollo = host == "rollo.dubronetwork.fr";
|
|
isXray = host == "xray.prunetwork.fr";
|
|
};
|
|
}
|
|
|
|
# Conditional stuff
|
|
|
|
## Définition des profils génériques
|
|
(mkIf pfl.isDesktop {
|
|
r6d.config-generator = {
|
|
awesome = true;
|
|
nix-serve-client = true;
|
|
};
|
|
})
|
|
(mkIf pfl.isHome {
|
|
r6d.profiles.isDesktop = true;
|
|
})
|
|
(mkIf (pfl.isServer && !comp.isMonstre) {
|
|
r6d.config-generator = {
|
|
#database_postgres = true;
|
|
dns_autorite = true;
|
|
#dns_resolveur = true;
|
|
# inutile d'exposer la conf complète du serveur par le store tant qu'il n'y a pas de protection complémentaire - utilisation SSH ?
|
|
#nix-serve-server = true;
|
|
|
|
#rabbitmq = true;
|
|
};
|
|
})
|
|
# /!\ PAS un serveur
|
|
(mkIf (!pfl.isServer || comp.isMonstre) {
|
|
r6d.config-generator = {
|
|
dns_resolveur = true;
|
|
};
|
|
})
|
|
(mkIf pfl.isWorkstation {
|
|
r6d.profiles.isDesktop = true;
|
|
|
|
r6d.config-generator = {
|
|
cartographie = true;
|
|
developpement = true;
|
|
docker = true;
|
|
|
|
edition-musique = true;
|
|
edition-photo = true;
|
|
edition-video = true;
|
|
};
|
|
})
|
|
|
|
## Profils liés à Dubronetwork
|
|
(mkIf pfl.isDubronetwork {
|
|
r6d.config-generator = {
|
|
auto-upgrade = true;
|
|
print = true;
|
|
};
|
|
})
|
|
(mkIf (pfl.isDubronetwork && pfl.isWorkstation) {
|
|
r6d.config-generator = {
|
|
conception-assistee = true;
|
|
virtualbox = true;
|
|
xmonad = true;
|
|
};
|
|
})
|
|
|
|
## Profils liés à Prunetwork
|
|
(mkIf pfl.isPrunetwork {
|
|
r6d.config-generator = {
|
|
auto-upgrade = true;
|
|
fail2ban = true;
|
|
swap = true;
|
|
};
|
|
})
|
|
|
|
|
|
## Affectation des profils aux machines
|
|
(mkIf comp.isOcean {
|
|
r6d.profiles = {
|
|
isPrunetwork = true;
|
|
isServer = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
docker = true;
|
|
radicale = true;
|
|
};
|
|
})
|
|
(mkIf comp.isRadx {
|
|
r6d.profiles = {
|
|
isHome = true;
|
|
isPrunetwork = true;
|
|
isWorkstation = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
hydra-builder = true;
|
|
hydra-core = true;
|
|
print = true;
|
|
virtualbox = true;
|
|
};
|
|
})
|
|
(mkIf comp.isXray {
|
|
r6d.profiles = {
|
|
isPrunetwork = true;
|
|
isServer = true;
|
|
};
|
|
})
|
|
|
|
(mkIf comp.isLatitude {
|
|
r6d.profiles = {
|
|
isDubronetwork = true;
|
|
isHome = true;
|
|
isWorkstation = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
laptop = true;
|
|
tincAddress = "192.168.12.2/24";
|
|
tincExtraConfig = "ConnectTo = phenom_dubronetwork_fr";
|
|
};
|
|
})
|
|
(mkIf comp.isMonstre {
|
|
r6d.profiles = {
|
|
isDubronetwork = true;
|
|
isServer = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
fail2ban = true;
|
|
nix-serve-client = true;
|
|
nixStoreProxyCache = true;
|
|
};
|
|
})
|
|
(mkIf comp.isNeoNomade{
|
|
r6d.profiles = {
|
|
isDubronetwork = true;
|
|
isHome = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
laptop = true;
|
|
};
|
|
})
|
|
(mkIf comp.isNomade{
|
|
r6d.profiles.isDubronetwork = true;
|
|
|
|
r6d.config-generator = {
|
|
laptop = true;
|
|
};
|
|
})
|
|
(mkIf comp.isPedro {
|
|
r6d.profiles = {
|
|
isDubronetwork = true;
|
|
isServer = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
fail2ban = true;
|
|
online-ipv6 = true;
|
|
};
|
|
})
|
|
(mkIf comp.isPhenom {
|
|
r6d.profiles = {
|
|
isDubronetwork = true;
|
|
isHome = true;
|
|
isWorkstation = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
nix-serve-server = true;
|
|
laptop = true;
|
|
edition-photo = true;
|
|
tincAddress = "192.168.12.1/24";
|
|
};
|
|
})
|
|
(mkIf comp.isRollo {
|
|
r6d.profiles = {
|
|
isDubronetwork = true;
|
|
isServer = true;
|
|
};
|
|
|
|
r6d.config-generator = {
|
|
dovecot = true;
|
|
fail2ban = true;
|
|
mailboxes = true;
|
|
murmur = true;
|
|
online-ipv6 = true;
|
|
znc = true;
|
|
};
|
|
})
|
|
];
|
|
}
|