mirror of https://gitlab.crans.org/nounous/nixos
Module pour les infos.nix
parent
c8dac2d45d
commit
1c4c776a1f
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
# XXX: Transformer en module NixOs
|
||||||
|
vlans = import ./vlans.nix;
|
||||||
|
switchs = import ./switchs.nix;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
"arceus"
|
||||||
|
"carapuce"
|
||||||
|
"salameche"
|
||||||
|
"horst"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
{
|
||||||
|
|
||||||
|
srv = {
|
||||||
|
id = 2;
|
||||||
|
description = "Réseau public";
|
||||||
|
interface = "ens19";
|
||||||
|
ipv4 = {
|
||||||
|
address = "185.230.79.0";
|
||||||
|
prefixLength = 26;
|
||||||
|
routes = [
|
||||||
|
{
|
||||||
|
address = "0.0.0.0";
|
||||||
|
via = "185.230.79.62";
|
||||||
|
prefixLength = 0;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
ipv6 = {
|
||||||
|
address = "2a0c:700:10::";
|
||||||
|
routes = [
|
||||||
|
{
|
||||||
|
address = "::";
|
||||||
|
via = "2a0c:700:2::ff:fe00:9902";
|
||||||
|
prefixLength = 0;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
srv-nat = {
|
||||||
|
id = 3;
|
||||||
|
description = "Réseau derrière un NAT";
|
||||||
|
interface = "ens19";
|
||||||
|
ipv4.routes = [
|
||||||
|
{
|
||||||
|
address = "0.0.0.0";
|
||||||
|
via = "172.16.3.99";
|
||||||
|
prefixLength = 0;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
ipv6 = {
|
||||||
|
address = "2a0c:700:3::";
|
||||||
|
routes = [
|
||||||
|
{
|
||||||
|
address = "::";
|
||||||
|
via = "2a0c:700:3::ff:fe00:9903";
|
||||||
|
prefixLength = 0;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
san = {
|
||||||
|
id = 4;
|
||||||
|
description = "Accès aux baies de stockages";
|
||||||
|
interface = "ens19";
|
||||||
|
};
|
||||||
|
|
||||||
|
ceph = {
|
||||||
|
id = 6;
|
||||||
|
description = "Réseau interne à ceph";
|
||||||
|
interface = "ens20";
|
||||||
|
};
|
||||||
|
|
||||||
|
adm = {
|
||||||
|
id = 10;
|
||||||
|
description = "Réseau interne";
|
||||||
|
interface = "ens18";
|
||||||
|
};
|
||||||
|
|
||||||
|
adh = {
|
||||||
|
id = 12;
|
||||||
|
description = "Réseau adhérent";
|
||||||
|
ipv4 = {
|
||||||
|
address = "185.230.78.0";
|
||||||
|
routes = [
|
||||||
|
{
|
||||||
|
address = "0.0.0.0";
|
||||||
|
via = "185.230.78.12";
|
||||||
|
prefixLength = 0;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
ipv6 = {
|
||||||
|
address = "2a0c:700:12::";
|
||||||
|
prefixLength = 48;
|
||||||
|
routes = [
|
||||||
|
{
|
||||||
|
address = "::";
|
||||||
|
via = "2a0c:700:12::ff:fe00:9912";
|
||||||
|
prefixLength = 0;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
adh-adm = {
|
||||||
|
id = 13;
|
||||||
|
description = "Réseau d’administration du réseau adhérent";
|
||||||
|
};
|
||||||
|
|
||||||
|
ens = {
|
||||||
|
id = 2751;
|
||||||
|
description = "Interconnexion avec l’ENS.";
|
||||||
|
ipv4 = {
|
||||||
|
address = "138.231.136.0";
|
||||||
|
prefixLength = 29;
|
||||||
|
};
|
||||||
|
ipv6 = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
ens-clubs = {
|
||||||
|
id = 2754;
|
||||||
|
description = "Réseau clubs interconnecté avec l’ENS";
|
||||||
|
ipv6 = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
ens-lp = {
|
||||||
|
id = 2756;
|
||||||
|
description = "Réseau imprimante interconnecté avec l’ENS";
|
||||||
|
ipv6 = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./networking.nix
|
./networking.nix
|
||||||
./nginx.nix
|
./nginx.nix
|
||||||
|
./restic.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostId = "bbdd1133";
|
networking.hostId = "bbdd1133";
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@
|
||||||
name = "thot";
|
name = "thot";
|
||||||
description = "Serveur de backup sous nixos utilisant Restic";
|
description = "Serveur de backup sous nixos utilisant Restic";
|
||||||
id = 14;
|
id = 14;
|
||||||
|
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
networking.adm.enable = false;
|
networking = {
|
||||||
resticClient.enable = false;
|
adm.enable = false;
|
||||||
|
|
||||||
services = {
|
|
||||||
resticServer = {
|
|
||||||
enable = true;
|
|
||||||
port = 4242;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
resticClient.enable = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
config.crans.services = {
|
||||||
|
resticServer = {
|
||||||
|
enable = true;
|
||||||
|
port = 4242;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -9,5 +9,9 @@
|
||||||
srv-nat.enable = true;
|
srv-nat.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.enable = false;
|
resticClient.enable = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,14 @@
|
||||||
adm.enable = true;
|
adm.enable = true;
|
||||||
srv = {
|
srv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
ipv4 = "185.230.79.19";
|
ipv4.address = "185.230.79.19";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "06:07";
|
resticClient.when = "06:07";
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ in
|
||||||
|
|
||||||
rtc = {
|
rtc = {
|
||||||
use_external_ip = false;
|
use_external_ip = false;
|
||||||
node_ip = config.crans.networking.srv.ipv4;
|
node_ip = config.crans.info.networking.srv.ipv4.address;
|
||||||
tcp_port = 8101;
|
tcp_port = 8101;
|
||||||
port_range_start = 50000;
|
port_range_start = 50000;
|
||||||
port_range_end = 52000;
|
port_range_end = 52000;
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,17 @@
|
||||||
adm.enable = true;
|
adm.enable = true;
|
||||||
srv = {
|
srv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
ipv4 = "185.230.79.15";
|
ipv4.address = "185.230.79.15";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "02:34";
|
resticClient.when = "02:34";
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
acme.enable = true;
|
acme.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public-ssh = "";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,9 @@
|
||||||
srv-nat.enable = true;
|
srv-nat.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "03:45";
|
resticClient.when = "03:45";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,9 @@
|
||||||
srv-nat.enable = true;
|
srv-nat.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "06:47";
|
resticClient.when = "06:47";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,14 @@
|
||||||
networking = {
|
networking = {
|
||||||
srv = {
|
srv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
ipv4 = "185.230.79.5";
|
ipv4.address = "185.230.79.5";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "04:56";
|
resticClient.when = "04:56";
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,9 @@
|
||||||
|
|
||||||
homeAdh.enable = true;
|
homeAdh.enable = true;
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.enable = false;
|
resticClient.enable = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,9 @@
|
||||||
srv-nat.enable = true;
|
srv-nat.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "02:56";
|
resticClient.when = "02:56";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,15 @@
|
||||||
srv = {
|
srv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interface = "ens20";
|
interface = "ens20";
|
||||||
ipv4 = "185.230.79.42";
|
ipv4.address = "185.230.79.42";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
resticClient.when = "03:42";
|
services.acme.enable = true;
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
resticClient.when = "03:42";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,10 +230,6 @@ in
|
||||||
"zero".proxyPass = "172.16.10.130";
|
"zero".proxyPass = "172.16.10.130";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
|
||||||
acme.enable = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Règle particulières
|
# Règle particulières
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,9 @@
|
||||||
srv-nat.enable = true;
|
srv-nat.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
monitoring = {
|
||||||
|
nginx.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
resticClient.when = "04:44";
|
resticClient.when = "04:44";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
lib/info.nix
42
lib/info.nix
|
|
@ -3,11 +3,6 @@
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
attrNames
|
attrNames
|
||||||
attrsToList
|
|
||||||
isInt
|
|
||||||
isString
|
|
||||||
join
|
|
||||||
length
|
|
||||||
listToAttrs
|
listToAttrs
|
||||||
filter
|
filter
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
|
@ -16,31 +11,9 @@ let
|
||||||
nixosSystem
|
nixosSystem
|
||||||
readDir
|
readDir
|
||||||
warn
|
warn
|
||||||
warnIf
|
|
||||||
warnIfNot
|
|
||||||
;
|
;
|
||||||
infoRequired = {
|
|
||||||
name = isString;
|
|
||||||
description = isString;
|
|
||||||
id = isInt;
|
|
||||||
};
|
|
||||||
verifyAttrs =
|
|
||||||
info:
|
|
||||||
let
|
|
||||||
missing = filter (n: !(info ? ${n})) (attrNames infoRequired);
|
|
||||||
wrongType = filter (n: info ? ${n.name} && !(n.value info.${n.name})) (attrsToList infoRequired);
|
|
||||||
in
|
|
||||||
(warnIf (
|
|
||||||
length missing > 0
|
|
||||||
) "${info.name}/info.nix : les attributs « ${join ", " missing} » sont manquants")
|
|
||||||
(warnIf (length wrongType > 0)
|
|
||||||
"${info.name}/info.nix : les attributs « ${join ", " (map (i: i.name) wrongType)} » sont mal typés"
|
|
||||||
)
|
|
||||||
(warnIfNot (
|
|
||||||
(info.isDebian or false) || info ? enable
|
|
||||||
) "${info.name}/info.nix : cette machine nix ne définit pas l’attribut enable")
|
|
||||||
info;
|
|
||||||
|
|
||||||
|
cransConfig = import ../config;
|
||||||
get_hosts_names = path: attrNames (filterAttrs (name: type: type == "directory") (readDir path));
|
get_hosts_names = path: attrNames (filterAttrs (name: type: type == "directory") (readDir path));
|
||||||
get_info =
|
get_info =
|
||||||
path:
|
path:
|
||||||
|
|
@ -51,7 +24,15 @@ let
|
||||||
filePath = path + "/${name}/info.nix";
|
filePath = path + "/${name}/info.nix";
|
||||||
in
|
in
|
||||||
if builtins.pathExists filePath then
|
if builtins.pathExists filePath then
|
||||||
verifyAttrs (import filePath)
|
(lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
../modules/info
|
||||||
|
filePath
|
||||||
|
];
|
||||||
|
specialArgs = {
|
||||||
|
crans = cransConfig;
|
||||||
|
};
|
||||||
|
}).config
|
||||||
else
|
else
|
||||||
warn "${toString filePath} not found" null
|
warn "${toString filePath} not found" null
|
||||||
) (get_hosts_names path)
|
) (get_hosts_names path)
|
||||||
|
|
@ -67,10 +48,11 @@ rec {
|
||||||
nixosSystem {
|
nixosSystem {
|
||||||
specialArgs = inputs // {
|
specialArgs = inputs // {
|
||||||
hosts = all_hosts;
|
hosts = all_hosts;
|
||||||
|
crans = cransConfig;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
(path + "/${name}")
|
(path + "/${name}")
|
||||||
({ ... }: { config.crans = info; })
|
({ ... }: { config.crans.info = info; })
|
||||||
]
|
]
|
||||||
++ baseModules;
|
++ baseModules;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
{ lib, config, ... }:
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
crans,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans;
|
cfg = config.crans.info;
|
||||||
|
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkEnableOption
|
|
||||||
mkOption
|
mkOption
|
||||||
mkIf
|
mkIf
|
||||||
types
|
types
|
||||||
|
|
@ -21,72 +25,24 @@ in
|
||||||
./ntp.nix
|
./ntp.nix
|
||||||
./restic_client.nix
|
./restic_client.nix
|
||||||
./monitoring.nix
|
./monitoring.nix
|
||||||
|
./motd.nix
|
||||||
./nullmailer.nix
|
./nullmailer.nix
|
||||||
./packages.nix
|
./packages.nix
|
||||||
./ssh.nix
|
./ssh.nix
|
||||||
./store.nix
|
./store.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
./vlans.nix
|
|
||||||
./virtualisation.nix
|
./virtualisation.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.crans = {
|
options.crans.info = mkOption {
|
||||||
enable = mkEnableOption "Configuration commune à toutes les machines du Crans";
|
type = types.submoduleWith {
|
||||||
|
modules = [ ../info ];
|
||||||
name = mkOption {
|
specialArgs = { inherit crans; };
|
||||||
type = types.str;
|
|
||||||
example = "vm-test";
|
|
||||||
description = "Nom de la machine";
|
|
||||||
};
|
|
||||||
|
|
||||||
isVm = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
description = "Est-ce une machine virtuelle ?";
|
|
||||||
};
|
|
||||||
|
|
||||||
isDebian = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
example = "true";
|
|
||||||
description = "Est-ce une machine Debian ?";
|
|
||||||
};
|
|
||||||
|
|
||||||
description = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
example = "VM de test";
|
|
||||||
description = "Description de la machine";
|
|
||||||
};
|
|
||||||
|
|
||||||
id = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
example = 135;
|
|
||||||
description = ''
|
|
||||||
ID de la machine :
|
|
||||||
- < 100 machine physique
|
|
||||||
- >= 100 VM ( id de la VM dans proxmox )
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
public-ssh = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Clé ssh public de la machine";
|
|
||||||
};
|
};
|
||||||
|
description = "Informations de la machines (info.nix)";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
crans = {
|
|
||||||
homeNounou.enable = lib.mkDefault true;
|
|
||||||
monitoring.enable = true;
|
|
||||||
networking = {
|
|
||||||
enable = lib.mkDefault true;
|
|
||||||
adm.enable = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
resticClient.enable = lib.mkDefault true;
|
|
||||||
users = {
|
|
||||||
ldap.enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
warnings = (
|
warnings = (
|
||||||
optional (
|
optional (
|
||||||
cfg.isVm != (cfg.id >= 100)
|
cfg.isVm != (cfg.id >= 100)
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,13 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans;
|
cfg = config.crans.info;
|
||||||
|
|
||||||
inherit (lib) mkEnableOption mkIf;
|
inherit (lib) mkIf;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.crans = {
|
# Options ../info/home.nix
|
||||||
homeNounou = {
|
|
||||||
enable = mkEnableOption "Monter /home_nounou.";
|
|
||||||
};
|
|
||||||
homeAdh = {
|
|
||||||
enable = mkEnableOption "Monter /home-adh";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
fileSystems = {
|
fileSystems = {
|
||||||
home_nounou = mkIf cfg.homeNounou.enable {
|
home_nounou = mkIf cfg.homeNounou.enable {
|
||||||
|
|
@ -31,7 +23,7 @@ in
|
||||||
home_adh = mkIf cfg.homeAdh.enable {
|
home_adh = mkIf cfg.homeAdh.enable {
|
||||||
mountPoint = "/home-adh";
|
mountPoint = "/home-adh";
|
||||||
device = "172.16.4.2:/pool/home";
|
device = "172.16.4.2:/pool/home";
|
||||||
fsType = "nfs";
|
fsType = "nfs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,27 @@
|
||||||
{ config, lib, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans.monitoring;
|
cfg = config.crans.info.monitoring;
|
||||||
|
|
||||||
inherit (lib)
|
nginxEnable = config.services.nginx.enable;
|
||||||
mkEnableOption
|
inherit (lib) mkIf optional;
|
||||||
mkIf
|
|
||||||
mkOption
|
boolToStr = b: if b then "true" else "false";
|
||||||
types
|
|
||||||
;
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.crans.monitoring = {
|
# Options ../info/monitoring.nix
|
||||||
enable = mkEnableOption "Monitoring prometheus de la machine.";
|
|
||||||
|
|
||||||
nginx = {
|
config = {
|
||||||
enable = mkOption {
|
warnings = optional (cfg.enable && (nginxEnable != cfg.nginx.enable)) ''
|
||||||
type = types.bool;
|
${config.crans.info.name} : config.services.nginx.enable (${boolToStr nginxEnable}) n’est pas cohérent avec le monitoring déclaré dans l’info.nix (${boolToStr cfg.nginx.enable})
|
||||||
default = config.services.nginx.enable;
|
'';
|
||||||
example = true;
|
|
||||||
description = "Monitoring de Nginx par prometheus.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
services.prometheus.exporters = mkIf cfg.enable {
|
||||||
services.prometheus.exporters = {
|
|
||||||
node = {
|
node = {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = 9100;
|
port = 9100;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
{ self, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) removeSuffix;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
users.motd =
|
||||||
|
let
|
||||||
|
shortRev = self.shortRev or self.dirtyShortRev or "inconnue";
|
||||||
|
rev = self.rev or (removeSuffix "-dirty" (self.dirtyRev or "inconnue"));
|
||||||
|
isDirty = !(self ? rev);
|
||||||
|
in
|
||||||
|
''
|
||||||
|
${
|
||||||
|
if isDirty then "!! DIRTY !! " else ""
|
||||||
|
}Version déployée ${shortRev}, modifiée le ${self.lastModifiedDate or "??"}.
|
||||||
|
|
||||||
|
https://gitlab.crans.org/nounous/nixos/-/commit/${rev}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,88 +1,24 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
hosts,
|
crans,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans;
|
cfg = config.crans.info;
|
||||||
cfg-net = cfg.networking;
|
cfg-net = cfg.networking;
|
||||||
|
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkEnableOption
|
|
||||||
mkIf
|
mkIf
|
||||||
mkOption
|
|
||||||
mkDefault
|
mkDefault
|
||||||
types
|
|
||||||
mod
|
|
||||||
mapAttrs
|
|
||||||
mapAttrs'
|
mapAttrs'
|
||||||
filterAttrs
|
filterAttrs
|
||||||
mergeAttrsList
|
|
||||||
optional
|
|
||||||
fixedWidthString
|
|
||||||
nameValuePair
|
nameValuePair
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.crans.networking = {
|
# Options ../info/networking.nix
|
||||||
enable = mkEnableOption "Configuration réseaux commune à toutes les machines du Crans.";
|
|
||||||
}
|
|
||||||
// mapAttrs (
|
|
||||||
vlan: conf:
|
|
||||||
let
|
|
||||||
vlanId = mod conf.id 100;
|
|
||||||
in
|
|
||||||
mergeAttrsList (
|
|
||||||
[
|
|
||||||
{
|
|
||||||
enable = mkEnableOption "Activation du réseau ${vlan}";
|
|
||||||
|
|
||||||
interface = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Interface pour le réseau ${vlan}";
|
|
||||||
default = conf.interface;
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultRoutes = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Configuration par défaut des routes de ${vlan}";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
]
|
|
||||||
++ optional ((conf.ipv4 or true) != null) {
|
|
||||||
ipv4 = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Adresse IPv4 de la machine sur le réseau ${vlan}";
|
|
||||||
default = "172.16.${toString vlanId}.${toString cfg.id}";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
++ optional ((conf.ipv6 or true) != null) (
|
|
||||||
let
|
|
||||||
# XXX: Utilisation du masque pour le déterminer à la place ?
|
|
||||||
prefix =
|
|
||||||
if lib.hasPrefix "2a0c:700" conf.ipv6.address then
|
|
||||||
"2a0c:700"
|
|
||||||
else if lib.hasPrefix "fd00:0:0" conf.ipv6.address then
|
|
||||||
"fd00:0:0"
|
|
||||||
else
|
|
||||||
(builtins.warn "Le prefixe de ${conf.ipv6.address} n’est pas reconnu");
|
|
||||||
in
|
|
||||||
{
|
|
||||||
ipv6 = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Adresse IPv6 de la machine sur le réseau ${vlan}";
|
|
||||||
default = "${prefix}:${toString vlanId}::ff:fe0${toString (cfg.id / 100)}:${toString (mod cfg.id 100)}${
|
|
||||||
fixedWidthString 2 "0" (toString vlanId)
|
|
||||||
}";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) cfg.vlans;
|
|
||||||
|
|
||||||
config = mkIf cfg-net.enable {
|
config = mkIf cfg-net.enable {
|
||||||
networking = {
|
networking = {
|
||||||
hostName = cfg.name;
|
hostName = cfg.name;
|
||||||
|
|
@ -95,24 +31,24 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
interfaces = mapAttrs' (
|
interfaces = mapAttrs' (
|
||||||
vlan: vconf:
|
vname: _:
|
||||||
let
|
let
|
||||||
conf = cfg-net.${vlan};
|
conf = cfg-net.${vname};
|
||||||
in
|
in
|
||||||
nameValuePair conf.interface (
|
nameValuePair conf.interface (
|
||||||
# On itère ipv4 / ipv6
|
# On itère ipv4 / ipv6
|
||||||
builtins.mapAttrs
|
builtins.mapAttrs
|
||||||
(
|
(
|
||||||
ipvx: _:
|
ipvx: _:
|
||||||
mkIf (vconf.${ipvx} != null) {
|
mkIf (conf.${ipvx} != null) {
|
||||||
addresses = [
|
addresses = [
|
||||||
{
|
{
|
||||||
address = conf.${ipvx};
|
address = conf.${ipvx}.address;
|
||||||
prefixLength = vconf.${ipvx}.prefixLength;
|
prefixLength = conf.${ipvx}.prefixLength;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
routes = mkIf conf.defaultRoutes vconf.${ipvx}.routes;
|
routes = conf.${ipvx}.routes;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -120,7 +56,7 @@ in
|
||||||
"ipv6" = null;
|
"ipv6" = null;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
) (filterAttrs (n: _: cfg-net.${n}.enable) cfg.vlans); # On filtre les interfaces désactivées.
|
) (filterAttrs (n: _: cfg-net.${n}.enable) crans.vlans); # On filtre les interfaces désactivées.
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,13 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans.resticClient;
|
cfg = config.crans.info.resticClient;
|
||||||
|
|
||||||
inherit (lib)
|
inherit (lib) mkIf;
|
||||||
mkEnableOption
|
|
||||||
mkIf
|
|
||||||
mkOption
|
|
||||||
types
|
|
||||||
;
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.crans.resticClient = {
|
# Options ../info/resticClient.nix
|
||||||
enable = mkEnableOption "Configuration générale pour le client restic.";
|
|
||||||
|
|
||||||
additionalPaths = mkOption {
|
|
||||||
type = types.listOf types.path;
|
|
||||||
default = [ ];
|
|
||||||
example = [ "/backup" ];
|
|
||||||
description = "Chemins à backuper en plus de ceux par défaut.";
|
|
||||||
};
|
|
||||||
|
|
||||||
additionalExcludes = mkOption {
|
|
||||||
type = types.listOf types.path;
|
|
||||||
default = [ ];
|
|
||||||
example = [ "/var/lib/<service>/cache" ];
|
|
||||||
description = "Chemins à exclure des backups en plus de ceux par défaut.";
|
|
||||||
};
|
|
||||||
|
|
||||||
when = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
example = "05:42";
|
|
||||||
description = "À quelle heure faire les backups.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
|
|
@ -52,11 +25,13 @@ in
|
||||||
paths = [
|
paths = [
|
||||||
"/etc"
|
"/etc"
|
||||||
"/var"
|
"/var"
|
||||||
] ++ cfg.additionalPaths;
|
]
|
||||||
|
++ cfg.additionalPaths;
|
||||||
exclude = [
|
exclude = [
|
||||||
"/var/cache"
|
"/var/cache"
|
||||||
"/var/lib/lxcfs"
|
"/var/lib/lxcfs"
|
||||||
] ++ cfg.additionalExcludes;
|
]
|
||||||
|
++ cfg.additionalExcludes;
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnCalendar = cfg.when;
|
OnCalendar = cfg.when;
|
||||||
RandomizedDelaySec = "6h";
|
RandomizedDelaySec = "6h";
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,9 @@
|
||||||
{
|
{ config, ... }:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
self,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans.users;
|
cfg = config.crans.info.users;
|
||||||
|
|
||||||
inherit (lib)
|
|
||||||
mkEnableOption
|
|
||||||
mkOption
|
|
||||||
types
|
|
||||||
;
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.crans.users = {
|
# Options : ../info/users.nix
|
||||||
ldap = {
|
|
||||||
enable = mkEnableOption "Authentification par le LDAP adm.";
|
|
||||||
};
|
|
||||||
|
|
||||||
root = {
|
|
||||||
passwordFile = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
default = ../../secrets/common/root.age;
|
|
||||||
example = ../../secrets/apprentix/root.age;
|
|
||||||
description = "Fichier chiffré par age contenant le mot de passe root.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
age.secrets.root-passwd-hash = {
|
age.secrets.root-passwd-hash = {
|
||||||
|
|
@ -39,20 +13,6 @@ in
|
||||||
users = {
|
users = {
|
||||||
mutableUsers = false;
|
mutableUsers = false;
|
||||||
|
|
||||||
motd =
|
|
||||||
let
|
|
||||||
shortRev = self.shortRev or self.dirtyShortRev or "inconnue";
|
|
||||||
rev = self.rev or (lib.strings.removeSuffix "-dirty" (self.dirtyRev or "inconnue"));
|
|
||||||
isDirty = !(self ? rev);
|
|
||||||
in
|
|
||||||
''
|
|
||||||
${
|
|
||||||
if isDirty then "!! DIRTY !! " else ""
|
|
||||||
}Version déployée ${shortRev}, modifiée le ${self.lastModifiedDate or "??"}.
|
|
||||||
|
|
||||||
https://gitlab.crans.org/nounous/nixos/-/commit/${rev}
|
|
||||||
'';
|
|
||||||
|
|
||||||
users.root = {
|
users.root = {
|
||||||
hashedPasswordFile = config.age.secrets.root-passwd-hash.path;
|
hashedPasswordFile = config.age.secrets.root-passwd-hash.path;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.acme.enable = mkEnableOption "Activer les certificats ACME via let's encrypt.";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkDefault
|
||||||
|
mkOption
|
||||||
|
mkIf
|
||||||
|
types
|
||||||
|
;
|
||||||
|
in
|
||||||
|
# Point Important
|
||||||
|
# L’évaluation se fait en deux passe.
|
||||||
|
# 1. La flake.nix avec la lib/info.nix évalue les info.nix
|
||||||
|
# 2. Les VMs évaluent la conf en partant de cette évaluation
|
||||||
|
# Il n’est donc pas possible de redéfinir les options des infos dans les conf
|
||||||
|
# des VMs (même avec des mkForce and co) puisque la conf est déjà merge lors de la
|
||||||
|
# première évaluation (les mkXX sont donc applatit à ce moment là)
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./acme.nix
|
||||||
|
./home.nix
|
||||||
|
./meta.nix
|
||||||
|
./monitoring.nix
|
||||||
|
./networking.nix
|
||||||
|
./resticClient.nix
|
||||||
|
./users.nix
|
||||||
|
];
|
||||||
|
options.enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
example = true;
|
||||||
|
description = "Activer la configuration Crans par défaut";
|
||||||
|
# On n’utilise pas mkEnableOption pour forcer la définition de enable à true
|
||||||
|
# ou false (et limiter les oublis)
|
||||||
|
};
|
||||||
|
config = mkIf config.enable {
|
||||||
|
homeNounou.enable = mkDefault true;
|
||||||
|
monitoring.enable = mkDefault true;
|
||||||
|
networking = {
|
||||||
|
enable = mkDefault true;
|
||||||
|
adm.enable = mkDefault true;
|
||||||
|
};
|
||||||
|
resticClient.enable = mkDefault true;
|
||||||
|
users = {
|
||||||
|
ldap.enable = mkDefault true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
homeNounou.enable = mkEnableOption "Monter /home_nounou.";
|
||||||
|
homeAdh.enable = mkEnableOption "Monter /home-adh";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Nom de la machine";
|
||||||
|
};
|
||||||
|
|
||||||
|
description = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Description de la machine";
|
||||||
|
};
|
||||||
|
|
||||||
|
id = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
example = 135;
|
||||||
|
description = "
|
||||||
|
ID de la machine :
|
||||||
|
- < 100 machine physique
|
||||||
|
- >= 100 VM ( id de la VM dans proxmox )
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
isVm = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = "Est-ce une machine virtuelle ?";
|
||||||
|
};
|
||||||
|
|
||||||
|
isDebian = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = "Est-ce que c’est une machine sous Débian ?";
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
public-ssh = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Clé ssh public de la machine";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkOption types;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.monitoring = {
|
||||||
|
enable = mkEnableOption "Monitoring prometheus de la machine.";
|
||||||
|
|
||||||
|
nginx = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
example = true;
|
||||||
|
description = "Monitoring de Nginx par prometheus.";
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,148 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
crans,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
fixedWidthString
|
||||||
|
hasPrefix
|
||||||
|
listToAttrs
|
||||||
|
mapAttrs
|
||||||
|
mergeAttrsList
|
||||||
|
mod
|
||||||
|
mkEnableOption
|
||||||
|
mkOption
|
||||||
|
optional
|
||||||
|
optionalAttrs
|
||||||
|
nameValuePair
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
|
switchOptions = listToAttrs (
|
||||||
|
map (
|
||||||
|
n:
|
||||||
|
nameValuePair n (mkOption {
|
||||||
|
type = types.nullOr types.int;
|
||||||
|
description = "Port sur le switch ${n}";
|
||||||
|
default = null;
|
||||||
|
})
|
||||||
|
) crans.switchs
|
||||||
|
);
|
||||||
|
|
||||||
|
routesType = types.listOf (
|
||||||
|
types.submodule {
|
||||||
|
options = {
|
||||||
|
address = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Réseau de destination";
|
||||||
|
};
|
||||||
|
prefixLength = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = "Masque du réseau de destination";
|
||||||
|
};
|
||||||
|
via = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Ip de la gateway";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
ilo.id = mkOption {
|
||||||
|
type = types.nullOr types.int;
|
||||||
|
description = "Identifiant de l’ilo";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
ilo.switch = switchOptions;
|
||||||
|
|
||||||
|
# TODO: vérifier que les IPs déclarées sont bien dans le réseau vlan (masque)
|
||||||
|
networking = {
|
||||||
|
enable = mkEnableOption "Activation du réseau Crans";
|
||||||
|
switch = switchOptions;
|
||||||
|
}
|
||||||
|
// mapAttrs (
|
||||||
|
vname: vconf:
|
||||||
|
mergeAttrsList (
|
||||||
|
[
|
||||||
|
{
|
||||||
|
enable = mkEnableOption "Activation du réseau ${vname}";
|
||||||
|
|
||||||
|
interface = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Interface pour le réseau ${vname}";
|
||||||
|
default = vconf.interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
tag = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = "Tag du vlan";
|
||||||
|
readOnly = true;
|
||||||
|
default = vconf.id;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optional ((vconf.ipv4 or { }) != null) {
|
||||||
|
ipv4.address =
|
||||||
|
mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Adresse IPv4 de la machine sur le réseau ${vname}";
|
||||||
|
}
|
||||||
|
// (optionalAttrs (hasPrefix "172.16" (vconf.ipv4.address or "172.16.0.0")) {
|
||||||
|
default = "172.16.${toString vconf.id}.${toString config.id}";
|
||||||
|
});
|
||||||
|
|
||||||
|
ipv4.prefixLength = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = "Masque IPv4 de la machine sur le réseau ${vname}";
|
||||||
|
default = vconf.ipv4.prefixLength or 24;
|
||||||
|
};
|
||||||
|
|
||||||
|
ipv4.routes = mkOption {
|
||||||
|
type = routesType;
|
||||||
|
description = "Routes de l’interface";
|
||||||
|
default = vconf.ipv4.routes or [ ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
++ optional ((vconf.ipv6 or { }) != null) (
|
||||||
|
let
|
||||||
|
# XXX: Utilisation du masque pour le déterminer à la place ?
|
||||||
|
prefix =
|
||||||
|
if !(vconf ? ipv6) || lib.hasPrefix "fd00:0:0" vconf.ipv6.address then
|
||||||
|
"fd00:0:0"
|
||||||
|
else if lib.hasPrefix "2a0c:700" vconf.ipv6.address then
|
||||||
|
"2a0c:700"
|
||||||
|
else
|
||||||
|
(builtins.warn "Le prefixe de ${vconf.ipv6.address} n’est pas reconnu");
|
||||||
|
in
|
||||||
|
{
|
||||||
|
ipv6.address = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Adresse IPv6 de la machine sur le réseau ${vname}";
|
||||||
|
default = "${prefix}:${toString vconf.id}::ff:fe0${toString (config.id / 100)}:${toString (mod config.id 100)}${
|
||||||
|
fixedWidthString 2 "0" (toString vconf.id)
|
||||||
|
}";
|
||||||
|
};
|
||||||
|
|
||||||
|
ipv6.prefixLength = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = "Masque IPv6 de la machine sur le réseau ${vname}";
|
||||||
|
default = vconf.ipv6.prefixLength or 64;
|
||||||
|
};
|
||||||
|
|
||||||
|
ipv6.routes = mkOption {
|
||||||
|
type = routesType;
|
||||||
|
description = "Routes de l’interface";
|
||||||
|
default = vconf.ipv6.routes or [ ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) crans.vlans
|
||||||
|
|
||||||
|
;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkOption types;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.resticClient = {
|
||||||
|
enable = mkEnableOption "Configuration générale pour le client restic.";
|
||||||
|
|
||||||
|
additionalPaths = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = [ ];
|
||||||
|
example = [ "/backup" ];
|
||||||
|
description = "Chemins à backuper en plus de ceux par défaut.";
|
||||||
|
};
|
||||||
|
|
||||||
|
additionalExcludes = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = [ ];
|
||||||
|
example = [ "/var/lib/<service>/cache" ];
|
||||||
|
description = "Chemins à exclure des backups en plus de ceux par défaut.";
|
||||||
|
};
|
||||||
|
|
||||||
|
when = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
example = "05:42";
|
||||||
|
description = "À quelle heure faire les backups.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkOption types;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.users = {
|
||||||
|
ldap = {
|
||||||
|
enable = mkEnableOption "Authentification par le LDAP adm.";
|
||||||
|
};
|
||||||
|
|
||||||
|
root = {
|
||||||
|
passwordFile = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
default = ../../secrets/common/root.age;
|
||||||
|
example = ../../secrets/apprentix/root.age;
|
||||||
|
description = "Fichier chiffré par age contenant le mot de passe root.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.crans.services.acme;
|
cfg = config.crans.info.services.acme;
|
||||||
|
|
||||||
inherit (lib) mkEnableOption mkIf;
|
inherit (lib) mkIf;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.crans.services.acme = {
|
# Options : ../info/acme.nix
|
||||||
enable = mkEnableOption "Activer les certificats ACME via let's encrypt.";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
acme-env.file = ../../secrets/acme/env.age;
|
acme-env.file = ../../secrets/acme/env.age;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.crans.info.monitoring;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
services.nginx = lib.mkIf config.services.nginx.enable {
|
services.nginx = lib.mkIf config.services.nginx.enable {
|
||||||
recommendedProxySettings = true;
|
recommendedProxySettings = true;
|
||||||
|
|
@ -15,7 +18,7 @@
|
||||||
real_ip_header X-Real-Ip;
|
real_ip_header X-Real-Ip;
|
||||||
'';
|
'';
|
||||||
|
|
||||||
virtualHosts.nginx-stub-status = lib.mkIf config.crans.monitoring.enable {
|
virtualHosts.nginx-stub-status = lib.mkIf (cfg.enable && cfg.nginx.enable) {
|
||||||
listen = [
|
listen = [
|
||||||
{
|
{
|
||||||
addr = "[::1]";
|
addr = "[::1]";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue