forgejo-ci-runners/flake.nix

182 lines
6.3 KiB
Nix
Raw Permalink Normal View History

2024-05-14 12:03:36 -05:00
{
description = "Forgejo CI Runners";
inputs = {
2024-09-07 13:51:01 -05:00
# NixOS nixpkgs 24.05
2024-11-17 23:32:09 -06:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
2024-09-07 13:51:01 -05:00
2024-08-07 19:26:51 -05:00
# Lix - Substitution of the Nix package manager, focused on correctness, usability, and growth and committed to doing right by its community.
# https://git.lix.systems/lix-project/lix
lix-module = {
2024-09-07 13:22:47 -05:00
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.0.tar.gz";
2024-08-07 19:26:51 -05:00
inputs.nixpkgs.follows = "nixpkgs";
};
2024-09-07 13:51:01 -05:00
# srvos - NixOS modules for Hetzner Cloud and other services
2024-05-14 12:03:36 -05:00
srvos.url = "github:numtide/srvos";
2024-09-07 13:51:01 -05:00
# disko - NixOS module for managing disks
2024-05-14 12:03:36 -05:00
disko.url = "github:nix-community/disko";
2024-09-07 13:51:01 -05:00
# Cachix helper functions for deploying NixOS systems with flakes.
2024-06-18 23:46:58 -05:00
cachix-deploy-flake.url = "github:cachix/cachix-deploy-flake";
2024-09-07 13:51:01 -05:00
# Cachix - Nix binary cache hosting and continuous integration
2024-06-19 00:48:47 -05:00
cachix-flake = {
url = "github:cachix/cachix";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-09-07 13:51:01 -05:00
# sops-nix - Atomic secret provisioning for NixOS based on sops
2024-05-14 12:03:36 -05:00
# https://github.com/Mic92/sops-nix
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
2024-08-07 19:26:51 -05:00
outputs = { self, sops-nix, nixpkgs, srvos, disko, cachix-flake, cachix-deploy-flake, lix-module, ... }@inputs:
2024-06-19 00:48:47 -05:00
let
2024-09-07 14:50:44 -05:00
inherit (nixpkgs) lib;
2024-06-19 00:48:47 -05:00
common = system: rec {
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
cachix = cachix-flake.packages.${system}.default;
})
];
};
cachix-deploy-lib = cachix-deploy-flake.lib pkgs;
};
aarch64-linux-modules = [
sops-nix.nixosModules.sops
2024-07-25 11:05:47 -05:00
srvos.nixosModules.hardware-hetzner-cloud
srvos.nixosModules.server
srvos.nixosModules.mixins-systemd-boot
disko.nixosModules.disko
2024-08-07 19:26:51 -05:00
lix-module.nixosModules.default
2024-07-25 11:05:47 -05:00
./agents/fj-hetzner-aarch64.nix
(import ./disko-hetzner-cloud.nix { disks = [ "/dev/sda" ]; })
{
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "fj-hetzner-aarch64-01";
users.users.root.openssh.authorizedKeys.keys =
[
2024-06-19 00:48:47 -05:00
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBsUe5YF5z8vGcEYtQX7AAiw2rJygGf2l7xxr8nZZa7w jahanson@legiondary"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJyA/yMPPo+scxBaDFUk7WeEyMAMhXUro5vi4feOKsJT jahanson@durincore"
2024-07-15 20:26:27 -05:00
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILcLI5qN69BuoLp8p7nTYKoLdsBNmZB31OerZ63Car1g jahanson@telchar"
2024-06-19 00:48:47 -05:00
];
2024-07-25 11:05:47 -05:00
services.openssh.enable = true;
services.openssh.settings.PermitRootLogin = "without-password";
}
];
x86_64-linux-modules = [
sops-nix.nixosModules.sops
2024-09-07 14:50:44 -05:00
./hardware/shadowfax.nix
srvos.nixosModules.server
srvos.nixosModules.mixins-systemd-boot
disko.nixosModules.disko
2024-08-07 19:26:51 -05:00
lix-module.nixosModules.default
./agents/fj-shadowfax-x86_64.nix
2024-09-07 14:50:44 -05:00
(import ./disko-shadowfax.nix { disks = [ "/dev/sda" ]; })
{
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "fj-shadowfax-01";
2024-07-25 11:05:47 -05:00
users.users.root.openssh.authorizedKeys.keys =
[
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBsUe5YF5z8vGcEYtQX7AAiw2rJygGf2l7xxr8nZZa7w jahanson@legiondary"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJyA/yMPPo+scxBaDFUk7WeEyMAMhXUro5vi4feOKsJT jahanson@durincore"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILcLI5qN69BuoLp8p7nTYKoLdsBNmZB31OerZ63Car1g jahanson@telchar"
];
services.openssh.enable = true;
services.openssh.settings.PermitRootLogin = "without-password";
}
];
2024-07-25 11:05:47 -05:00
in
{
2024-06-19 02:28:19 -05:00
# NixOS configurations for manual deployment
2024-07-25 11:05:47 -05:00
nixosConfigurations =
{
2024-09-07 14:50:44 -05:00
"fj-hetzner-aarch64" = lib.nixosSystem {
2024-07-25 11:05:47 -05:00
system = "aarch64-linux";
specialArgs = { inherit inputs; };
modules = aarch64-linux-modules;
};
2024-09-07 14:50:44 -05:00
"fj-x86_64" = lib.nixosSystem {
2024-07-25 11:05:47 -05:00
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = x86_64-linux-modules;
};
};
2024-09-07 14:50:44 -05:00
2024-06-19 02:28:19 -05:00
# Cachix deploy for automated deployments
2024-07-25 11:05:47 -05:00
packages.aarch64-linux.default =
let
2024-08-07 19:39:22 -05:00
inherit (common "aarch64-linux") cachix-deploy-lib;
in
cachix-deploy-lib.nixos {
# system = "aarch64-linux";
imports = aarch64-linux-modules;
2024-05-14 12:03:36 -05:00
};
2024-06-19 00:48:47 -05:00
packages.x86_64-linux.default =
let
2024-08-07 19:39:22 -05:00
inherit (common "x86_64-linux") cachix-deploy-lib;
2024-06-19 00:48:47 -05:00
in
cachix-deploy-lib.nixos {
imports = x86_64-linux-modules;
2024-06-19 00:48:47 -05:00
};
2024-06-19 09:45:36 -05:00
# Constructs a deploy.json output that can be used to deploy the runners
# https://docs.cachix.org/deploy/reference#deploy-json
2024-07-25 11:05:47 -05:00
deploy-json =
2024-06-19 02:28:19 -05:00
{
2024-07-25 11:05:47 -05:00
"aarch64-linux" =
let
inherit (common "aarch64-linux") cachix-deploy-lib;
in
cachix-deploy-lib.spec
{
agents = {
"fj-hetzner-aarch64-01" =
let
2024-08-07 19:39:22 -05:00
inherit (common "aarch64-linux") cachix-deploy-lib;
2024-07-25 11:05:47 -05:00
in
cachix-deploy-lib.nixos {
# system = "aarch64-linux";
imports = aarch64-linux-modules;
};
};
2024-06-19 02:28:19 -05:00
};
2024-07-25 11:05:47 -05:00
"x86_64-linux" =
let
inherit (common "x86_64-linux") cachix-deploy-lib;
in
cachix-deploy-lib.spec
{
agents = {
"fj-shadowfax-01" =
let
2024-08-07 19:39:22 -05:00
inherit (common "x86_64-linux") cachix-deploy-lib;
2024-07-25 11:05:47 -05:00
in
cachix-deploy-lib.nixos {
imports = x86_64-linux-modules;
};
};
2024-06-19 02:28:19 -05:00
};
};
2024-07-25 11:05:47 -05:00
2024-05-26 19:38:35 -05:00
# Convenience output that aggregates the outputs for home, nixos.
2024-09-07 14:50:44 -05:00
# Also used in ci to build targets generally.
top =
let
nixtop = nixpkgs.lib.genAttrs
(builtins.attrNames inputs.self.nixosConfigurations)
(attr: inputs.self.nixosConfigurations.${attr}.config.system.build.toplevel);
in
nixtop;
};
2024-05-14 12:03:36 -05:00
}