infra/flake.nix

145 lines
5.5 KiB
Nix
Raw Permalink Normal View History

2022-04-10 20:57:52 +02:00
{
description = "NixOS configuration of our builders";
2024-07-24 19:05:26 +10:00
nixConfig.extra-substituters = [ "https://nix-community.cachix.org" ];
2022-04-18 07:42:44 +02:00
nixConfig.extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
2022-04-10 20:57:52 +02:00
inputs = {
2023-10-25 11:53:51 +10:00
buildbot-nix.inputs.flake-parts.follows = "flake-parts";
2024-11-27 13:15:38 +10:00
buildbot-nix.inputs.hercules-ci-effects.follows = "hercules-ci-effects";
buildbot-nix.inputs.nixpkgs.follows = "nixpkgs";
2023-10-25 11:53:51 +10:00
buildbot-nix.inputs.treefmt-nix.follows = "treefmt-nix";
2024-09-23 23:24:31 +10:00
buildbot-nix.url = "github:nix-community/buildbot-nix";
2022-12-30 20:49:32 +01:00
disko.inputs.nixpkgs.follows = "nixpkgs";
disko.url = "github:nix-community/disko";
empty.url = "github:nix-systems/empty";
2023-04-12 13:20:42 +10:00
flake-compat.url = "github:nix-community/flake-compat";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
2024-07-22 15:02:19 +10:00
hercules-ci-effects.inputs.flake-parts.follows = "flake-parts";
hercules-ci-effects.inputs.nixpkgs.follows = "nixpkgs";
hercules-ci-effects.url = "github:qowoz/hercules-ci-effects/darwin-sudo";
2024-07-06 16:58:34 +10:00
hydra.flake = false;
hydra.url = "github:qowoz/hydra/community";
2024-08-17 21:49:16 +10:00
lite-config.url = "github:yelite/lite-config";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-darwin.url = "github:qowoz/nix-darwin/darwin-sudo";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
nix-index-database.url = "github:nix-community/nix-index-database";
nixos-facter-modules.url = "github:nix-community/nixos-facter-modules";
nixpkgs-update-github-releases.flake = false;
nixpkgs-update-github-releases.url = "github:nix-community/nixpkgs-update-github-releases";
nixpkgs-update.inputs.mmdoc.follows = "empty";
nixpkgs-update.inputs.treefmt-nix.follows = "treefmt-nix";
2024-12-24 07:20:31 +10:00
nixpkgs-update.url = "github:nix-community/nixpkgs-update/infra";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
nur-update.inputs.nixpkgs.follows = "nixpkgs";
nur-update.url = "github:nix-community/nur-update";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.url = "github:Mic92/sops-nix";
srvos.inputs.nixpkgs.follows = "nixpkgs";
srvos.url = "github:nix-community/srvos";
systems.url = "github:nix-systems/default";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
2022-04-10 20:57:52 +02:00
};
2024-07-24 19:05:26 +10:00
outputs =
inputs@{ flake-parts, self, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
2024-08-17 21:49:16 +10:00
imports = [
2025-01-18 10:09:22 +10:00
./dev/docs.nix
2023-12-27 10:43:18 +10:00
./dev/effect-deploy.nix
./modules
2023-12-27 10:43:18 +10:00
inputs.hercules-ci-effects.flakeModule
2024-08-17 21:49:16 +10:00
inputs.lite-config.flakeModule
inputs.treefmt-nix.flakeModule
];
lite-config =
{ lib, ... }:
{
nixpkgs = {
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "terraform" ];
2024-07-06 16:58:34 +10:00
overlays = [
2024-12-09 15:57:39 +10:00
(final: prev: (import ./dev/packages.nix { inherit final prev inputs; }))
2024-07-06 16:58:34 +10:00
];
2024-08-17 21:49:16 +10:00
};
hostModuleDir = ./hosts;
hosts = {
build01.system = "x86_64-linux";
build02.system = "x86_64-linux";
build03.system = "x86_64-linux";
build04.system = "aarch64-linux";
build05.system = "aarch64-linux";
2024-08-17 21:49:16 +10:00
darwin01.system = "aarch64-darwin";
darwin02.system = "aarch64-darwin";
web02.system = "x86_64-linux";
};
systemModules = [
(
{ hostPlatform, ... }:
{
imports =
lib.optionals hostPlatform.isDarwin [ ./modules/darwin/common ]
++ lib.optionals hostPlatform.isLinux [ ./modules/nixos/common ];
}
)
];
};
2022-12-31 07:18:49 +01:00
2024-07-24 19:05:26 +10:00
perSystem =
{
inputs',
lib,
pkgs,
self',
system,
...
}:
{
imports = [
./dev/shell.nix
./terraform/shell.nix
];
treefmt = {
flakeCheck = system == "x86_64-linux";
imports = [ ./dev/treefmt.nix ];
};
2023-09-13 11:35:21 +10:00
2024-07-24 19:05:26 +10:00
checks =
let
darwinConfigurations = lib.mapAttrs' (
name: config: lib.nameValuePair "host-${name}" config.config.system.build.toplevel
2024-07-24 19:05:26 +10:00
) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.darwinConfigurations);
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
nixosConfigurations = lib.mapAttrs' (
name: config: lib.nameValuePair "host-${name}" config.config.system.build.toplevel
2024-07-24 19:05:26 +10:00
) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
in
darwinConfigurations
// devShells
// {
inherit (self') formatter;
}
// nixosConfigurations
// pkgs.lib.optionalAttrs (system == "x86_64-linux") {
inherit (self'.packages) docs docs-linkcheck;
2024-07-24 19:05:26 +10:00
nixpkgs-update-supervisor-test = pkgs.callPackage ./hosts/build02/supervisor_test.nix { };
nixosTests-buildbot = pkgs.nixosTests.buildbot;
nixosTests-buildbot-nix-master = inputs'.buildbot-nix.checks.master;
nixosTests-buildbot-nix-worker = inputs'.buildbot-nix.checks.worker;
nixosTests-harmonia = pkgs.nixosTests.harmonia;
2024-09-02 13:06:43 +10:00
nixosTests-hydra = pkgs.nixosTests.hydra.hydra;
};
2024-07-24 19:05:26 +10:00
};
};
2022-04-10 20:57:52 +02:00
}