From d234b670d06ee72b87e384ebb3789b8d098d62cd Mon Sep 17 00:00:00 2001 From: K900 Date: Fri, 9 Aug 2024 18:45:53 +0300 Subject: [PATCH] flake.nix: reformat, prepare for hook --- flake.nix | 217 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 128 insertions(+), 89 deletions(-) diff --git a/flake.nix b/flake.nix index 7de8260..d99a6e9 100644 --- a/flake.nix +++ b/flake.nix @@ -31,98 +31,137 @@ }; }; - outputs = { self, nixpkgs, terranix, colmena, ... } @ inputs: - let - supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; - forEachSystem = f: builtins.listToAttrs (map (system: { - name = system; - value = f system; - }) supportedSystems); - systemBits = forEachSystem (system: rec { - inherit system; - pkgs = import nixpkgs { - localSystem = system; - overlays = [ - inputs.hydra.overlays.default - inputs.lix.overlays.default - inputs.nix-gerrit.overlays.default - ]; - }; - terraform = pkgs.opentofu; - terraformCfg = terranix.lib.terranixConfiguration { - inherit system; - modules = [ - ./terraform - { - bagel.gandi.enable = true; - bagel.hydra.enable = true; - } - ]; - }; - }); - forEachSystem' = f: forEachSystem (system: (f systemBits.${system})); - inherit (nixpkgs) lib; - in - { - apps = forEachSystem' ({ system, pkgs, terraformCfg, terraform, ... }: { - tf = { - type = "app"; - program = toString (pkgs.writers.writeBash "tf" '' - set -eo pipefail - ln -snf ${terraformCfg} config.tf.json - exec ${lib.getExe terraform} "$@" - ''); - }; - - default = self.apps.${system}.tf; - }); - - devShells = forEachSystem' ({ system, pkgs, ... }: { - default = pkgs.mkShell { - packages = [ - inputs.agenix.packages.${system}.agenix - - pkgs.opentofu - - (pkgs.callPackage ./lib/colmena-wrapper.nix { }) - ]; - }; - }); - - nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes; - - colmena = let - commonModules = [ - inputs.agenix.nixosModules.default - inputs.hydra.nixosModules.hydra - inputs.buildbot-nix.nixosModules.buildbot-coordinator - inputs.buildbot-nix.nixosModules.buildbot-worker - - ./services - ./common + outputs = + { + self, + nixpkgs, + terranix, + colmena, + ... + }@inputs: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" ]; + forEachSystem = + f: + builtins.listToAttrs ( + map (system: { + name = system; + value = f system; + }) supportedSystems + ); + systemBits = forEachSystem (system: rec { + inherit system; + pkgs = import nixpkgs { + localSystem = system; + overlays = [ + inputs.hydra.overlays.default + inputs.lix.overlays.default + inputs.nix-gerrit.overlays.default + ]; + }; + terraform = pkgs.opentofu; + terraformCfg = terranix.lib.terranixConfiguration { + inherit system; + modules = [ + ./terraform + { + bagel.gandi.enable = true; + bagel.hydra.enable = true; + } + ]; + }; + }); + forEachSystem' = f: forEachSystem (system: (f systemBits.${system})); + inherit (nixpkgs) lib; + in + { + apps = forEachSystem' ( + { + system, + pkgs, + terraformCfg, + terraform, + ... + }: + { + tf = { + type = "app"; + program = toString ( + pkgs.writers.writeBash "tf" '' + set -eo pipefail + ln -snf ${terraformCfg} config.tf.json + exec ${lib.getExe terraform} "$@" + '' + ); + }; - makeBuilder = i: lib.nameValuePair "builder-${toString i}" { - imports = commonModules; - bagel.baremetal.builders = { enable = true; num = i; netboot = i >= 6; }; - }; + default = self.apps.${system}.tf; + } + ); - builders = lib.listToAttrs (lib.genList makeBuilder 12); - in { - meta.nixpkgs = systemBits.x86_64-linux.pkgs; - meta.specialArgs.inputs = inputs; + devShells = forEachSystem' ( + { system, pkgs, ... }: + { + default = pkgs.mkShell { + packages = [ + inputs.agenix.packages.${system}.agenix - bagel-box.imports = commonModules ++ [ ./hosts/bagel-box ]; - meta01.imports = commonModules ++ [ ./hosts/meta01 ]; - gerrit01.imports = commonModules ++ [ ./hosts/gerrit01 ]; - fodwatch.imports = commonModules ++ [ ./hosts/fodwatch ]; - git.imports = commonModules ++ [ ./hosts/git ]; - wob-vpn-gw.imports = commonModules ++ [ ./hosts/wob-vpn-gw ]; - buildbot.imports = commonModules ++ [ ./hosts/buildbot ]; - public01.imports = commonModules ++ [ ./hosts/public01 ]; - } // builders; + pkgs.opentofu - hydraJobs = builtins.mapAttrs (n: v: v.config.system.build.netbootDir or v.config.system.build.toplevel) self.nixosConfigurations; - buildbotJobs = builtins.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations; - }; + (pkgs.callPackage ./lib/colmena-wrapper.nix { }) + ]; + }; + } + ); + + nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes; + + colmena = + let + commonModules = [ + inputs.agenix.nixosModules.default + inputs.hydra.nixosModules.hydra + inputs.buildbot-nix.nixosModules.buildbot-coordinator + inputs.buildbot-nix.nixosModules.buildbot-worker + + ./services + ./common + ]; + + makeBuilder = + i: + lib.nameValuePair "builder-${toString i}" { + imports = commonModules; + bagel.baremetal.builders = { + enable = true; + num = i; + netboot = i >= 6; + }; + }; + + builders = lib.listToAttrs (lib.genList makeBuilder 12); + in + { + meta.nixpkgs = systemBits.x86_64-linux.pkgs; + meta.specialArgs.inputs = inputs; + + bagel-box.imports = commonModules ++ [ ./hosts/bagel-box ]; + meta01.imports = commonModules ++ [ ./hosts/meta01 ]; + gerrit01.imports = commonModules ++ [ ./hosts/gerrit01 ]; + fodwatch.imports = commonModules ++ [ ./hosts/fodwatch ]; + git.imports = commonModules ++ [ ./hosts/git ]; + wob-vpn-gw.imports = commonModules ++ [ ./hosts/wob-vpn-gw ]; + buildbot.imports = commonModules ++ [ ./hosts/buildbot ]; + public01.imports = commonModules ++ [ ./hosts/public01 ]; + } + // builders; + + hydraJobs = builtins.mapAttrs ( + n: v: v.config.system.build.netbootDir or v.config.system.build.toplevel + ) self.nixosConfigurations; + buildbotJobs = builtins.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations; + }; }