feat: Builder config settable with options

This commit is contained in:
Hunter Halloran
2025-12-17 10:43:43 -05:00
parent 3a95155d49
commit 5fe7c08830
5 changed files with 185 additions and 26 deletions

View File

@@ -98,22 +98,27 @@
devices = {
"nix-builder" = {
# GitHub Actions self-hosted runner configuration
# The runner will register itself with the repository on first start
services.github-runners.nixos-systems = {
enable = true;
url = "https://github.com/UGA-Innovation-Factory/nixos-systems";
# Token file must be created manually at this path with a GitHub PAT
# that has repo access. Generate at: https://github.com/settings/tokens
# echo "YOUR_TOKEN_HERE" | sudo tee /var/lib/github-runner-token > /dev/null
tokenFile = "/var/lib/github-runner-token";
# Labels to identify this runner in workflows
extraLabels = [ "nix-builder" ];
# User to run the runner as
user = "engr-ugaif";
# Working directory for runner
workDir = "/var/lib/github-runner";
# Replace runner on config changes
replace = true;
ugaif.sw = {
type = [
"headless"
"builders"
];
builders.githubRunner = {
enable = true;
url = "https://github.com/UGA-Innovation-Factory/nixos-systems";
# Token file must be created manually at this path with a GitHub PAT
# that has repo access. Generate at: https://github.com/settings/tokens
# echo "YOUR_TOKEN_HERE" | sudo tee /var/lib/github-runner-token > /dev/null
tokenFile = "/var/lib/github-runner-token";
# Labels to identify this runner in workflows
extraLabels = [ "nix-builder" ];
# User to run the runner as
user = "engr-ugaif";
# Working directory for runner
workDir = "/var/lib/github-runner";
# Runner service name
name = "nixos-systems";
};
};
};
"usda-dash" = builtins.fetchGit {

31
sw/builders/default.nix Normal file
View File

@@ -0,0 +1,31 @@
# ============================================================================
# Builders Software Configuration
# ============================================================================
# Imports builder-specific programs and services (GitHub Actions runners, etc.)
{
config,
lib,
pkgs,
inputs,
...
}:
lib.mkMerge [
(import ./programs.nix {
inherit
config
lib
pkgs
inputs
;
})
(import ./services.nix {
inherit
config
lib
pkgs
inputs
;
})
]

19
sw/builders/programs.nix Normal file
View File

@@ -0,0 +1,19 @@
{
config,
lib,
pkgs,
inputs,
...
}:
with lib;
let
cfg = config.ugaif.sw;
basePackages = with pkgs; [
# Build-related packages can be added here if needed
];
in
{
environment.systemPackages = subtractLists cfg.excludePackages (basePackages ++ cfg.extraPackages);
}

24
sw/builders/services.nix Normal file
View File

@@ -0,0 +1,24 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.ugaif.sw;
builderCfg = cfg.builders;
in
mkIf builderCfg.githubRunner.enable {
services.github-runners.${builderCfg.githubRunner.name} = {
enable = true;
url = builderCfg.githubRunner.url;
tokenFile = builderCfg.githubRunner.tokenFile;
extraLabels = builderCfg.githubRunner.extraLabels;
user = builderCfg.githubRunner.user;
workDir = builderCfg.githubRunner.workDir;
replace = true;
};
}

View File

@@ -17,6 +17,12 @@ with lib;
let
cfg = config.ugaif.sw;
# Normalize type to always be a list
swTypes = if isList cfg.type then cfg.type else [ cfg.type ];
# Helper to check if a type is enabled
hasType = type: elem type swTypes;
in
{
imports = [
@@ -29,14 +35,26 @@ in
enable = mkEnableOption "Standard Workstation Configuration";
type = mkOption {
type = types.enum [
"desktop"
"tablet-kiosk"
"headless"
"stateless-kiosk"
type = types.oneOf [
(types.enum [
"desktop"
"tablet-kiosk"
"headless"
"stateless-kiosk"
"builders"
])
(types.listOf (
types.enum [
"desktop"
"tablet-kiosk"
"headless"
"stateless-kiosk"
"builders"
]
))
];
default = "desktop";
description = "Type of system configuration: 'desktop' for normal OS, 'tablet-kiosk' for tablet/kiosk mode.";
description = "Type(s) of system configuration. Can be a single type or a list of types to combine multiple configurations.";
};
extraPackages = mkOption {
@@ -56,6 +74,58 @@ in
default = "https://ha.factory.uga.edu";
description = "URL to open in Chromium kiosk mode.";
};
# Builders-specific options
builders = mkOption {
type = types.submodule {
options = {
githubRunner = {
enable = mkEnableOption "GitHub Actions self-hosted runner";
url = mkOption {
type = types.str;
description = "GitHub repository URL for the runner";
};
tokenFile = mkOption {
type = types.path;
default = "/var/lib/github-runner-token";
description = ''
Path to file containing GitHub PAT token.
Generate at: https://github.com/settings/tokens
The token must have repo access.
'';
};
extraLabels = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Extra labels to identify this runner in workflows";
};
user = mkOption {
type = types.str;
default = "engr-ugaif";
description = "User to run the runner as";
};
workDir = mkOption {
type = types.str;
default = "/var/lib/github-runner";
description = "Working directory for runner";
};
name = mkOption {
type = types.str;
default = "nixos-systems";
description = "Name of the GitHub runner service";
};
};
};
};
default = { };
description = "Builder-specific configuration options";
};
};
config = mkIf cfg.enable (mkMerge [
@@ -80,7 +150,7 @@ in
];
}
# ========== Software Profile Imports ==========
(mkIf (cfg.type == "desktop") (
(mkIf (hasType "desktop") (
import ./desktop {
inherit
config
@@ -90,7 +160,7 @@ in
;
}
))
(mkIf (cfg.type == "tablet-kiosk") (
(mkIf (hasType "tablet-kiosk") (
import ./tablet-kiosk {
inherit
config
@@ -100,7 +170,7 @@ in
;
}
))
(mkIf (cfg.type == "headless") (
(mkIf (hasType "headless") (
import ./headless {
inherit
config
@@ -110,7 +180,7 @@ in
;
}
))
(mkIf (cfg.type == "stateless-kiosk") (
(mkIf (hasType "stateless-kiosk") (
import ./stateless-kiosk {
inherit
config
@@ -120,5 +190,15 @@ in
;
}
))
(mkIf (hasType "builders") (
import ./builders {
inherit
config
lib
pkgs
inputs
;
}
))
]);
}