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.
190 lines
6.7 KiB
Nix
190 lines
6.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
# exemple utilisé pour commencer bird.nix
|
|
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
|
|
|
|
{
|
|
imports = [
|
|
./activation-manuelle/auto-upgrade.nix
|
|
./activation-manuelle/laptop.nix
|
|
./activation-manuelle/locate.nix
|
|
./activation-manuelle/fail2ban.nix
|
|
./activation-manuelle/nix-serve-client.nix
|
|
./activation-manuelle/nix-serve-server.nix
|
|
./activation-manuelle/print.nix
|
|
./activation-manuelle/swap.nix
|
|
./activation-manuelle/users.nix
|
|
];
|
|
|
|
###### 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.";
|
|
docker = mkEnableOption "Profil pour l'utilisation de Docker.";
|
|
fail2ban = mkEnableOption "Profil pour activer Fail2ban.";
|
|
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.";
|
|
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.";
|
|
print = mkEnableOption "Profil pour activer cups & pouvoir imprimer.";
|
|
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.";
|
|
};
|
|
#* 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.";
|
|
isPhenom = mkEnableOption "Identification du nom de machine.";
|
|
isRadx = 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";
|
|
isPhenom = host == "phenom.dubronetwork.fr";
|
|
isRadx = host == "radx.prunetwork.fr";
|
|
isXray = host == "xray.prunetwork.fr";
|
|
};
|
|
}
|
|
|
|
# Conditional stuff
|
|
|
|
## Définition des profils génériques
|
|
(mkIf pfl.isDesktop {
|
|
r6d.config-generator.awesome = true;
|
|
r6d.config-generator.nix-serve-client = true;
|
|
})
|
|
(mkIf pfl.isHome {
|
|
r6d.profiles.isDesktop = true;
|
|
})
|
|
(mkIf pfl.isServer {
|
|
r6d.config-generator.nix-serve-server = true;
|
|
})
|
|
(mkIf pfl.isWorkstation {
|
|
r6d.profiles.isDesktop = true;
|
|
|
|
r6d.config-generator.docker = true;
|
|
})
|
|
(mkIf pfl.isDubronetwork {
|
|
r6d.config-generator.auto-upgrade = true;
|
|
r6d.config-generator.nix-serve-client = true;
|
|
r6d.config-generator.print = true;
|
|
})
|
|
(mkIf (pfl.isDubronetwork && pfl.isHome) {
|
|
r6d.config-generator.jeux = true;
|
|
})
|
|
(mkIf (pfl.isDubronetwork && pfl.isServer) {
|
|
r6d.config-generator.nix-serve-server = true;
|
|
})
|
|
(mkIf (pfl.isDubronetwork && pfl.isWorkstation) {
|
|
r6d.config-generator.virtualbox = true;
|
|
})
|
|
(mkIf pfl.isPrunetwork {
|
|
r6d.config-generator.auto-upgrade = true;
|
|
r6d.config-generator.fail2ban = true;
|
|
r6d.config-generator.swap = true;
|
|
})
|
|
|
|
|
|
## Affectation des profils aux machines
|
|
(mkIf comp.isOcean {
|
|
r6d.profiles.isPrunetwork = true;
|
|
r6d.profiles.isServer = true;
|
|
})
|
|
(mkIf comp.isRadx {
|
|
r6d.profiles.isHome = true;
|
|
r6d.profiles.isPrunetwork = true;
|
|
r6d.profiles.isServer = true;
|
|
r6d.profiles.isWorkstation = true;
|
|
|
|
r6d.config-generator = {
|
|
virtualbox = true;
|
|
};
|
|
})
|
|
(mkIf comp.isXray {
|
|
r6d.profiles.isPrunetwork = true;
|
|
r6d.profiles.isServer = true;
|
|
})
|
|
|
|
(mkIf comp.isLatitude {
|
|
r6d.profiles.isDubronetwork = true;
|
|
r6d.profiles.isHome = true;
|
|
r6d.profiles.isWorkstation = true;
|
|
|
|
r6d.config-generator = {
|
|
laptop = true;
|
|
xmonad = true;
|
|
};
|
|
})
|
|
(mkIf comp.isMonstre {
|
|
r6d.profiles.isDubronetwork = true;
|
|
r6d.profiles.isServer = true;
|
|
|
|
r6d.config-generator.fail2ban = true;
|
|
})
|
|
(mkIf comp.isNeoNomade{
|
|
r6d.profiles.isDubronetwork = true;
|
|
r6d.profiles.isHome = true;
|
|
|
|
r6d.config-generator = {
|
|
laptop = true;
|
|
};
|
|
})
|
|
(mkIf comp.isNomade{
|
|
r6d.profiles.isDubronetwork = true;
|
|
|
|
r6d.config-generator = {
|
|
laptop = true;
|
|
};
|
|
})
|
|
(mkIf comp.isPhenom {
|
|
r6d.profiles.isDubronetwork = true;
|
|
r6d.profiles.isHome = true;
|
|
r6d.profiles.isWorkstation = true;
|
|
|
|
r6d.config-generator.nix-serve-server = true;
|
|
r6d.config-generator.xmonad = true;
|
|
})
|
|
];
|
|
}
|