Compare commits
25 Commits
2016-07-13
...
2016-07-11
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cce1410a0 | |||
| 9499034120 | |||
| 2c715f9e14 | |||
| cd18fb2792 | |||
| 522131a517 | |||
| cfc55fa479 | |||
| 81ad043adb | |||
| a475a88ac4 | |||
| 30c9bd1b71 | |||
| b95c4509aa | |||
| e3d982a1fd | |||
| 021f6499f9 | |||
| 1416a12d22 | |||
| c9d1f4e67c | |||
| 2bb9511c1f | |||
| b4a72c5510 | |||
| 253403de89 | |||
| 2fa21f7f4d | |||
| 0bbddfbfa0 | |||
| 85ee98585b | |||
| 61d0c565ea | |||
| 0a8c503032 | |||
| 3d1feebee0 | |||
| d03f8cbfc2 | |||
| b277551d6a |
@@ -2,6 +2,7 @@
|
||||
|
||||
{
|
||||
# Automatic update & automatic clean
|
||||
system.autoUpgrade.enable = true;
|
||||
nix.gc.automatic = true;
|
||||
|
||||
system.autoUpgrade.enable = config.r6d.config-generator.auto-upgrade;
|
||||
nix.gc.automatic = config.r6d.config-generator.auto-upgrade;
|
||||
}
|
||||
|
||||
33
activation-manuelle/fail2ban.nix
Normal file
33
activation-manuelle/fail2ban.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Gestion de fail2ban
|
||||
|
||||
services = pkgs.lib.mkIf config.r6d.config-generator.fail2ban {
|
||||
fail2ban = {
|
||||
enable = true;
|
||||
jails = {
|
||||
DEFAULT = ''
|
||||
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
|
||||
ignoreip = 127.0.0.1/8 pedro.dubronetwork.fr cube.dubronetwork.fr voyage.prunetwork.fr xray.prunetwork.fr 192.168.0.0/16 172.16.0.0/16
|
||||
|
||||
# 1 jour
|
||||
# bantime = 86400
|
||||
# 5 jours
|
||||
bantime = 432000
|
||||
maxretry = 3
|
||||
|
||||
#
|
||||
# Destination email address used solely for the interpolations in
|
||||
# jail.{conf,local} configuration files.
|
||||
destemail = admins@dubronetwork.fr
|
||||
'';
|
||||
ssh-route = ''
|
||||
filter = sshd
|
||||
action = route[blocktype=blackhole]
|
||||
maxretry = 3
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
imports = [
|
||||
];
|
||||
|
||||
services.locate= {
|
||||
enable = true;
|
||||
services.locate = {
|
||||
enable = config.r6d.config-generator.locate;
|
||||
interval = "hourly";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
{ config, pkgs, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib) mkIf mkMerge;
|
||||
profiles = config.r6d.profiles;
|
||||
computers = config.r6d.computers;
|
||||
in {
|
||||
nix = mkIf config.r6d.config-generator.nix-serve-client {
|
||||
# Cache http pour le store
|
||||
requireSignedBinaryCaches = false;
|
||||
binaryCaches = [
|
||||
("https://cache.nixos.org/")
|
||||
(mkIf (profiles.isDubronetwork && (! computers.isMonstre)) "http://192.168.10.169:5000")
|
||||
(mkIf profiles.isDubronetwork "http://192.168.10.252:5000")
|
||||
|
||||
{
|
||||
# Cache http pour le store
|
||||
nix.requireSignedBinaryCaches = false;
|
||||
nix.binaryCaches = [ "http://192.168.10.169:5000" ];
|
||||
(mkIf profiles.isPrunetwork "http://192.168.1.20:5000")
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
8
activation-manuelle/nix-serve-server.nix
Normal file
8
activation-manuelle/nix-serve-server.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# 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 ];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Cache http pour le store
|
||||
services.nix-serve.enable = true;
|
||||
networking.firewall.allowedTCPPorts = [5000];
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
|
||||
# Gestion du swap
|
||||
|
||||
# https://en.wikipedia.org/wiki/Swappiness
|
||||
boot.kernel.sysctl = {
|
||||
boot.kernel.sysctl = pkgs.lib.mkIf config.r6d.config-generator.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;
|
||||
|
||||
6
base.nix
6
base.nix
@@ -2,12 +2,12 @@
|
||||
|
||||
{
|
||||
imports = [
|
||||
#./activation-manuelle/auto-upgrade.nix
|
||||
#./activation-manuelle/locate.nix
|
||||
#./activation-manuelle/swap.nix
|
||||
./environment.nix
|
||||
./localisation.nix
|
||||
./networking.nix
|
||||
./services.nix
|
||||
|
||||
# inclusion conditionnelle
|
||||
./config-generator.nix
|
||||
];
|
||||
}
|
||||
|
||||
157
config-generator.nix
Normal file
157
config-generator.nix
Normal file
@@ -0,0 +1,157 @@
|
||||
{ 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/locate.nix
|
||||
./activation-manuelle/fail2ban.nix
|
||||
./activation-manuelle/nix-serve-client.nix
|
||||
./activation-manuelle/nix-serve-server.nix
|
||||
./activation-manuelle/swap.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.";
|
||||
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 serveur de cache nix.";
|
||||
nix-serve-server= mkEnableOption "Profil pour que la machine soit un serveur de cache nix.";
|
||||
swap = mkEnableOption "Profil pour que le swap soit activé.";
|
||||
virtualbox = mkEnableOption "Profil pour l'utilisation de VirtualBox.";
|
||||
};
|
||||
#* 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.";
|
||||
isPhenom = mkEnableOption "Identification du nom de machine.";
|
||||
isRadx = 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";
|
||||
isPhenom = host == "phenom.dubronetwork.fr";
|
||||
isRadx = host == "radx.prunetwork.fr";
|
||||
};
|
||||
}
|
||||
|
||||
# Conditional stuff
|
||||
|
||||
## Définition des profils génériques
|
||||
(mkIf pfl.isDesktop {
|
||||
})
|
||||
(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;
|
||||
})
|
||||
(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.nix-serve-server = true;
|
||||
r6d.config-generator.virtualbox = true;
|
||||
})
|
||||
(mkIf pfl.isPrunetwork {
|
||||
r6d.config-generator.auto-upgrade = true;
|
||||
r6d.config-generator.fail2ban = true;
|
||||
r6d.config-generator.nix-serve-client = true;
|
||||
r6d.config-generator.swap = true;
|
||||
})
|
||||
|
||||
|
||||
## Affectation des profils aux machines
|
||||
(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.isLatitude {
|
||||
r6d.profiles.isDubronetwork = true;
|
||||
r6d.profiles.isHome = true;
|
||||
r6d.profiles.isWorkstation = true;
|
||||
|
||||
r6d.config-generator = {
|
||||
laptop = 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.isPhenom {
|
||||
r6d.profiles.isDubronetwork = true;
|
||||
r6d.profiles.isHome = true;
|
||||
r6d.profiles.isWorkstation = true;
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -14,28 +14,28 @@
|
||||
# $ nix-env -qaP | grep wget
|
||||
environment = {
|
||||
systemPackages = with pkgs; [
|
||||
bind # utilisé pour les utilitaires comme dig
|
||||
byobu
|
||||
exfat # Pour monter les FAT avec Fuse
|
||||
git gitAndTools.gitSVN gitAndTools.tig
|
||||
gnumake
|
||||
gnupg
|
||||
bind # utilisé pour les utilitaires comme dig
|
||||
byobu # permet de se déconnecter d'un terminal sans l'aréter
|
||||
exfat # Pour monter les FAT avec Fuse
|
||||
git gitAndTools.gitSVN gitAndTools.tig # outil de gestion de version
|
||||
gnumake # pour décrire les recettes de compilation
|
||||
gnupg # GPG
|
||||
gpm # prise en charge de la souris en console
|
||||
htop
|
||||
ncdu
|
||||
nmap
|
||||
mtr
|
||||
p7zip
|
||||
parted
|
||||
htop # monitoring
|
||||
ncdu # outil pour voir l'espace utilisé
|
||||
nmap # outil de scan de port réseau
|
||||
mtr # outil de diagnostic réseau
|
||||
p7zip # compression de fichier
|
||||
parted # partitionnement de disque
|
||||
pciutils
|
||||
python34Packages.glances
|
||||
pwgen
|
||||
tmux
|
||||
tree
|
||||
python34Packages.glances # monitoring
|
||||
pwgen # générateur de mot de passe
|
||||
tmux # nécessaire pour byobu
|
||||
tree # affiche une arborescence de fichiers et dossiers
|
||||
usbutils
|
||||
(import ./vim.nix)
|
||||
wget
|
||||
which
|
||||
wget # client HTTP console
|
||||
which # pour connaitre le chemin d'un exécutable
|
||||
];
|
||||
shellAliases = {
|
||||
byobu = "byobu-tmux";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# http://www.git-attitude.fr/2014/09/15/30-options-git-qui-gagnent-a-etre-connues/
|
||||
[color]
|
||||
diff = auto
|
||||
branch = auto
|
||||
@@ -10,6 +11,7 @@
|
||||
ci = commit
|
||||
co = checkout
|
||||
ff = pull --ff-only
|
||||
oops = commit --amend --no-edit
|
||||
# Show files ignored by git
|
||||
ignored = ls-files -o -i --exclude-standard
|
||||
ls = ls-files
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
boot.kernel.sysctl = {
|
||||
"net.ipv6.conf.all.temp_prefered_lft" = 1800; # 30 min
|
||||
"net.ipv6.conf.all.temp_valid_lft" = 3600; # 1 heure
|
||||
"net.ipv6.conf.all.temp_valid_lft" = 43200; # 12 heures
|
||||
"net.ipv6.conf.all.use_tempaddr" = 2; # activé
|
||||
|
||||
"net.ipv6.conf.default.temp_prefered_lft" = 3600; # 1 heure
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
# Enable CUPS to print documents.
|
||||
services.printing = {
|
||||
enable = true;
|
||||
drivers = [ pkgs.samsung-unified-linux-driver ];
|
||||
drivers = [
|
||||
pkgs.samsung-unified-linux-driver
|
||||
];
|
||||
};
|
||||
|
||||
# Monitoring
|
||||
|
||||
Reference in New Issue
Block a user