Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP blueprint #1563

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ];
# });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved to packages/hydra/default.nix, and then pulled in the module with services.hydra.package = perSystem.self.hydra;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With lite-config this overlay is applied to pkgsso we don't need to do any additional wiring, e.g. .#nixosConfigurations.build03 and .#checks.x86_64-linux.nixosTests-hydra both just work. It is also exposed directly in .#packages.${system}.hydra.

# })
# ];

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