Merge pull request #2 from UGA-Innovation-Factory/refactor

enable system flake additions
This commit is contained in:
2025-12-09 18:44:07 -05:00
committed by GitHub
4 changed files with 39 additions and 32 deletions

View File

@@ -47,22 +47,36 @@ let
mkHostGroup = { prefix, count, system ? "x86_64-linux", extraModules ? [], deviceOverrides ? {} }:
lib.listToAttrs (map (i: {
name = "${prefix}${toString i}";
value = mkHost {
hostName = "${prefix}${toString i}";
inherit system;
extraModules = extraModules ++
(lib.optional (builtins.hasAttr (toString i) deviceOverrides)
({ ... }:
let
devConf = deviceOverrides.${toString i};
fsConf = builtins.removeAttrs devConf [ "extraUsers" ];
in {
host.filesystem = fsConf;
modules.users.enabledUsers = devConf.extraUsers or [];
}
)
);
};
value =
let
devConf = deviceOverrides.${toString i} or {};
hasOverride = builtins.hasAttr (toString i) deviceOverrides;
# Extract flakeUrl if it exists
externalFlake = if hasOverride && (builtins.hasAttr "flakeUrl" devConf)
then builtins.getFlake devConf.flakeUrl
else null;
# Module from external flake
externalModule = if externalFlake != null
then externalFlake.nixosModules.default
else {};
# Config override module
overrideModule = { ... }:
let
# Remove special keys that are not filesystem options
fsConf = builtins.removeAttrs devConf [ "extraUsers" "flakeUrl" ];
in lib.mkIf hasOverride {
host.filesystem = fsConf;
modules.users.enabledUsers = devConf.extraUsers or [];
};
in
mkHost {
hostName = "${prefix}${toString i}";
inherit system;
extraModules = extraModules ++ [ overrideModule ] ++ (lib.optional (externalFlake != null) externalModule);
};
}) (lib.range 1 count));
# Generate host groups based on the input hosts configuration

View File

@@ -3,7 +3,7 @@ let
userSubmodule = lib.types.submodule {
options = {
isNormalUser = lib.mkOption { type = lib.types.bool; default = true; };
description = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; };
description = lib.mkOption { type = lib.types.str; default = ""; };
extraGroups = lib.mkOption { type = lib.types.listOf lib.types.str; default = []; };
hashedPassword = lib.mkOption { type = lib.types.str; default = "!"; };
extraPackages = lib.mkOption { type = lib.types.listOf lib.types.package; default = []; };
@@ -49,9 +49,7 @@ in
finalPackages = lib.subtractLists user.excludePackages (defaultPackages ++ user.extraPackages);
in
{
inherit (user) isNormalUser extraGroups hashedPassword;
description = if user.description != null then user.description else lib.mkDefault "";
openssh.authorizedKeys.keys = user.opensshKeys;
inherit (user) isNormalUser description extraGroups hashedPassword;
packages = finalPackages;
shell = config.modules.users.shell;
}
@@ -61,14 +59,14 @@ in
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { osConfig = config; };
extraSpecialArgs = { inherit osConfig; };
users =
let
enabledAccounts = lib.filterAttrs (name: _: lib.elem name config.modules.users.enabledUsers) config.modules.users.accounts;
in
lib.mapAttrs (name: user: { ... }: {
imports = user.extraImports ++
imports = user.extraImports ++ [ ../sw/theme.nix ../sw/nvim.nix ] ++
(lib.optional (user.flakeUrl != "") (builtins.getFlake user.flakeUrl).homeManagerModules.default);
home.username = name;
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";

View File

@@ -10,18 +10,17 @@
# Enable specific users for this device index
"1" = { extraUsers = [ "hdh20267" ]; };
"2" = { extraUsers = [ "hdh20267" ]; };
# Example of using an external flake for system configuration:
# "2" = { flakeUrl = "github:user/system-flake"; };
};
};
# Desktop Configuration
# Base specs: NVMe drive, 16G Swap
nix-desktop = {
count = 1;
};
nix-desktop.count = 1;
# Surface Tablet Configuration (Kiosk Mode)
# Base specs: eMMC drive, 8G Swap
nix-surface = {
count = 3;
};
nix-surface.count = 3;
}

View File

@@ -6,21 +6,17 @@
root = {
isNormalUser = false;
hashedPassword = "!";
extraImports = [ ./sw/theme.nix ];
opensshKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBC7xzHxY2BfFUybMvG4wHSF9oEAGzRiLTFEndLvWV/X hdh20267@engr733847d.engr.uga.edu" ];
};
engr-ugaif = {
description = "UGA Innovation Factory";
extraGroups = [ "networkmanager" "wheel" "video" "input" ];
hashedPassword = "$6$El6e2NhPrhVFjbFU$imlGZqUiizWw5fMP/ib0CeboOcFhYjIVb8oR1V1dP2NjDeri3jMoUm4ZABOB2uAF8UEDjAGHhFuZxhtbHg647/";
extraImports = [ ./sw/theme.nix ./sw/nvim.nix ];
opensshKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBC7xzHxY2BfFUybMvG4wHSF9oEAGzRiLTFEndLvWV/X hdh20267@engr733847d.engr.uga.edu" ];
};
hdh20267 = {
description = "Hunter Halloran";
extraGroups = [ "networkmanager" "wheel" ];
homePackages = [ pkgs.ghostty ];
extraImports = [ ./sw/theme.nix ./sw/nvim.nix ];
# Example of using an external flake for configuration:
# flakeUrl = "github:hdh20267/dotfiles";
};