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 = { devices = {
"nix-builder" = { "nix-builder" = {
# GitHub Actions self-hosted runner configuration # GitHub Actions self-hosted runner configuration
# The runner will register itself with the repository on first start ugaif.sw = {
services.github-runners.nixos-systems = { type = [
enable = true; "headless"
url = "https://github.com/UGA-Innovation-Factory/nixos-systems"; "builders"
# Token file must be created manually at this path with a GitHub PAT ];
# that has repo access. Generate at: https://github.com/settings/tokens builders.githubRunner = {
# echo "YOUR_TOKEN_HERE" | sudo tee /var/lib/github-runner-token > /dev/null enable = true;
tokenFile = "/var/lib/github-runner-token"; url = "https://github.com/UGA-Innovation-Factory/nixos-systems";
# Labels to identify this runner in workflows # Token file must be created manually at this path with a GitHub PAT
extraLabels = [ "nix-builder" ]; # that has repo access. Generate at: https://github.com/settings/tokens
# User to run the runner as # echo "YOUR_TOKEN_HERE" | sudo tee /var/lib/github-runner-token > /dev/null
user = "engr-ugaif"; tokenFile = "/var/lib/github-runner-token";
# Working directory for runner # Labels to identify this runner in workflows
workDir = "/var/lib/github-runner"; extraLabels = [ "nix-builder" ];
# Replace runner on config changes # User to run the runner as
replace = true; user = "engr-ugaif";
# Working directory for runner
workDir = "/var/lib/github-runner";
# Runner service name
name = "nixos-systems";
};
}; };
}; };
"usda-dash" = builtins.fetchGit { "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 let
cfg = config.ugaif.sw; 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 in
{ {
imports = [ imports = [
@@ -29,14 +35,26 @@ in
enable = mkEnableOption "Standard Workstation Configuration"; enable = mkEnableOption "Standard Workstation Configuration";
type = mkOption { type = mkOption {
type = types.enum [ type = types.oneOf [
"desktop" (types.enum [
"tablet-kiosk" "desktop"
"headless" "tablet-kiosk"
"stateless-kiosk" "headless"
"stateless-kiosk"
"builders"
])
(types.listOf (
types.enum [
"desktop"
"tablet-kiosk"
"headless"
"stateless-kiosk"
"builders"
]
))
]; ];
default = "desktop"; 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 { extraPackages = mkOption {
@@ -56,6 +74,58 @@ in
default = "https://ha.factory.uga.edu"; default = "https://ha.factory.uga.edu";
description = "URL to open in Chromium kiosk mode."; 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 [ config = mkIf cfg.enable (mkMerge [
@@ -80,7 +150,7 @@ in
]; ];
} }
# ========== Software Profile Imports ========== # ========== Software Profile Imports ==========
(mkIf (cfg.type == "desktop") ( (mkIf (hasType "desktop") (
import ./desktop { import ./desktop {
inherit inherit
config config
@@ -90,7 +160,7 @@ in
; ;
} }
)) ))
(mkIf (cfg.type == "tablet-kiosk") ( (mkIf (hasType "tablet-kiosk") (
import ./tablet-kiosk { import ./tablet-kiosk {
inherit inherit
config config
@@ -100,7 +170,7 @@ in
; ;
} }
)) ))
(mkIf (cfg.type == "headless") ( (mkIf (hasType "headless") (
import ./headless { import ./headless {
inherit inherit
config config
@@ -110,7 +180,7 @@ in
; ;
} }
)) ))
(mkIf (cfg.type == "stateless-kiosk") ( (mkIf (hasType "stateless-kiosk") (
import ./stateless-kiosk { import ./stateless-kiosk {
inherit inherit
config config
@@ -120,5 +190,15 @@ in
; ;
} }
)) ))
(mkIf (hasType "builders") (
import ./builders {
inherit
config
lib
pkgs
inputs
;
}
))
]); ]);
} }