Merge branch 'comin' into 'main'

Draft: Auto-updates

See merge request nounous/nixos!109
merge-requests/109/merge
Lyes Saadi 2026-11-21 20:38:59 +01:00
commit 849bebf0f1
23 changed files with 348 additions and 31 deletions

View File

@ -20,16 +20,54 @@
"type": "github"
}
},
"comin": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1795253528,
"narHash": "sha256-TvzBvAV7KVWsvTCQjRg1oY/lhDbuN9YXLDctGGhXPdU=",
"owner": "nlewo",
"repo": "comin",
"rev": "4cc0f6a9764a0ac73ec248d1475a1372c19b4773",
"type": "github"
},
"original": {
"owner": "nlewo",
"repo": "comin",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1765121682,
"narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=",
"owner": "NixOS",
"repo": "flake-compat",
"rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1790898470,
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
"lastModified": 1793576659,
"narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
"rev": "ea2630b7470978622c7689a1ff75d2b389175399",
"type": "github"
},
"original": {
@ -40,11 +78,42 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1793294725,
"narHash": "sha256-loLMnbbS4KhmG2ln9EY6f0YMNCA273Yx02oWYQ9IMeE=",
"lastModified": 1770107345,
"narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1793504054,
"narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1795137884,
"narHash": "sha256-iKXCN36qYfBni+3nH4vAd98/kshoIsPB2S9mYWhma30=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6f06d204d8f2d8761d9da78778745974a3216381",
"rev": "ab5c18fdedfc8f9bbc9d773f10a540790e2787a7",
"type": "github"
},
"original": {
@ -54,41 +123,45 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1790477367,
"narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"comin": "comin",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
"nixpkgs": "nixpkgs_2",
"treefmt-nix": "treefmt-nix_2"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1770228511,
"narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "337a4fe074be1042a35086f15481d763b8ddc0e7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"treefmt-nix_2": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1791885023,
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
"lastModified": 1795173499,
"narHash": "sha256-J8IYl3oEdctyvBgWr+/L01MY5Xm0TU4WXwZDccN5jjk=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
"rev": "a0a97e31a897a3537eea5c49df4f8adaa83b3b37",
"type": "github"
},
"original": {

View File

@ -16,6 +16,12 @@
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Auto updates
comin = {
url = "github:nlewo/comin";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
@ -24,6 +30,7 @@
nixpkgs,
flake-parts,
agenix,
comin,
...
}:
let
@ -46,6 +53,7 @@
baseModules = [
./modules
agenix.nixosModules.default
comin.nixosModules.default
];
in
(attrsToNixosSystem ./hosts/vm attrs_all_info attrs_vm_info baseModules)

View File

@ -3,6 +3,7 @@
description = "Serveur de stockage ceph";
id = 3;
enable = true;
# Sous Nix mais dans une autre branche
isDebian = true;
@ -16,6 +17,10 @@
};
};
resticClient.enable = false;
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOsBGkhiu6l3jeo15cQHMu3dPyL025zXPV2ZH02EDYEt root@cephiroth";
ilo = {
id = 53;
switch.salameche = 20;

View File

@ -13,5 +13,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFKNg1b8ft1L55+joXQ/7Dt2QTOdkea8opTEnq4xrhPU root@thot";
resticClient.enable = false;
}

View File

@ -13,5 +13,7 @@
homeNounou.enable = false;
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCJV6jqQWEYuwi+OJ9r/4TbBN/cK9NvYWNiJhpFzcc7 root@apprentix";
users.root.passwordFile = ../../../secrets/apprentix/root.age;
}

View File

@ -21,5 +21,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFa2D9fREtO2r2oIx6q9JAKFUHtxGbgEPMjkx09DQSU8 root@collabora";
resticClient.enable = false;
}

View File

@ -15,10 +15,20 @@
monitoring = {
nginx.enable = true;
comin.enable = true;
};
autoUpdate = {
enable = true;
main.enable = false;
testing.branch = "comin";
};
resticClient.when = "06:07";
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGoR66An5huQucZlueQCcB/vwd085wrS2mUIz39e8QLt root@coturn";
services = {
acme.enable = true;
};

View File

@ -19,6 +19,8 @@
resticClient.when = "02:34";
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB6jVMIZ5y2oXX9HOkw7r5UUjw95MlFaFuu7FnEC0Q8z root@jitsi";
services = {
acme.enable = true;
};

View File

@ -25,5 +25,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEVfKNokHG6ig32hhQxTep+fKFmKahlDClPrX/dP4/gb root@livre";
resticClient.when = "03:45";
}

View File

@ -38,5 +38,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFfcKtim7Aj+strHdg847D7KCCdoOAuasxx/2yi2TY1n root@mediakiwi";
resticClient.when = "06:47";
}

View File

@ -18,6 +18,8 @@
resticClient.when = "04:56";
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMGfSvxqC2PJYRrxJaivVDujwlwCZ6AwH8hOSA9ktZ1V root@neo";
services = {
acme.enable = true;
};

View File

@ -25,5 +25,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMgSP9UmuJw8Bi2ML07WHsWvxN8akkc9XZxXyOgdjXkq root@nextcloud";
resticClient.enable = false;
}

View File

@ -23,5 +23,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTdfSIL3AWIv0mjRDam6E/qsjoqwJ8QSm1Cb0xqs1s1 root@periodique";
resticClient.when = "02:56";
}

View File

@ -20,5 +20,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOx/lUQE6naP3EBy81sr93X8ktZmivU09ACx6T43Odhb root@reverseproxy";
resticClient.when = "03:42";
}

View File

@ -12,5 +12,7 @@
};
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPpaGf8A+XWXBdNrs69RiC0qPbjPHdtkl31OjxrktmF6 root@two";
resticClient.when = "07:29";
}

View File

@ -21,5 +21,7 @@
nginx.enable = true;
};
publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICn6vfDlsZVU6TEWg9vTgq9+Fp3irHjytBTky7A4ErRM root@vaultwarden";
resticClient.when = "04:44";
}

View File

@ -0,0 +1,78 @@
{ lib, info, ... }:
let
inherit (lib) mkIf;
cfg = info.autoUpdate;
in
{
# Options ../info/autoupdate.nix
config = mkIf cfg.enable {
services.comin = {
enable = true;
buildAttemptsLimit = 3;
buildRetryTimer = 5 * 60;
buildTimeout = 2 * 60 * 60;
remotes = [
# TODO : à split en deux remotes, l'une pour main, l'autre pour testing
{
name = "origin";
url = "https://gitlab.adm.crans.org/nounous/nixos.git";
poller.period = cfg.period;
branches = {
main =
let
branch =
if cfg.main.enable then
{
branch = "name";
# period = cfg.main.period;
}
else
cfg.testing;
in
{
inherit (cfg) operation;
name = branch.branch;
};
testing = {
inherit (cfg) operation;
name = cfg.testing.branch;
};
};
}
];
exporter = mkIf info.monitoring.comin.enable {
listen_address = info.networking.adm.ipv4.address;
port = 4267;
};
};
nix = mkIf (info.name != "cephiroth") {
distributedBuilds = true;
settings = {
max-jobs = 0;
builders-use-substitutes = true;
};
buildMachines = [
{
hostName = "cephiroth.adm.crans.org";
sshUser = "builder";
sshKey = "/etc/ssh/ssh_host_ed25519_key";
system = "x86_64-linux";
maxJobs = 32;
supportedFeatures = [
"nixos-test"
"benchmark"
"big-parallel"
"kvm"
];
}
];
};
# TODO : Autoreboot
};
}

View File

@ -13,6 +13,7 @@ in
{
imports = [
./age.nix
./autoupdate.nix
./grub.nix
./home.nix
./locale.nix

View File

@ -1,5 +1,19 @@
{ ... }:
{
infra,
lib,
hosts,
...
}:
let
inherit (lib)
attrNames
concatMap
optional
mapAttrs'
mkIf
nameValuePair
;
in
{
services.openssh = {
enable = true;
@ -7,5 +21,34 @@
settings = {
PermitRootLogin = "yes";
};
# knownHosts :
# {
# "host" = {
# hostNames = ["host.adm.crans.org" 172.16.10.2 …]
# publicKey = "ssh-ed25519…"
# }
# }
knownHosts = mapAttrs' (
n: conf:
nameValuePair n (
mkIf (conf.publicSsh != null) {
publicKey = conf.publicSsh;
hostNames = [
"${n}.adm.crans.org"
]
++ concatMap (
vlan:
let
netv = conf.networking.${vlan};
in
optional (netv.enable && (netv.ipv4.address or null) != null) netv.ipv4.address
++ optional (netv.enable && (netv.ipv6.address or null) != null) netv.ipv6.address
) (attrNames infra.vlans);
}
)
) hosts;
};
}

View File

@ -0,0 +1,64 @@
{ config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption types;
in
{
options.autoUpdate = {
enable = mkEnableOption "Activer les mises à jours automatiques.";
autoDeploy = mkOption {
type = types.bool;
description = "Auto-déployer les changements construits.";
default = true;
};
autoReboot = mkOption {
type = types.nullOr types.str;
description = "Définir une plage d'heure d'auto-reboot.";
default = null;
};
operation = mkOption {
type = types.str;
description = "L'opération à effectuer (switch, test ou boot).";
example = "boot";
default = "switch";
};
period = mkOption {
type = types.ints.positive;
description = "Le délai entre chaque pull du git en secondes.";
default = 5 * 60;
};
main = {
enable = mkOption {
type = types.bool;
description = "Activer le suivi de la branche main.";
default = true;
};
# branch = mkOption {
# type = types.str;
# description = "La branche à suivre pour les mises à jours principales.";
# default = "main";
# };
# operation = mkOption {
# type = types.str;
# description = "L'opération à effectuer (switch, test ou boot).";
# example = "boot";
# default = "switch";
# };
};
testing = {
branch = mkOption {
type = types.str;
description = "La branche à suivre pour les tests.";
default = "testing-${config.name}";
};
# operation = mkOption {
# type = types.str;
# description = "L'opération à effectuer (switch, test ou boot).";
# example = "boot";
# default = "${config.autoUpdate.main.operation}";
# };
};
};
}

View File

@ -14,6 +14,7 @@ in
{
imports = [
./acme.nix
./autoupdate.nix
./home.nix
./meta.nix
./monitoring.nix
@ -27,7 +28,7 @@ in
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)
# ou false (et limiter les oublis).
};
config = mkIf config.enable {
homeNounou.enable = mkDefault true;

View File

@ -35,8 +35,9 @@ in
default = false;
};
public-ssh = mkOption {
type = types.str;
publicSsh = mkOption {
type = types.nullOr types.str;
default = null;
description = "Clé ssh publique de la machine.";
};
};

View File

@ -14,5 +14,14 @@ in
default = false;
};
};
comin = {
enable = mkOption {
type = types.bool;
example = true;
description = "Monitoring de Comin (l'auto-update) par prometheus.";
default = false;
};
};
};
}