Compare commits

..

11 Commits

12 changed files with 157 additions and 52 deletions

View File

@@ -1,8 +1,12 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
# Automatic update & automatic clean
system.autoUpgrade.enable = config.r6d.config-generator.auto-upgrade;
nix.gc.automatic = config.r6d.config-generator.auto-upgrade;
system.autoUpgrade.enable = cfg.auto-upgrade;
nix.gc.automatic = cfg.auto-upgrade;
}

View File

@@ -1,9 +1,13 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
# Gestion de fail2ban
services = pkgs.lib.mkIf config.r6d.config-generator.fail2ban {
services = mkIf cfg.fail2ban {
fail2ban = {
enable = true;
jails = {

View File

@@ -1,6 +1,10 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
# Gestion spécifique pour PC portable
powerManagement.cpuFreqGovernor = pkgs.lib.mkIf config.r6d.config-generator.laptop "powersave";
powerManagement.cpuFreqGovernor = mkIf cfg.laptop "powersave";
}

View File

@@ -1,11 +1,15 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
imports = [
];
services.locate = {
enable = config.r6d.config-generator.locate;
enable = cfg.locate;
interval = "hourly";
};
}

View File

@@ -1,7 +1,9 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge;
profiles = config.r6d.profiles;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
in {
nix = mkIf config.r6d.config-generator.nix-serve-client {

View File

@@ -1,8 +1,12 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
# Cache http pour le store
services.nix-serve.enable = config.r6d.config-generator.nix-serve-server;
networking.firewall.allowedTCPPorts = pkgs.lib.mkIf config.r6d.config-generator.nix-serve-server [ 5000 ];
services.nix-serve.enable = cfg.nix-serve-server;
networking.firewall.allowedTCPPorts = mkIf cfg.nix-serve-server [ 5000 ];
}

View File

@@ -1,8 +1,12 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
# Enable CUPS to print documents.
services.printing = pkgs.lib.mkIf config.r6d.config-generator.print {
services.printing = mkIf cfg.print {
enable = true;
drivers = [
pkgs.samsung-unified-linux-driver

View File

@@ -1,10 +1,14 @@
{ config, pkgs, ... }:
{
with pkgs.lib;
let
cfg = config.r6d.config-generator;
in {
# Gestion du swap
# https://en.wikipedia.org/wiki/Swappiness
boot.kernel.sysctl = pkgs.lib.mkIf config.r6d.config-generator.swap {
boot.kernel.sysctl = mkIf cfg.swap {
# le swap est activé (!= 0)
# le swap est utilisé lorsque (100 - x) % de la mémoire est déja allouée
"vm.swappiness" = 10;

File diff suppressed because one or more lines are too long

View File

@@ -4,6 +4,7 @@
imports = [
./environment.nix
./localisation.nix
./monitoring.nix
./networking.nix
./services.nix

View File

@@ -43,7 +43,10 @@ in
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.";
database_postgres=mkEnableOption "Profil pour activer le SGBD PostgreSQL.";
docker = mkEnableOption "Profil pour l'utilisation de Docker.";
dns_autorite = mkEnableOption "Profil pour servir les fichiers de zone DNS.";
dns_resolveur = mkEnableOption "Profil pour activer un résolveur DNS local.";
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..";
@@ -51,6 +54,7 @@ in
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.";
rabbitmq = mkEnableOption "Profil pour activer le service de messagerie AMQP.";
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.";
@@ -91,24 +95,43 @@ in
## Définition des profils génériques
(mkIf pfl.isDesktop {
r6d.config-generator.awesome = true;
r6d.config-generator.nix-serve-client = true;
r6d.config-generator = {
awesome = true;
nix-serve-client = true;
};
})
(mkIf pfl.isHome {
r6d.profiles.isDesktop = true;
})
(mkIf pfl.isServer {
r6d.config-generator.nix-serve-server = true;
r6d.config-generator = {
#database_postgres = true;
dns_autorite = true;
#dns_resolveur = true;
nix-serve-server = true;
#rabbitmq = true;
};
})
(mkIf (!pfl.isServer) {
r6d.config-generator = {
dns_resolveur = true;
};
})
(mkIf pfl.isWorkstation {
r6d.profiles.isDesktop = true;
r6d.config-generator.docker = true;
r6d.config-generator = {
docker = true;
};
})
## Profils liés à Dubronetwork
(mkIf pfl.isDubronetwork {
r6d.config-generator.auto-upgrade = true;
r6d.config-generator.nix-serve-client = true;
r6d.config-generator.print = true;
r6d.config-generator = {
auto-upgrade = true;
nix-serve-client = true;
print = true;
};
})
(mkIf (pfl.isDubronetwork && pfl.isHome) {
r6d.config-generator.jeux = true;
@@ -117,54 +140,72 @@ in
r6d.config-generator.nix-serve-server = true;
})
(mkIf (pfl.isDubronetwork && pfl.isWorkstation) {
r6d.config-generator.virtualbox = true;
r6d.config-generator = {
virtualbox = true;
xmonad = true;
};
})
## Profils liés à Prunetwork
(mkIf pfl.isPrunetwork {
r6d.config-generator.auto-upgrade = true;
r6d.config-generator.fail2ban = true;
r6d.config-generator.swap = true;
r6d.config-generator = {
auto-upgrade = true;
fail2ban = true;
swap = true;
};
})
## Affectation des profils aux machines
(mkIf comp.isOcean {
r6d.profiles.isPrunetwork = true;
r6d.profiles.isServer = true;
r6d.profiles = {
isPrunetwork = true;
isServer = true;
};
})
(mkIf comp.isRadx {
r6d.profiles.isHome = true;
r6d.profiles.isPrunetwork = true;
r6d.profiles.isServer = true;
r6d.profiles.isWorkstation = true;
r6d.profiles = {
isHome = true;
isPrunetwork = true;
isServer = true;
isWorkstation = true;
};
r6d.config-generator = {
virtualbox = true;
};
})
(mkIf comp.isXray {
r6d.profiles.isPrunetwork = true;
r6d.profiles.isServer = true;
r6d.profiles = {
isPrunetwork = true;
isServer = true;
};
})
(mkIf comp.isLatitude {
r6d.profiles.isDubronetwork = true;
r6d.profiles.isHome = true;
r6d.profiles.isWorkstation = true;
r6d.profiles = {
isDubronetwork = true;
isHome = true;
isWorkstation = true;
};
r6d.config-generator = {
laptop = true;
xmonad = true;
};
})
(mkIf comp.isMonstre {
r6d.profiles.isDubronetwork = true;
r6d.profiles.isServer = true;
r6d.profiles = {
isDubronetwork = true;
isServer = true;
};
r6d.config-generator.fail2ban = true;
})
(mkIf comp.isNeoNomade{
r6d.profiles.isDubronetwork = true;
r6d.profiles.isHome = true;
r6d.profiles = {
isDubronetwork = true;
isHome = true;
};
r6d.config-generator = {
laptop = true;
@@ -178,12 +219,15 @@ in
};
})
(mkIf comp.isPhenom {
r6d.profiles.isDubronetwork = true;
r6d.profiles.isHome = true;
r6d.profiles.isWorkstation = true;
r6d.profiles = {
isDubronetwork = true;
isHome = true;
isWorkstation = true;
};
r6d.config-generator.nix-serve-server = true;
r6d.config-generator.xmonad = true;
r6d.config-generator = {
nix-serve-server = true;
};
})
];
}

27
monitoring.nix Normal file
View File

@@ -0,0 +1,27 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
## Munin server -- generate /var/www/munin
services.munin-cron = {
enable = true;
hosts = ''
[${config.networking.hostName}]
address localhost
'';
extraGlobalConfig = ''
contact.email.command mail -s "Munin notification for ''${var:host}" hostmaster@prunetwork.fr
'';
};
networking.firewall.allowedTCPPorts = [
# TODO configurer les bon ports lors de l'ouverture du service
];
## Documentation
# * https://nixos.org/wiki/Create_and_debug_nix_packages
# * http://chriswarbo.net/essays/nixos/developing_on_nixos.html
}