déplacement de la configuration à la racine du dépôt (sauf rc.lua)

This commit is contained in:
Yves Dubromelle
2017-03-25 00:25:30 +01:00
parent c1d112a10a
commit 40426c1ad2
56 changed files with 53 additions and 68 deletions

20
services/docker.nix Normal file
View File

@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.docker {
# Paquets
environment.systemPackages = with pkgs; [
# Ecosystème Docker
docker
python27Packages.docker_compose
];
virtualisation.docker.enable = true;
}

View File

@@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.elasticsearch {
# Paquets
environment.systemPackages = with pkgs; [
];
# Services
## E : http://localhost:9200/_cat/indices?v
services.elasticsearch = {
enable = true;
port = 9200;
listenAddress = "127.0.0.1";
#listenAddress = "_site_";
};
# Réseau
# -> Aucun port n'est ouvert caril est recommandé de mettre un proxy HTTP devant
networking.firewall = {
allowedTCPPorts = [
];
allowedUDPPorts = [
];
};
}

21
services/haveged.nix Normal file
View File

@@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf true {
# Sécurité & Accès distant
# Services
## Augmentation de l'entropie du système par un générateur de nombres aléatoires
## cat /proc/sys/kernel/random/entropy_avail
services.haveged = {
enable = true;
refill_threshold = 2048;
};
}

16
services/hoogle.nix Normal file
View File

@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.developpement-haskell {
services.hoogle = {
enable = true;
# port 8080
};
}

45
services/hydra-build.nix Normal file
View File

@@ -0,0 +1,45 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
# TODO: ménage
mkIf cfg.hydra-builder {
# Paquets
environment.systemPackages = with pkgs; [
qemu
kvm
];
# Services
## Services de virtualisation utilisé pour les tests hydra
virtualisation.docker.enable = true;
virtualisation.libvirtd.enable = true;
virtualisation.libvirtd.enableKVM = true;
#virtualisation.virtualbox.guest.enable = true;
virtualisation.virtualbox.host.enable = true;
virtualisation.virtualbox.host.headless = true;
## Ménage automatique tous les jours
nix.gc.automatic = true;
# users.users."hydrabld" = {
# description = "Execution des jobs hydra";
# group = "nixbld";
# extraGroups = [
# "docker"
# "nixbld"
# "vboxusers"
# ];
# isNormalUser = true; # devrait être à false: TODO débugger la conf ssh & users pour que ça marche en user système
# openssh.authorizedKeys.keys = [
# "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGYpjcWJCf8dXpv2LmoIaNVbwZXEC50QUU6Az+lqeD89 hydra radx"
# ];
# };
}

93
services/hydra-core.nix Normal file
View File

@@ -0,0 +1,93 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
#### https://github.com/NixOS/hydra/issues/413
# Note that we use 'import <nixpkgs> {}' instead of 'pkgs'.
# If we use the latter we get an infinite recursion
# because we include hydra-src in the module imports below which in turn defines the 'pkgs' value.
#hydra-src = (import <nixpkgs> {}).fetchgit {
# url = "https://github.com/NixOS/hydra.git";
# rev = "de55303197d997c4fc5503b52b1321ae9528583d";
# sha256 = "0nimqsbpjxfwha6d5gp6a7jh50i83z1llmx30da4bscsic8z1xly";
#};
#hydra-src-pkg = lib.mkDefault ((import (hydra-src + /release.nix) {}).build.x86_64-linux);
# information pour l'état de hydra :
# hydra-queue-runner --status | json_pp
in
# TODO: passe de ménage
mkIf cfg.hydra-core {
# Paquets
environment.systemPackages = with pkgs; [
];
# Documentation HYDRA
## Installation
# 1. créer clef SSH :
# ssh-keygen -C "hydra@pedro.dubronetwork.fr" -N "" -f /etc/nixos/id_buildfarm
# 2. récupérer la clef publique du serveur ssh + l'ajouter dans les `knownHosts` :
# ssh-keyscan localhost
# 3. créer un utilisateur pour gérer hydra
# su - hydra
# hydra-create-user jpierre03 --password xxx --role 'admin'
# 4. relancer hydra
# 5. ajouter un vhost à nginx
# 6. relancer nginx
# 7. le service accessible à hydra.<nom de machine>
## Tutoriel
# * https://github.com/peti/hydra-tutorial
# Services
## Hydra
services.hydra = {
enable = true;
hydraURL = "http://hydra.${config.networking.hostName}";
notificationSender = "hydra@${config.networking.hostName}";
listenHost = "localhost";
minimumDiskFree = 50; # Go
smtpHost = "localhost";
#package = hydra-src-pkg ;
};
#systemd.services.hydra-evaluator = {
# path = [ pkgs.nettools config.services.hydra.package ];
#};
## Ménage
#nix.gc.automatic = true;
## Délégation des actions de compilation à la ferme de compilation
### Machines connues
programs.ssh.knownHosts = {
"hydra.prunetwork.fr".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHqja/yYsQeS5amZKPUG+EKSIkjEN6fYW54Fzvj1pFaP";
"monstre.dubronetwork.fr".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBTTrLhq1Cwm0rpnwEIxSLqVrJWZnt+/9dt+SKd8NiIc";
"pedro.dubronetwork.fr".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM7fjo2ysLqlfSo6BKnc6I6m1ayoPrbwEEyTKZmUzsOD";
"ocean.prunetwork.fr".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINCaRuTl8iCTUE4XInOpkSlwQj5Re4w4Iq+gNIlJe8pA";
"radx.prunetwork.fr".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGyoXdTEnxSgZTMfRfVH+bpOGZJtJpydAijcRGsZik7U";
"rollo.dubronetwork.fr".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID4lWgS/sVdcZvnAAN+lBSOcCL9ISdAUsjp1kh9lalNu";
};
### La liste des machines utilisées
nix = {
distributedBuilds = false;
buildMachines = [
# { hostName = "pedro.dubronetwork.fr"; maxJobs = 5; speedFactor = 10; sshKey = "/etc/nixos/id_buildfarm"; sshUser = "root"; system = "x86_64-linux"; }
];
extraOptions = "auto-optimise-store = true";
};
}

33
services/kibana.nix Normal file
View File

@@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.kibana {
# Paquets
environment.systemPackages = with pkgs; [
];
# Services
# K : http://localhost:8000
services.kibana = {
enable = true;
elasticsearch.url = "http://127.0.0.1:9200";
port = 8000;
};
# Réseau
# -> Aucun port n'est ouvert caril est recommandé de mettre un proxy HTTP devant
networking.firewall = {
allowedTCPPorts = [
];
allowedUDPPorts = [
];
};
}

17
services/locate.nix Normal file
View File

@@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.locate {
# Services
services.locate = {
enable = true;
interval = "hourly";
};
}

View File

@@ -0,0 +1,51 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
# TODO: ajouter option
# TODO: changer adresse mail
mkIf true {
# Paquets
environment.systemPackages = with pkgs; [
bc
mailutils
];
# Services
## Noeud de supervision munin = pas de stockage des données locales
services.munin-node = {
enable = true;
};
systemd.services.munin-node = {
path = with pkgs; [ munin lm_sensors ];
serviceConfig.TimeoutStartSec = "3min";
};
## Munin server -- generate /var/www/munin
services.munin-cron = {
enable = true;
hosts = ''
[${config.networking.hostName}]
address 127.0.0.1
'';
extraGlobalConfig = ''
contact.email.command ${pkgs.mutt}/bin/mutt -F /etc/nixos/base/public/services/munin-muttrc -s "Munin notification for ''${var:host}" jean-pierre@ocean.prunetwork.fr
'';
};
# Réseau
networking.firewall = {
allowedTCPPorts = [
#8000
];
allowedUDPPorts = [
];
};
}

View File

@@ -0,0 +1,198 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.smokeping {
# Paquets
environment.systemPackages = with pkgs; [
bind
];
# Paquets avec setuid root
security.wrappers = {
# outil de diagnostic réseau
fping.source = "${pkgs.fping}/bin/fping";
};
# Services
services.smokeping = {
enable = true;
probeConfig = ''
+ FPing
#binary = ${pkgs.fping}/bin/fping
binary = ${config.security.wrapperDir}/fping
+DNS
#binary = ${pkgs.bind}/bin/dig
binary = /run/current-system/sw/bin/dig
forks = 5
offset = 50%
step = 300
timeout = 15
'';
targetConfig = ''
probe = FPing
menu = Top
title = Suivi de la latence reseau
remark = Monitoring de la latence reseau. \
Here you will learn all about the latency of our network.
+ Local
probe = FPing
menu = Local
title = Local Network
++ LocalMachine
menu = Local Machine
title = This host
host = localhost
+ Grudu_Tinc
probe = FPing
title = Grudu_Tinc
menu = Grudu.net - Tinc
++ Hydra
menu = hydra.grudu.net
title = hydra.grudu.net
host = hydra.grudu.net
++ Monstre
menu = monstre.grudu.net
title = monstre.grudu.net
host = monstre.grudu.net
++ Rollo
menu = rollo.grudu.net
title = rollo.grudu.net
host = rollo.grudu.net
++ Ocean
menu = ocean.grudu.net
title = ocean.grudu.net
host = ocean.grudu.net
++ MultiHost
menu = Multihost
title = Ensemble de mesures de latence
host = /Grudu_Tinc/Monstre /Grudu_Tinc/Rollo /Grudu_Tinc/Ocean /Grudu_Tinc/Hydra
+ Grudu_DNS
title = Grudu_DNS
menu = Grudu.net - DNS
probe = DNS
pings = 5
++ Ocean
title = ocean
menu = serveur ocean
server = ocean.prunetwork.fr
+++ ocean
host = ocean.grudu.net
lookup = ocean.grudu.net
+++ rollo
host = rollo.grudu.net
lookup = rollo.grudu.net
++ Rollo
title = rollo
menu = serveur rollo
server = rollo.dubronetwork.fr
+++ ocean
host = ocean.grudu.net
lookup = ocean.grudu.net
+++ rollo
host = rollo.grudu.net
lookup = rollo.grudu.net
++ MultiHost
menu = Multihost
title = Ensemble de mesures DNS
host = /Grudu_DNS/Ocean/ocean /Grudu_DNS/Ocean/rollo /Grudu_DNS/Rollo/ocean /Grudu_DNS/Rollo/rollo
+ France
probe = FPing
title = France
menu = Operateur francais
++ Atos
menu = Atos
title = www.atos.fr
host = www.atos.fr
++ Axialys
menu = Axialys
title = www.axialys.fr
host = www.axialys.fr
++ Azurtel
menu = azurtel
title = www.azurtel.fr
host = www.azurtel.fr
++ Bouygues-Telecom
menu = Bouygues-Telecom
title = www.bouygues-telecom.fr
host = www.bouygues-telecom.fr
++ Colt
menu = Colt
title = www.colt.fr
host = www.colt.fr
++ Completel
menu = completel
title = www.completel.fr
host = www.completel.fr
++ Free
menu = Free
title = www.free.fr
host = www.free.fr
++ Kosmos
menu = Kosmos
title = www.kosmos.fr
host = www.kosmos.fr
++ Orange
menu = Orange
title = www.orange.fr
host = www.orange.fr
++ Renater
menu = Renater
title = www.renater.fr
host = www.renater.fr
++ SFR
menu = SFR
title = www.sfr.fr
host = www.sfr.fr
++ MultiHost
menu = Multihost
title = Ensemble de mesures de latence
host = /France/Atos /France/Axialys /France/Azurtel \
/France/Bouygues-Telecom \
/France/Completel \
/France/Free \
/France/Kosmos \
/France/Orange \
/France/Renater \
/France/SFR
# /France/Colt
'';
};
# Réseau
networking.firewall = {
allowedTCPPorts = [
#8081 # accès depuis localhost uniquement ou à travers un proxy nginx
];
allowedUDPPorts = [
];
};
}

3
services/munin-muttrc Normal file
View File

@@ -0,0 +1,3 @@
set copy=no
set realname = "Munin daemon"

27
services/print.nix Normal file
View File

@@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.print {
# Services
## Enable CUPS to print documents.
services.printing = {
enable = true;
drivers = [
pkgs.samsung-unified-linux-driver
];
# Suppression automatique des fichiers temporaires.
# Par défaut, cups conserve une copie de ce qui a été imprimé
# pas cool pour les mots de passe ou autre donnée sensible
extraConf = ''
PreserveJobHistory No
PreserveJobFiles No
'';
};
}

18
services/pulseaudio.nix Normal file
View File

@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.pulseaudio {
# Pulse Audio
hardware.pulseaudio = {
enable = true;
support32Bit = true;
daemon.config = { flat-volumes = "no"; };
};
}

27
services/scanner.nix Normal file
View File

@@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.scanner {
# Paquets
environment.systemPackages = with pkgs; [
simple-scan
];
# Services
hardware.sane.enable = true;
# Réseau
networking.firewall = {
allowedTCPPorts = [
];
allowedUDPPorts = [
];
};
}

31
services/ssh.nix Normal file
View File

@@ -0,0 +1,31 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf true {
# Services
## OpenSSH daemon
services.openssh = {
enable = true;
# https://wiki.mozilla.org/Security/Guidelines/OpenSSH#Modern_.28OpenSSH_6.7.2B.29
# http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html
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
# 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
'';
};
}

27
services/virtualbox.nix Normal file
View File

@@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.virtualbox {
# Paquets
environment.systemPackages = with pkgs; [
linuxPackages.virtualbox
linuxPackages.virtualboxGuestAdditions
];
# À décommenter pour activer le pack d'extension
#boot.kernelPackages = pkgs.linuxPackages // {
# virtualbox = pkgs.linuxPackages.virtualbox.override {
# enableExtensionPack = true;
# pulseSupport = true;
# };
#};
virtualisation.virtualbox.host.enable = true;
}

45
services/x11.nix Normal file
View File

@@ -0,0 +1,45 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf profiles.isDesktopEnvironment {
# Services
# Enable the X11 windowing system.
services.xserver = {
enable = true;
layout = "fr";
xkbOptions = "eurosign:e";
displayManager.lightdm.enable = true;
windowManager.awesome.enable = true;
inputClassSections = [''
Identifier "Marble Mouse"
MatchProduct "Logitech USB Trackball"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
# Physical button #s: A b D - - - - B C b = A & D simultaneously; - = no button
#Option "ButtonMapping" "1 8 3 4 5 6 7 2 2" # For right-hand placement
#Option "ButtonMapping" "3 8 1 4 5 6 7 2 2" # For left-hand placement
# EmulateWheel refers to emulating a mouse wheel using Marble Mouse trackball.
Option "EmulateWheel" "true"
Option "EmulateWheelButton" "8" # Factory default; use "9" for left-side placement.
# EmulateWheelInertia specifies how far (in pixels) the pointer must move to
# generate button press/release events in wheel emulation mode.
Option "EmulateWheelInertia" "10" # Factory default: 50
Option "ZAxisMapping" "4 5"
Option "XAxisMapping" "6 7" # Disable this for vertical-only scrolling.
# Emulate3Buttons refers to the act of pressing buttons A and D
# simultaneously to emulate a middle-click or wheel click.
Option "Emulate3Buttons" "true" # Factory default.
''];
};
}

32
services/xmonad/xmobarrc Normal file
View File

@@ -0,0 +1,32 @@
Config { font = "xft:Monospace-10:bold"
, additionalFonts = []
, border = NoBorder
, bgColor = "black"
, fgColor = "white"
, alpha = 255
, position = Top
--, textOffset = -1
--, iconOffset = -1
, lowerOnStart = False
, pickBroadest = False
, persistent = False
, hideOnStart = False
, iconRoot = "."
, allDesktops = True
, overrideRedirect = True
, commands = [ Run DynNetwork ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Battery ["-t", "Batt: <left>%, <watts>W -> <timeleft>"] 10
, Run Date "%F %H:%M:%S" "date" 10
--, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run StdinReader
, Run Brightness [] 10
, Run Volume "default" "Master" [] 10
]
, sepChar = "%"
, alignSep = "}{"
, template = " %StdinReader% }\
\{ %cpu% | %memory% | %dynnetwork% | %battery% | %bright% | %default:Master% | <fc=#ee9a00>%date%</fc>"
}

47
services/xmonad/xmonad.hs Normal file
View File

@@ -0,0 +1,47 @@
import Graphics.X11.ExtraTypes.XF86
import XMonad
import XMonad.Config.Desktop
import XMonad.Config.Azerty
import XMonad.Hooks.DynamicLog
import XMonad.Util.EZConfig
-- # Ligne principale
main = xmonad =<< xmobar myConfig
--main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig
-- # Réglages de xmonad
myConfig = azertyConfig
{ terminal = "sakura"
, modMask = mod4Mask
, borderWidth = 2
, workspaces = myWorkspaces
} `additionalKeys` myKeys `removeKeys` unusefulKeys
myWorkspaces = ["1:mail","2:chat","3:web","4","5","6","7","8", "9:system"]
myKeys = [ ((0, xF86XK_MonBrightnessUp), spawn "xbacklight +10") -- +brightness
, ((0, xF86XK_MonBrightnessDown), spawn "xbacklight -10") -- -brightness
, ((0, xF86XK_AudioRaiseVolume), spawn "amixer set Master 3%+") -- +volume
, ((0, xF86XK_AudioLowerVolume), spawn "amixer set Master 3%-") -- -volume
, ((0, xF86XK_AudioMute), spawn "amixer set Master toggle") -- mute volume
, ((0, xF86XK_AudioPlay), spawn "cmus-remote -u") -- cmus play/stop
, ((0, xF86XK_AudioPrev), spawn "cmus-remote -r") -- cmus next
, ((0, xF86XK_AudioNext), spawn "cmus-remote -n") -- cmus previous
]
unusefulKeys = []
-- # Réglages de xmobar
myBar = "xmobar"
-- Custom PP, configure it as you like. It determines what is being written to the bar.
myPP = xmobarPP
{ ppCurrent = xmobarColor "black" "yellow" . wrap " " " "
}
-- Key binding to toggle the gap for the bar.
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)

View File

@@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkMerge mkThenElse;
cfg = config.r6d.config-generator;
computers = config.r6d.computers;
profiles = config.r6d.profiles;
in
mkIf cfg.xmonad {
# Paquets
environment.systemPackages = with pkgs; [
dmenu
haskellPackages.xmobar
trayer
];
# Services
services.xserver.windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = haskellPackages: [
haskellPackages.xmobar
];
};
environment.variables = {
_JAVA_AWT_WM_NONREPARENTING = "1";
};
}