mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-10 04:49:19 -08:00
feat(aya): runner
This commit is contained in:
parent
fc11fb8152
commit
585c758254
11 changed files with 785 additions and 32 deletions
48
modules/nixos/github-runner.nix
Normal file
48
modules/nixos/github-runner.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.attrsets) filterAttrs mapAttrs' nameValuePair;
|
||||
inherit (inputs.self.lib.lib) unmerged;
|
||||
cfg = config.services.github-runners;
|
||||
nixosConfig = config;
|
||||
enabledRunners = filterAttrs (_: runner: runner.enable) cfg;
|
||||
runnerModule = { config, ... }: {
|
||||
options = with lib.types; {
|
||||
networkNamespace.name = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
};
|
||||
serviceSettings = mkOption {
|
||||
type = unmerged.type;
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
config = {
|
||||
serviceSettings = mkIf (config.networkNamespace.name != null) {
|
||||
networkNamespace = {
|
||||
name = mkDefault config.networkNamespace.name;
|
||||
afterOnline = mkDefault true;
|
||||
};
|
||||
};
|
||||
serviceOverrides = mkIf (config.user != null && nixosConfig.users.users ? ${config.user}) {
|
||||
DynamicUser = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options = with lib.types; {
|
||||
services.github-runners = mkOption {
|
||||
type = attrsOf (submodule runnerModule);
|
||||
};
|
||||
};
|
||||
config = {
|
||||
systemd.services = mapAttrs' (name: runner: nameValuePair "github-runner-${name}" (
|
||||
unmerged.merge runner.serviceSettings
|
||||
)) enabledRunners;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue