Skip to content

Commit

Permalink
blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Nov 14, 2024
1 parent c8673ea commit 380eba4
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 252 deletions.
36 changes: 0 additions & 36 deletions dev/docs.nix

This file was deleted.

39 changes: 0 additions & 39 deletions dev/shell.nix

This file was deleted.

14 changes: 14 additions & 0 deletions devshells/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ perSystem, pkgs, ... }:

with pkgs;

mkShellNoCC {
packages = [
perSystem.agenix.default
jq
python3.pkgs.deploykit
python3.pkgs.invoke
sops
ssh-to-age
];
}
7 changes: 7 additions & 0 deletions devshells/mkdocs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ perSystem, pkgs, ... }:

with pkgs;

mkShellNoCC {
inputsFrom = [ perSystem.self.docs ];
}
24 changes: 24 additions & 0 deletions devshells/sotp.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ pkgs, ... }:

with pkgs;

mkShellNoCC {
packages = [
(buildGoModule rec {
pname = "sotp";
version = "e7f7c804b1641169ce850d8352fb07294881609e";
src = fetchFromGitHub {
owner = "getsops";
repo = "sotp";
rev = version;
hash = "sha256-Cu8cZCmM19G5zeMIiiaCwVJee8wrBZP3Ltk1jWKb2vs=";
};
vendorHash = "sha256-vQruuohwi53By8UZLrPbRtUrmNbmPt+Sku9hI5J3Dlc=";
ldflags = [
"-s"
"-w"
];
doCheck = false;
})
];
}
16 changes: 16 additions & 0 deletions devshells/terraform.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ pkgs, ... }:

with pkgs;

mkShellNoCC {
packages = [
(terraform.withPlugins (p: [
p.cloudflare
p.external
p.hydra
p.null
p.sops
p.tfe
]))
];
}
40 changes: 24 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 42 additions & 95 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
agenix.inputs.nixpkgs.follows = "nixpkgs";
agenix.inputs.systems.follows = "systems";
agenix.url = "github:ryantm/agenix";
blueprint.inputs.nixpkgs.follows = "nixpkgs";
blueprint.inputs.systems.follows = "systems";
blueprint.url = "github:numtide/blueprint";
buildbot-nix.inputs.flake-parts.follows = "flake-parts";
buildbot-nix.inputs.nixpkgs.follows = "nixpkgs";
buildbot-nix.inputs.treefmt-nix.follows = "treefmt-nix";
Expand All @@ -29,7 +32,6 @@
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
hydra.flake = false;
hydra.url = "github:qowoz/hydra/community";
lite-config.url = "github:yelite/lite-config";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -54,101 +56,46 @@
treefmt-nix.url = "github:numtide/treefmt-nix";
};

outputs =
inputs@{ flake-parts, self, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;

imports = [
./modules
inputs.lite-config.flakeModule
inputs.treefmt-nix.flakeModule
];

lite-config =
{ lib, ... }:
{
nixpkgs = {
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "terraform" ];
overlays = [
(final: prev: {
hydra = (prev.hydra.override { nix = final.nixVersions.nix_2_24; }).overrideAttrs (o: {
version = inputs.hydra.shortRev;
src = inputs.hydra;
buildInputs = o.buildInputs ++ [ final.perlPackages.DBIxClassHelpers ];
});
})
];
};

hostModuleDir = ./hosts;
# overlays = [
# (final: prev: {
# hydra = (prev.hydra.override { nix = final.nixVersions.nix_2_24; }).overrideAttrs (o: {
# version = inputs.hydra.shortRev;
# src = inputs.hydra;
# buildInputs = o.buildInputs ++ [ final.perlPackages.DBIxClassHelpers ];
# });
# })
# ];

hosts = {
build01.system = "x86_64-linux";
build02.system = "x86_64-linux";
build03.system = "x86_64-linux";
build04.system = "aarch64-linux";
darwin01.system = "aarch64-darwin";
darwin02.system = "aarch64-darwin";
web02.system = "x86_64-linux";
};
# checks =
# let
# darwinConfigurations = lib.mapAttrs' (
# name: config: lib.nameValuePair "host-${name}" config.config.system.build.toplevel
# ) ((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
# ) ((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;
# 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-hydra = pkgs.nixosTests.hydra.hydra;
# };

systemModules = [
(
{ hostPlatform, ... }:
{
imports =
lib.optionals hostPlatform.isDarwin [ ./modules/darwin/common ]
++ lib.optionals hostPlatform.isLinux [ ./modules/nixos/common ];
}
)
];
};

perSystem =
{
inputs',
lib,
pkgs,
self',
system,
...
}:
{
imports = [
./dev/docs.nix
./dev/shell.nix
./terraform/shell.nix
];
treefmt = {
flakeCheck = system == "x86_64-linux";
imports = [ ./dev/treefmt.nix ];
};

checks =
let
darwinConfigurations = lib.mapAttrs' (
name: config: lib.nameValuePair "host-${name}" config.config.system.build.toplevel
) ((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
) ((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;
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-hydra = pkgs.nixosTests.hydra.hydra;
};
};
outputs =
inputs:
inputs.blueprint {
inherit inputs;
nixpkgs.config.allowUnfreePredicate =
pkg: builtins.elem (inputs.nixpkgs.lib.getName pkg) [ "terraform" ];
};
}
5 changes: 5 additions & 0 deletions hosts/build01/default.nix → hosts/build01/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{ inputs, ... }:
{
imports = [
inputs.self.nixosModules.common
inputs.srvos.nixosModules.hardware-hetzner-online-amd
inputs.self.nixosModules.disko-zfs
inputs.self.nixosModules.builder
inputs.self.nixosModules.community-builder
];

networking.hostName = "build01";

nixpkgs.hostPlatform = "x86_64-linux";

# Emulate riscv64 until we have proper builders
boot.binfmt.emulatedSystems = [ "riscv64-linux" ];
boot.binfmt.preferStaticEmulators = true;
Expand Down
Loading

0 comments on commit 380eba4

Please sign in to comment.