diff --git a/flake.lock b/flake.lock index 02b77ad..2b70d64 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,44 @@ "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" @@ -40,16 +78,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1793294725, - "narHash": "sha256-loLMnbbS4KhmG2ln9EY6f0YMNCA273Yx02oWYQ9IMeE=", - "owner": "NixOS", + "lastModified": 1770107345, + "narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "6f06d204d8f2d8761d9da78778745974a3216381", + "rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-26.05", + "owner": "nixos", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -69,15 +107,50 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1793294725, + "narHash": "sha256-loLMnbbS4KhmG2ln9EY6f0YMNCA273Yx02oWYQ9IMeE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6f06d204d8f2d8761d9da78778745974a3216381", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "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" diff --git a/flake.nix b/flake.nix index f00085f..15bb8c1 100644 --- a/flake.nix +++ b/flake.nix @@ -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) diff --git a/modules/crans/autoupdate.nix b/modules/crans/autoupdate.nix new file mode 100644 index 0000000..893407a --- /dev/null +++ b/modules/crans/autoupdate.nix @@ -0,0 +1,77 @@ +{ 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; + 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 = 8; + supportedFeatures = [ + "nixos-test" + "benchmark" + "big-parallel" + "kvm" + ]; + } + ]; + }; + + # TODO : Autoreboot + }; +} diff --git a/modules/crans/default.nix b/modules/crans/default.nix index ee6e5aa..13cc45f 100644 --- a/modules/crans/default.nix +++ b/modules/crans/default.nix @@ -13,6 +13,7 @@ in { imports = [ ./age.nix + ./autoupdate.nix ./grub.nix ./home.nix ./locale.nix