Compare commits
28 Commits
2016-07-20
...
2016-07-25
| Author | SHA1 | Date | |
|---|---|---|---|
| 35c49c2fcd | |||
| 95c7fc7a14 | |||
|
|
908be0c5e8 | ||
|
|
12fe6f2b94 | ||
| dbd58cabc0 | |||
| 5fa77bda2e | |||
| 363b2f56e4 | |||
| 5380bb76b0 | |||
| ef3778dd54 | |||
| b50aa1ad0e | |||
| 326da0f7e8 | |||
| c5b7c16946 | |||
| af15068c29 | |||
| d503b8f0f4 | |||
| 7bd6eb37e3 | |||
| 592e5664be | |||
| 20e8e8beaa | |||
| 66252cb498 | |||
| 906ae9b7d1 | |||
| 2195033ee5 | |||
| becd37ba28 | |||
| f55ae85a66 | |||
| cd458f24a7 | |||
| 86c46a97de | |||
| b2619291a7 | |||
| 5350372774 | |||
|
|
3d1a7d2161 | ||
|
|
111f33ff3d |
4
Makefile
4
Makefile
@@ -23,7 +23,7 @@ push: submodules-push
|
||||
git push --tags
|
||||
|
||||
rebuild-switch:
|
||||
nixos-rebuild switch
|
||||
nixos-rebuild switch --fallback
|
||||
|
||||
store-repair:
|
||||
nix-store --verify --check-contents --repair
|
||||
@@ -44,5 +44,5 @@ tag: submodules-tag
|
||||
git tag -f "$$(date +%F)-$$(hostname -s)"
|
||||
|
||||
upgrade:
|
||||
nixos-rebuild switch --upgrade
|
||||
nixos-rebuild switch --upgrade --fallback
|
||||
|
||||
|
||||
5
README
Normal file
5
README
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
# Lien pour install sur machine distante
|
||||
|
||||
* https://nixos.org/wiki/How_to_install_NixOS_from_Linux#Installing_through_a_chroot
|
||||
* https://github.com/NixOS/nixpkgs/issues/13305
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
@@ -12,7 +14,11 @@ in {
|
||||
(mkIf (profiles.isDubronetwork && (! computers.isMonstre)) "http://192.168.10.169:5000")
|
||||
(mkIf profiles.isDubronetwork "http://192.168.10.252:5000")
|
||||
|
||||
(mkIf profiles.isPrunetwork "http://192.168.1.20:5000")
|
||||
(mkIf (profiles.isPrunetwork && !profiles.isServer) "http://192.168.1.20:5000")
|
||||
];
|
||||
};
|
||||
}
|
||||
extraOptions = ''
|
||||
connect-timeout = 5
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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 ];
|
||||
}
|
||||
|
||||
15
activation-manuelle/print.nix
Normal file
15
activation-manuelle/print.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
let
|
||||
cfg = config.r6d.config-generator;
|
||||
in {
|
||||
# Enable CUPS to print documents.
|
||||
services.printing = mkIf cfg.print {
|
||||
enable = true;
|
||||
drivers = [
|
||||
pkgs.samsung-unified-linux-driver
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
29
activation-manuelle/users.nix
Normal file
29
activation-manuelle/users.nix
Normal file
File diff suppressed because one or more lines are too long
1
base.nix
1
base.nix
@@ -4,6 +4,7 @@
|
||||
imports = [
|
||||
./environment.nix
|
||||
./localisation.nix
|
||||
./monitoring.nix
|
||||
./networking.nix
|
||||
./services.nix
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ in
|
||||
./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
|
||||
@@ -41,15 +43,21 @@ 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..";
|
||||
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-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.";
|
||||
};
|
||||
#* Utilisé pour avoir des raccourcis de machine
|
||||
r6d.computers = {
|
||||
@@ -57,6 +65,7 @@ in
|
||||
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.";
|
||||
@@ -75,6 +84,7 @@ in
|
||||
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";
|
||||
@@ -85,22 +95,46 @@ in
|
||||
|
||||
## Définition des profils génériques
|
||||
(mkIf pfl.isDesktop {
|
||||
r6d.config-generator.awesome = 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;
|
||||
# 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) {
|
||||
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 = {
|
||||
auto-upgrade = true;
|
||||
nix-serve-client = true;
|
||||
print = true;
|
||||
};
|
||||
})
|
||||
(mkIf (pfl.isDubronetwork && pfl.isHome) {
|
||||
r6d.config-generator.jeux = true;
|
||||
@@ -109,50 +143,73 @@ 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.nix-serve-client = 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;
|
||||
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 = {
|
||||
nix-serve-server = true;
|
||||
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;
|
||||
};
|
||||
})
|
||||
(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;
|
||||
@@ -166,11 +223,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 = {
|
||||
nix-serve-server = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
@@ -17,19 +17,23 @@
|
||||
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
|
||||
git gitAndTools.gitSVN gitAndTools.tig gti # 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 # monitoring
|
||||
#libressl # librairie pour faire du TLS et les algorithmes de crypto par OpenBSD
|
||||
ncdu # outil pour voir l'espace utilisé
|
||||
nmap # outil de scan de port réseau
|
||||
mtr # outil de diagnostic réseau
|
||||
par2cmdline # outil de récupération de fichiers corrompus - .par2
|
||||
p7zip # compression de fichier
|
||||
parted # partitionnement de disque
|
||||
pciutils
|
||||
python # python -- python -m SimpleHTTPServer 8000
|
||||
python34Packages.glances # monitoring
|
||||
pwgen # générateur de mot de passe
|
||||
rtorrent # outil de téléchargement de torrent & magnet
|
||||
tmux # nécessaire pour byobu
|
||||
tree # affiche une arborescence de fichiers et dossiers
|
||||
usbutils
|
||||
@@ -53,4 +57,16 @@
|
||||
promptInit = builtins.readFile ./bash-prompt.sh;
|
||||
interactiveShellInit = builtins.readFile ./bash-interactive-init.sh;
|
||||
};
|
||||
|
||||
# https://wiki.mozilla.org/Security/Guidelines/OpenSSH#Modern
|
||||
programs.ssh.extraConfig = ''
|
||||
# Ensure KnownHosts are unreadable if leaked - it is otherwise easier to know which hosts your keys have access to.
|
||||
HashKnownHosts yes
|
||||
# Host keys the client accepts - order here is honored by OpenSSH
|
||||
HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ssh-rsa,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256
|
||||
|
||||
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp256,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256
|
||||
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
|
||||
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
|
||||
'';
|
||||
}
|
||||
|
||||
27
monitoring.nix
Normal file
27
monitoring.nix
Normal 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
|
||||
}
|
||||
19
services.nix
19
services.nix
@@ -13,14 +13,19 @@
|
||||
## OpenSSH daemon
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
};
|
||||
# https://wiki.mozilla.org/Security/Guidelines/OpenSSH#Modern_.28OpenSSH_6.7.2B.29
|
||||
extraConfig = ''
|
||||
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
|
||||
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
|
||||
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
|
||||
|
||||
# Enable CUPS to print documents.
|
||||
services.printing = {
|
||||
enable = true;
|
||||
drivers = [
|
||||
pkgs.samsung-unified-linux-driver
|
||||
];
|
||||
# LogLevel VERBOSE logs user's key fingerprint on login. Needed to have a clear audit track of which key was using to log in.
|
||||
LogLevel VERBOSE
|
||||
|
||||
# Use kernel sandbox mechanisms where possible in unprivilegied processes
|
||||
# Systrace on OpenBSD, Seccomp on Linux, seatbelt on MacOSX/Darwin, rlimit elsewhere.
|
||||
UsePrivilegeSeparation sandbox
|
||||
'';
|
||||
};
|
||||
|
||||
# Monitoring
|
||||
|
||||
Reference in New Issue
Block a user