infra/flake.nix

109 lines
2.9 KiB
Nix
Raw Normal View History

2024-06-23 04:41:53 +00:00
{
description = "Bagel cooking infrastructure";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
terranix.url = "github:terranix/terranix";
2024-06-23 04:41:53 +00:00
2024-06-24 16:03:07 +00:00
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
2024-06-23 04:41:53 +00:00
colmena.url = "github:zhaofengli/colmena";
colmena.inputs.nixpkgs.follows = "nixpkgs";
2024-06-24 14:45:59 +00:00
hydra.url = "git+https://git.lix.systems/lix-project/hydra.git";
hydra.inputs.nixpkgs.follows = "nixpkgs";
2024-06-24 18:59:37 +00:00
nix-gerrit.url = "git+https://git.lix.systems/the-distro/nix-gerrit.git";
nix-gerrit.inputs.nixpkgs.follows = "nixpkgs";
flake.lock: Update Flake lock file updates: • Updated input 'hydra': 'git+https://git.lix.systems/lix-project/hydra.git?ref=refs/heads/main&rev=fb9e29d4d0f2f591cd1d706fd3b7334af7d34b84' (2024-07-13) → 'git+https://git.lix.systems/lix-project/hydra.git?ref=refs/heads/main&rev=b0e9b4b2f99f9d8f5c4e780e89f955c394b5ced4' (2024-07-17) • Added input 'hydra/lix': 'git+https://git.lix.systems/lix-project/lix?ref=refs/heads/main&rev=6b4d46e9e0e1dd80e0977684ab20d14bcd1a6bc3' (2024-07-16) • Added input 'hydra/lix/flake-compat': 'github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33' (2023-10-04) • Added input 'hydra/lix/nix2container': 'github:nlewo/nix2container/20aad300c925639d5d6cbe30013c8357ce9f2a2e' (2024-04-13) • Added input 'hydra/lix/nixpkgs': follows 'hydra/nixpkgs' • Added input 'hydra/lix/nixpkgs-regression': 'github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2' (2022-01-24) • Added input 'hydra/lix/pre-commit-hooks': 'github:cachix/git-hooks.nix/e35aed5fda3cc79f88ed7f1795021e559582093a' (2024-04-02) • Removed input 'hydra/nix' • Removed input 'hydra/nix/flake-compat' • Removed input 'hydra/nix/nix2container' • Removed input 'hydra/nix/nixpkgs' • Removed input 'hydra/nix/nixpkgs-regression' • Removed input 'hydra/nix/pre-commit-hooks' • Added input 'hydra/nix-eval-jobs': 'git+https://git.lix.systems/lix-project/nix-eval-jobs?ref=refs/heads/main&rev=c057494450f2d1420726ddb0bab145a5ff4ddfdd' (2024-07-17) • Added input 'hydra/nix-eval-jobs/flake-parts': 'github:hercules-ci/flake-parts/9227223f6d922fee3c7b190b2cc238a99527bbb7' (2024-07-03) • Added input 'hydra/nix-eval-jobs/flake-parts/nixpkgs-lib': follows 'hydra/nix-eval-jobs/nixpkgs' • Added input 'hydra/nix-eval-jobs/lix': follows 'hydra/lix' • Added input 'hydra/nix-eval-jobs/nix-github-actions': 'github:nix-community/nix-github-actions/622f829f5fe69310a866c8a6cd07e747c44ef820' (2024-07-04) • Added input 'hydra/nix-eval-jobs/nix-github-actions/nixpkgs': follows 'hydra/nix-eval-jobs/nixpkgs' • Added input 'hydra/nix-eval-jobs/nixpkgs': follows 'hydra/nixpkgs' • Added input 'hydra/nix-eval-jobs/treefmt-nix': 'github:numtide/treefmt-nix/0fb28f237f83295b4dd05e342f333b447c097398' (2024-07-15) • Added input 'hydra/nix-eval-jobs/treefmt-nix/nixpkgs': follows 'hydra/nix-eval-jobs/nixpkgs' • Updated input 'lix': follows 'hydra/nix' → follows 'hydra/lix' • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/6794d064edc69918bb0fc0e0eda33ece324be17a' (2024-07-12) → 'github:NixOS/nixpkgs/9355fa86e6f27422963132c2c9aeedb0fb963d93' (2024-07-16)
2024-07-17 11:10:53 +00:00
lix.follows = "hydra/lix";
2024-06-23 04:41:53 +00:00
};
outputs = { self, nixpkgs, terranix, colmena, ... } @ inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
localSystem = system;
overlays = [
inputs.hydra.overlays.default
inputs.lix.overlays.default
inputs.nix-gerrit.overlays.default
];
};
lib = pkgs.lib;
terraform = pkgs.opentofu;
terraformCfg = terranix.lib.terranixConfiguration {
inherit system;
2024-07-07 18:43:05 +00:00
modules = [
./terraform
{
2024-07-07 18:43:05 +00:00
bagel.gandi.enable = true;
bagel.hydra.enable = true;
}
];
};
in
{
apps.${system} = {
tf = {
type = "app";
program = toString (pkgs.writers.writeBash "tf" ''
set -eo pipefail
ln -snf ${terraformCfg} config.tf.json
exec ${lib.getExe terraform} "$@"
'');
};
2024-07-07 16:02:55 +00:00
default = self.apps.${system}.tf;
};
2024-07-05 09:43:53 +00:00
devShells.${system}.default = pkgs.mkShell {
packages = [
2024-07-05 09:43:53 +00:00
inputs.agenix.packages.${system}.agenix
pkgs.colmena
pkgs.opentofu
2024-07-05 09:43:53 +00:00
];
};
nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes;
2024-07-10 12:24:47 +00:00
colmena = let
commonModules = [
inputs.agenix.nixosModules.default
inputs.hydra.nixosModules.hydra
./services
./common
];
makeBuilder = i: lib.nameValuePair "builder-${toString i}" {
imports = commonModules;
bagel.baremetal.builders = { enable = true; num = i; };
};
builders = lib.listToAttrs (lib.genList makeBuilder 12);
in {
2024-06-23 04:41:53 +00:00
meta.nixpkgs = import nixpkgs {
localSystem = system;
2024-06-24 18:59:37 +00:00
overlays = [
inputs.hydra.overlays.default
inputs.lix.overlays.default
inputs.nix-gerrit.overlays.default
2024-06-24 18:59:37 +00:00
];
2024-06-23 04:41:53 +00:00
};
2024-06-24 14:45:59 +00:00
meta.specialArgs.inputs = inputs;
2024-07-10 12:24:47 +00:00
bagel-box.imports = commonModules ++ [ ./hosts/bagel-box ];
meta01.imports = commonModules ++ [ ./hosts/meta01 ];
gerrit01.imports = commonModules ++ [ ./hosts/gerrit01 ];
fodwatch.imports = commonModules ++ [ ./hosts/fodwatch ];
2024-07-16 13:42:10 +00:00
git.imports = commonModules ++ [ ./hosts/git ];
2024-07-10 12:24:47 +00:00
wob-vpn-gw.imports = commonModules ++ [ ./hosts/wob-vpn-gw ];
} // builders;
hydraJobs = builtins.mapAttrs (n: v: v.config.system.build.toplevel) self.nixosConfigurations;
2024-06-23 04:41:53 +00:00
};
}