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 for 'nix fmt'
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
# Generate NixOS configurations from hosts/default.nix # Generate NixOS configurations from hosts/default.nix
nixosConfigurations = hosts.nixosConfigurations; nixosConfigurations = hosts.nixosConfigurations;

View File

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

View File

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

View File

@@ -35,7 +35,10 @@
]; ];
services.vscode-server.enable = true; services.vscode-server.enable = true;
system.stateVersion = "25.11"; 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.nixos-wsl.nixosModules.default
inputs.vscode-server.nixosModules.default inputs.vscode-server.nixosModules.default
({ lib, config, ... }: { (
options.ugaif.host.wsl.user = lib.mkOption { { lib, config, ... }:
type = lib.types.str; {
default = "engr-ugaif"; options.ugaif.host.wsl.user = lib.mkOption {
description = "The default user to log in as in WSL."; type = lib.types.str;
}; default = "engr-ugaif";
description = "The default user to log in as in WSL.";
};
config = { config = {
wsl.enable = true; wsl.enable = true;
wsl.defaultUser = config.ugaif.host.wsl.user; wsl.defaultUser = config.ugaif.host.wsl.user;
# Enable the headless software profile
ugaif.sw.enable = true;
ugaif.sw.type = "headless";
# Fix for VS Code Server in WSL if needed, though vscode-server input exists # Enable the headless software profile
services.vscode-server.enable = true; ugaif.sw.enable = true;
ugaif.sw.type = "headless";
# Disable Disko and Bootloader for WSL # Fix for VS Code Server in WSL if needed, though vscode-server input exists
disko.enableConfig = lib.mkForce false; services.vscode-server.enable = true;
boot.loader.systemd-boot.enable = lib.mkForce false;
boot.loader.grub.enable = lib.mkForce false;
# Disable networking for wsl (it manages its own networking) # Disable Disko and Bootloader for WSL
systemd.network.enable = lib.mkForce false; disko.enableConfig = lib.mkForce false;
boot.loader.systemd-boot.enable = lib.mkForce false;
# Provide dummy values for required options from boot.nix boot.loader.grub.enable = lib.mkForce false;
ugaif.host.filesystem.device = "/dev/null";
ugaif.host.filesystem.swapSize = "0G"; # 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.) # 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>` # It exports a set of packages that can be built using `nix build .#<artifact-name>`
let let
@@ -9,7 +14,8 @@ let
# Creates a self-installing ISO for a specific host configuration # Creates a self-installing ISO for a specific host configuration
# This ISO will automatically partition the disk (using disko) and install the system # This ISO will automatically partition the disk (using disko) and install the system
mkInstaller = hostName: mkInstaller =
hostName:
let let
targetConfig = self.nixosConfigurations.${hostName}.config; targetConfig = self.nixosConfigurations.${hostName}.config;
targetSystem = targetConfig.system.build.toplevel; targetSystem = targetConfig.system.build.toplevel;
@@ -18,7 +24,12 @@ let
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = { specialArgs = {
inherit inputs hostName targetSystem diskoScript; inherit
inputs
hostName
targetSystem
diskoScript
;
hostPlatform = system; hostPlatform = system;
}; };
modules = [ modules = [
@@ -29,7 +40,8 @@ let
}; };
# Uses nixos-generators to create artifacts like LXC containers, Proxmox VMA, or Live ISOs # Uses nixos-generators to create artifacts like LXC containers, Proxmox VMA, or Live ISOs
mkGenerator = hostName: format: mkGenerator =
hostName: format:
nixos-generators.nixosGenerate { nixos-generators.nixosGenerate {
inherit system; inherit system;
specialArgs = { inherit inputs; }; specialArgs = { inherit inputs; };
@@ -44,7 +56,8 @@ let
# Creates Netboot (iPXE) artifacts using the native NixOS netboot module # Creates Netboot (iPXE) artifacts using the native NixOS netboot module
# Returns a system configuration that includes the netboot module # Returns a system configuration that includes the netboot module
mkNetboot = hostName: mkNetboot =
hostName:
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = { inherit inputs; }; specialArgs = { inherit inputs; };
@@ -60,66 +73,110 @@ let
hostNames = builtins.attrNames hosts.nixosConfigurations; hostNames = builtins.attrNames hosts.nixosConfigurations;
# Generate installer ISOs for hosts that have "installer-iso" in their buildMethods # Generate installer ISOs for hosts that have "installer-iso" in their buildMethods
installerPackages = lib.listToAttrs (lib.concatMap (name: installerPackages = lib.listToAttrs (
let cfg = hosts.nixosConfigurations.${name}; in lib.concatMap (
if lib.elem "installer-iso" cfg.config.ugaif.host.buildMethods then [{ name:
name = "installer-iso-${name}"; let
value = (mkInstaller name).config.system.build.isoImage; cfg = hosts.nixosConfigurations.${name};
}] else [] in
) hostNames); 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 # Generate Live ISOs for hosts that have "iso" in their buildMethods
isoPackages = lib.listToAttrs (lib.concatMap (name: isoPackages = lib.listToAttrs (
let cfg = hosts.nixosConfigurations.${name}; in lib.concatMap (
if lib.elem "iso" cfg.config.ugaif.host.buildMethods then [{ name:
name = "iso-${name}"; let
value = mkGenerator name "iso"; cfg = hosts.nixosConfigurations.${name};
}] else [] in
) hostNames); 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 # Generate iPXE artifacts (kernel, initrd, script) for hosts that have "ipxe" in their buildMethods
ipxePackages = lib.listToAttrs (lib.concatMap (name: ipxePackages = lib.listToAttrs (
let cfg = hosts.nixosConfigurations.${name}; in lib.concatMap (
if lib.elem "ipxe" cfg.config.ugaif.host.buildMethods then [{ name:
name = "ipxe-${name}"; let
value = cfg = hosts.nixosConfigurations.${name};
let in
build = (mkNetboot name).config.system.build; if lib.elem "ipxe" cfg.config.ugaif.host.buildMethods then
in [
pkgs.symlinkJoin { {
name = "netboot-artifacts-${name}"; name = "ipxe-${name}";
paths = [ value =
build.netbootRamdisk let
build.kernel build = (mkNetboot name).config.system.build;
build.netbootIpxeScript in
]; pkgs.symlinkJoin {
}; name = "netboot-artifacts-${name}";
}] else [] paths = [
) hostNames); build.netbootRamdisk
build.kernel
build.netbootIpxeScript
];
};
}
]
else
[ ]
) hostNames
);
# Generate LXC tarballs for hosts that have "lxc" in their buildMethods # Generate LXC tarballs for hosts that have "lxc" in their buildMethods
lxcPackages = lib.listToAttrs (lib.concatMap (name: lxcPackages = lib.listToAttrs (
let cfg = hosts.nixosConfigurations.${name}; in lib.concatMap (
if lib.elem "lxc" cfg.config.ugaif.host.buildMethods then [{ name:
name = "lxc-${name}"; let
value = cfg = hosts.nixosConfigurations.${name};
if cfg.config.boot.isContainer then in
cfg.config.system.build.tarball if lib.elem "lxc" cfg.config.ugaif.host.buildMethods then
else [
mkGenerator name "lxc"; {
}] else [] name = "lxc-${name}";
) hostNames); value =
if cfg.config.boot.isContainer then cfg.config.system.build.tarball else mkGenerator name "lxc";
}
]
else
[ ]
) hostNames
);
proxmoxPackages = lib.listToAttrs (lib.concatMap (name: proxmoxPackages = lib.listToAttrs (
let cfg = hosts.nixosConfigurations.${name}; in lib.concatMap (
if lib.elem "proxmox" cfg.config.ugaif.host.buildMethods then [{ name:
name = "proxmox-${name}"; let
value = cfg = hosts.nixosConfigurations.${name};
if cfg.config.boot.isContainer then in
cfg.config.system.build.tarball if lib.elem "proxmox" cfg.config.ugaif.host.buildMethods then
else [
mkGenerator name "proxmox"; {
}] else [] name = "proxmox-${name}";
) hostNames); value =
if cfg.config.boot.isContainer then cfg.config.system.build.tarball else mkGenerator name "proxmox";
}
]
else
[ ]
) hostNames
);
in in
installerPackages // isoPackages // ipxePackages // lxcPackages // proxmoxPackages installerPackages // isoPackages // ipxePackages // lxcPackages // proxmoxPackages

View File

@@ -1,7 +1,17 @@
# This module defines a systemd service that automatically installs NixOS to the disk. # This module defines a systemd service that automatically installs NixOS to the disk.
# It is intended to be used in an installation ISO. # 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. # 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 = [ environment.systemPackages = [
pkgs.git pkgs.git
@@ -14,7 +24,10 @@
systemd.services.auto-install = { systemd.services.auto-install = {
description = "Automatic NixOS install for ${hostName}"; 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" ]; wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];

View File

@@ -9,15 +9,35 @@
}: }:
lib.mkMerge [ lib.mkMerge [
(import ./kiosk-browser.nix { (import ./kiosk-browser.nix {
inherit config lib pkgs inputs; inherit
config
lib
pkgs
inputs
;
}) })
(import ./services.nix { (import ./services.nix {
inherit config lib pkgs inputs; inherit
config
lib
pkgs
inputs
;
}) })
(import ./net.nix { (import ./net.nix {
inherit config lib pkgs inputs; inherit
config
lib
pkgs
inputs
;
}) })
(import ./programs.nix { (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. # 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. # It includes a startup script that determines the kiosk URL based on the machine's MAC address.
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder; macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder; macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;
shellCases = 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"; description = "System daemon to one-shot run the Nix updater from fleet flake as root";
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
ExecStart = ExecStart =
let let
hosts = config.ugaif.sw.remoteBuild.hosts; hosts = config.ugaif.sw.remoteBuild.hosts;
builders = lib.strings.concatMapStringsSep ";" (x: x) hosts; builders = lib.strings.concatMapStringsSep ";" (x: x) hosts;
rebuildCmd = "${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --refresh"; rebuildCmd = "${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --refresh";
source = "--flake github:UGA-Innovation-Factory/nixos-systems"; source = "--flake github:UGA-Innovation-Factory/nixos-systems";
remoteBuildFlags = if config.ugaif.sw.remoteBuild.enable remoteBuildFlags = if config.ugaif.sw.remoteBuild.enable then ''--builders "${builders}"'' else "";
then
''--builders "${builders}"''
else "";
in in
"${rebuildCmd} ${remoteBuildFlags} --print-build-logs ${source}#${config.networking.hostName}"; "${rebuildCmd} ${remoteBuildFlags} --print-build-logs ${source}#${config.networking.hostName}";
User = "root"; User = "root";
Group = "root"; Group = "root";
TimeoutStartSec = "0"; TimeoutStartSec = "0";