run nix fmt

This commit is contained in:
UGA Innovation Factory
2025-12-15 15:57:56 -05:00
parent 19737c2adb
commit 140648cd8f
14 changed files with 236 additions and 115 deletions

View File

@@ -85,7 +85,7 @@
{
# Formatter for 'nix fmt'
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
# Generate NixOS configurations from hosts/default.nix
nixosConfigurations = hosts.nixosConfigurations;

View File

@@ -70,7 +70,7 @@ let
else
{ }
) accounts;
allModules =
commonModules
++ userFlakeModules

View File

@@ -33,8 +33,11 @@
# Ephemeral setup: No swap, no disk
ugaif.host.filesystem.swapSize = lib.mkForce "0G";
ugaif.host.filesystem.device = lib.mkForce "/dev/null"; # Dummy device
ugaif.host.buildMethods = lib.mkDefault [ "iso" "ipxe" ];
ugaif.host.buildMethods = lib.mkDefault [
"iso"
"ipxe"
];
# Disable Disko config since we are running from RAM/ISO
disko.enableConfig = lib.mkForce false;
@@ -42,7 +45,11 @@
fileSystems."/" = {
device = "none";
fsType = "tmpfs";
options = [ "defaults" "size=50%" "mode=755" ];
options = [
"defaults"
"size=50%"
"mode=755"
];
};
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

View File

@@ -35,7 +35,10 @@
];
services.vscode-server.enable = true;
system.stateVersion = "25.11";
ugaif.host.buildMethods = lib.mkDefault [ "lxc" "proxmox" ];
ugaif.host.buildMethods = lib.mkDefault [
"lxc"
"proxmox"
];
}
)
{

View File

@@ -2,35 +2,38 @@
[
inputs.nixos-wsl.nixosModules.default
inputs.vscode-server.nixosModules.default
({ lib, config, ... }: {
options.ugaif.host.wsl.user = lib.mkOption {
type = lib.types.str;
default = "engr-ugaif";
description = "The default user to log in as in WSL.";
};
(
{ lib, config, ... }:
{
options.ugaif.host.wsl.user = lib.mkOption {
type = lib.types.str;
default = "engr-ugaif";
description = "The default user to log in as in WSL.";
};
config = {
wsl.enable = true;
wsl.defaultUser = config.ugaif.host.wsl.user;
# Enable the headless software profile
ugaif.sw.enable = true;
ugaif.sw.type = "headless";
config = {
wsl.enable = true;
wsl.defaultUser = config.ugaif.host.wsl.user;
# Fix for VS Code Server in WSL if needed, though vscode-server input exists
services.vscode-server.enable = true;
# Enable the headless software profile
ugaif.sw.enable = true;
ugaif.sw.type = "headless";
# Disable Disko and Bootloader for WSL
disko.enableConfig = lib.mkForce false;
boot.loader.systemd-boot.enable = lib.mkForce false;
boot.loader.grub.enable = lib.mkForce false;
# Fix for VS Code Server in WSL if needed, though vscode-server input exists
services.vscode-server.enable = true;
# Disable networking for wsl (it manages its own networking)
systemd.network.enable = lib.mkForce false;
# Provide dummy values for required options from boot.nix
ugaif.host.filesystem.device = "/dev/null";
ugaif.host.filesystem.swapSize = "0G";
};
})
# Disable Disko and Bootloader for WSL
disko.enableConfig = lib.mkForce false;
boot.loader.systemd-boot.enable = lib.mkForce false;
boot.loader.grub.enable = lib.mkForce false;
# Disable networking for wsl (it manages its own networking)
systemd.network.enable = lib.mkForce false;
# Provide dummy values for required options from boot.nix
ugaif.host.filesystem.device = "/dev/null";
ugaif.host.filesystem.swapSize = "0G";
};
}
)
]

View File

@@ -1,4 +1,9 @@
{ inputs, hosts, self, system }:
{
inputs,
hosts,
self,
system,
}:
# This file defines the logic for generating various build artifacts (ISOs, Netboot, LXC, etc.)
# It exports a set of packages that can be built using `nix build .#<artifact-name>`
let
@@ -9,7 +14,8 @@ let
# Creates a self-installing ISO for a specific host configuration
# This ISO will automatically partition the disk (using disko) and install the system
mkInstaller = hostName:
mkInstaller =
hostName:
let
targetConfig = self.nixosConfigurations.${hostName}.config;
targetSystem = targetConfig.system.build.toplevel;
@@ -18,7 +24,12 @@ let
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs hostName targetSystem diskoScript;
inherit
inputs
hostName
targetSystem
diskoScript
;
hostPlatform = system;
};
modules = [
@@ -29,7 +40,8 @@ let
};
# Uses nixos-generators to create artifacts like LXC containers, Proxmox VMA, or Live ISOs
mkGenerator = hostName: format:
mkGenerator =
hostName: format:
nixos-generators.nixosGenerate {
inherit system;
specialArgs = { inherit inputs; };
@@ -44,7 +56,8 @@ let
# Creates Netboot (iPXE) artifacts using the native NixOS netboot module
# Returns a system configuration that includes the netboot module
mkNetboot = hostName:
mkNetboot =
hostName:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
@@ -60,66 +73,110 @@ let
hostNames = builtins.attrNames hosts.nixosConfigurations;
# Generate installer ISOs for hosts that have "installer-iso" in their buildMethods
installerPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "installer-iso" cfg.config.ugaif.host.buildMethods then [{
name = "installer-iso-${name}";
value = (mkInstaller name).config.system.build.isoImage;
}] else []
) hostNames);
installerPackages = lib.listToAttrs (
lib.concatMap (
name:
let
cfg = hosts.nixosConfigurations.${name};
in
if lib.elem "installer-iso" cfg.config.ugaif.host.buildMethods then
[
{
name = "installer-iso-${name}";
value = (mkInstaller name).config.system.build.isoImage;
}
]
else
[ ]
) hostNames
);
# Generate Live ISOs for hosts that have "iso" in their buildMethods
isoPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "iso" cfg.config.ugaif.host.buildMethods then [{
name = "iso-${name}";
value = mkGenerator name "iso";
}] else []
) hostNames);
isoPackages = lib.listToAttrs (
lib.concatMap (
name:
let
cfg = hosts.nixosConfigurations.${name};
in
if lib.elem "iso" cfg.config.ugaif.host.buildMethods then
[
{
name = "iso-${name}";
value = mkGenerator name "iso";
}
]
else
[ ]
) hostNames
);
# Generate iPXE artifacts (kernel, initrd, script) for hosts that have "ipxe" in their buildMethods
ipxePackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "ipxe" cfg.config.ugaif.host.buildMethods then [{
name = "ipxe-${name}";
value =
let
build = (mkNetboot name).config.system.build;
in
pkgs.symlinkJoin {
name = "netboot-artifacts-${name}";
paths = [
build.netbootRamdisk
build.kernel
build.netbootIpxeScript
];
};
}] else []
) hostNames);
ipxePackages = lib.listToAttrs (
lib.concatMap (
name:
let
cfg = hosts.nixosConfigurations.${name};
in
if lib.elem "ipxe" cfg.config.ugaif.host.buildMethods then
[
{
name = "ipxe-${name}";
value =
let
build = (mkNetboot name).config.system.build;
in
pkgs.symlinkJoin {
name = "netboot-artifacts-${name}";
paths = [
build.netbootRamdisk
build.kernel
build.netbootIpxeScript
];
};
}
]
else
[ ]
) hostNames
);
# Generate LXC tarballs for hosts that have "lxc" in their buildMethods
lxcPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "lxc" cfg.config.ugaif.host.buildMethods then [{
name = "lxc-${name}";
value =
if cfg.config.boot.isContainer then
cfg.config.system.build.tarball
else
mkGenerator name "lxc";
}] else []
) hostNames);
lxcPackages = lib.listToAttrs (
lib.concatMap (
name:
let
cfg = hosts.nixosConfigurations.${name};
in
if lib.elem "lxc" cfg.config.ugaif.host.buildMethods then
[
{
name = "lxc-${name}";
value =
if cfg.config.boot.isContainer then cfg.config.system.build.tarball else mkGenerator name "lxc";
}
]
else
[ ]
) hostNames
);
proxmoxPackages = lib.listToAttrs (lib.concatMap (name:
let cfg = hosts.nixosConfigurations.${name}; in
if lib.elem "proxmox" cfg.config.ugaif.host.buildMethods then [{
name = "proxmox-${name}";
value =
if cfg.config.boot.isContainer then
cfg.config.system.build.tarball
else
mkGenerator name "proxmox";
}] else []
) hostNames);
proxmoxPackages = lib.listToAttrs (
lib.concatMap (
name:
let
cfg = hosts.nixosConfigurations.${name};
in
if lib.elem "proxmox" cfg.config.ugaif.host.buildMethods then
[
{
name = "proxmox-${name}";
value =
if cfg.config.boot.isContainer then cfg.config.system.build.tarball else mkGenerator name "proxmox";
}
]
else
[ ]
) hostNames
);
in
installerPackages // isoPackages // ipxePackages // lxcPackages // proxmoxPackages

View File

@@ -1,7 +1,17 @@
# This module defines a systemd service that automatically installs NixOS to the disk.
# It is intended to be used in an installation ISO.
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
{ config, lib, pkgs, inputs, hostName, hostPlatform, targetSystem, diskoScript, ... }:
{
config,
lib,
pkgs,
inputs,
hostName,
hostPlatform,
targetSystem,
diskoScript,
...
}:
{
environment.systemPackages = [
pkgs.git
@@ -14,7 +24,10 @@
systemd.services.auto-install = {
description = "Automatic NixOS install for ${hostName}";
after = [ "network-online.target" "systemd-udev-settle.service" ];
after = [
"network-online.target"
"systemd-udev-settle.service"
];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];

View File

@@ -9,15 +9,35 @@
}:
lib.mkMerge [
(import ./kiosk-browser.nix {
inherit config lib pkgs inputs;
inherit
config
lib
pkgs
inputs
;
})
(import ./services.nix {
inherit config lib pkgs inputs;
inherit
config
lib
pkgs
inputs
;
})
(import ./net.nix {
inherit config lib pkgs inputs;
inherit
config
lib
pkgs
inputs
;
})
(import ./programs.nix {
inherit config lib pkgs inputs;
inherit
config
lib
pkgs
inputs
;
})
]

View File

@@ -1,7 +1,11 @@
# This module configures Chromium for kiosk mode under Sway.
# It includes a startup script that determines the kiosk URL based on the machine's MAC address.
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;

View File

@@ -13,15 +13,16 @@ let
# varName: the shell variable to assign
# prefix: optional string to prepend to the value (default: "")
# attrset: attribute set to use (default: hostmap)
macCaseBuilder = {
varName,
prefix ? "",
attrset ? hostmap
}:
macCaseBuilder =
{
varName,
prefix ? "",
attrset ? hostmap,
}:
lib.concatStringsSep "\n" (
lib.mapAttrsToList (mac: val: " ${mac}) ${varName}=${prefix}${val} ;;") attrset
);
in
in
{
inherit hostmap macCaseBuilder;
}

View File

@@ -1,5 +1,11 @@
# This module configures the network for the stateless kiosk using base networking (no systemd-networkd).
{ config, lib, pkgs, inputs, ... }:
{
config,
lib,
pkgs,
inputs,
...
}:
{
networking = {
useNetworkd = false;

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
programs.sway = {
enable = true;

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;
shellCases = macCaseBuilder {

View File

@@ -62,18 +62,15 @@ with lib;
description = "System daemon to one-shot run the Nix updater from fleet flake as root";
serviceConfig = {
Type = "oneshot";
ExecStart =
ExecStart =
let
hosts = config.ugaif.sw.remoteBuild.hosts;
builders = lib.strings.concatMapStringsSep ";" (x: x) hosts;
rebuildCmd = "${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --refresh";
source = "--flake github:UGA-Innovation-Factory/nixos-systems";
remoteBuildFlags = if config.ugaif.sw.remoteBuild.enable
then
''--builders "${builders}"''
else "";
remoteBuildFlags = if config.ugaif.sw.remoteBuild.enable then ''--builders "${builders}"'' else "";
in
"${rebuildCmd} ${remoteBuildFlags} --print-build-logs ${source}#${config.networking.hostName}";
"${rebuildCmd} ${remoteBuildFlags} --print-build-logs ${source}#${config.networking.hostName}";
User = "root";
Group = "root";
TimeoutStartSec = "0";