Merge pull request #2 from UGA-Innovation-Factory/refactor
enable system flake additions
This commit is contained in:
@@ -47,22 +47,36 @@ let
|
|||||||
mkHostGroup = { prefix, count, system ? "x86_64-linux", extraModules ? [], deviceOverrides ? {} }:
|
mkHostGroup = { prefix, count, system ? "x86_64-linux", extraModules ? [], deviceOverrides ? {} }:
|
||||||
lib.listToAttrs (map (i: {
|
lib.listToAttrs (map (i: {
|
||||||
name = "${prefix}${toString i}";
|
name = "${prefix}${toString i}";
|
||||||
value = mkHost {
|
value =
|
||||||
hostName = "${prefix}${toString i}";
|
let
|
||||||
inherit system;
|
devConf = deviceOverrides.${toString i} or {};
|
||||||
extraModules = extraModules ++
|
hasOverride = builtins.hasAttr (toString i) deviceOverrides;
|
||||||
(lib.optional (builtins.hasAttr (toString i) deviceOverrides)
|
|
||||||
({ ... }:
|
# Extract flakeUrl if it exists
|
||||||
let
|
externalFlake = if hasOverride && (builtins.hasAttr "flakeUrl" devConf)
|
||||||
devConf = deviceOverrides.${toString i};
|
then builtins.getFlake devConf.flakeUrl
|
||||||
fsConf = builtins.removeAttrs devConf [ "extraUsers" ];
|
else null;
|
||||||
in {
|
|
||||||
host.filesystem = fsConf;
|
# Module from external flake
|
||||||
modules.users.enabledUsers = devConf.extraUsers or [];
|
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));
|
}) (lib.range 1 count));
|
||||||
|
|
||||||
# Generate host groups based on the input hosts configuration
|
# Generate host groups based on the input hosts configuration
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ let
|
|||||||
userSubmodule = lib.types.submodule {
|
userSubmodule = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
isNormalUser = lib.mkOption { type = lib.types.bool; default = true; };
|
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 = []; };
|
extraGroups = lib.mkOption { type = lib.types.listOf lib.types.str; default = []; };
|
||||||
hashedPassword = lib.mkOption { type = lib.types.str; default = "!"; };
|
hashedPassword = lib.mkOption { type = lib.types.str; default = "!"; };
|
||||||
extraPackages = lib.mkOption { type = lib.types.listOf lib.types.package; 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);
|
finalPackages = lib.subtractLists user.excludePackages (defaultPackages ++ user.extraPackages);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit (user) isNormalUser extraGroups hashedPassword;
|
inherit (user) isNormalUser description extraGroups hashedPassword;
|
||||||
description = if user.description != null then user.description else lib.mkDefault "";
|
|
||||||
openssh.authorizedKeys.keys = user.opensshKeys;
|
|
||||||
packages = finalPackages;
|
packages = finalPackages;
|
||||||
shell = config.modules.users.shell;
|
shell = config.modules.users.shell;
|
||||||
}
|
}
|
||||||
@@ -61,14 +59,14 @@ in
|
|||||||
home-manager = {
|
home-manager = {
|
||||||
useGlobalPkgs = true;
|
useGlobalPkgs = true;
|
||||||
useUserPackages = true;
|
useUserPackages = true;
|
||||||
extraSpecialArgs = { osConfig = config; };
|
extraSpecialArgs = { inherit osConfig; };
|
||||||
|
|
||||||
users =
|
users =
|
||||||
let
|
let
|
||||||
enabledAccounts = lib.filterAttrs (name: _: lib.elem name config.modules.users.enabledUsers) config.modules.users.accounts;
|
enabledAccounts = lib.filterAttrs (name: _: lib.elem name config.modules.users.enabledUsers) config.modules.users.accounts;
|
||||||
in
|
in
|
||||||
lib.mapAttrs (name: user: { ... }: {
|
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);
|
(lib.optional (user.flakeUrl != "") (builtins.getFlake user.flakeUrl).homeManagerModules.default);
|
||||||
home.username = name;
|
home.username = name;
|
||||||
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
|
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
|
||||||
|
|||||||
@@ -10,18 +10,17 @@
|
|||||||
# Enable specific users for this device index
|
# Enable specific users for this device index
|
||||||
"1" = { extraUsers = [ "hdh20267" ]; };
|
"1" = { extraUsers = [ "hdh20267" ]; };
|
||||||
"2" = { extraUsers = [ "hdh20267" ]; };
|
"2" = { extraUsers = [ "hdh20267" ]; };
|
||||||
|
|
||||||
|
# Example of using an external flake for system configuration:
|
||||||
|
# "2" = { flakeUrl = "github:user/system-flake"; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Desktop Configuration
|
# Desktop Configuration
|
||||||
# Base specs: NVMe drive, 16G Swap
|
# Base specs: NVMe drive, 16G Swap
|
||||||
nix-desktop = {
|
nix-desktop.count = 1;
|
||||||
count = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Surface Tablet Configuration (Kiosk Mode)
|
# Surface Tablet Configuration (Kiosk Mode)
|
||||||
# Base specs: eMMC drive, 8G Swap
|
# Base specs: eMMC drive, 8G Swap
|
||||||
nix-surface = {
|
nix-surface.count = 3;
|
||||||
count = 3;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,21 +6,17 @@
|
|||||||
root = {
|
root = {
|
||||||
isNormalUser = false;
|
isNormalUser = false;
|
||||||
hashedPassword = "!";
|
hashedPassword = "!";
|
||||||
extraImports = [ ./sw/theme.nix ];
|
|
||||||
opensshKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBC7xzHxY2BfFUybMvG4wHSF9oEAGzRiLTFEndLvWV/X hdh20267@engr733847d.engr.uga.edu" ];
|
|
||||||
};
|
};
|
||||||
engr-ugaif = {
|
engr-ugaif = {
|
||||||
description = "UGA Innovation Factory";
|
description = "UGA Innovation Factory";
|
||||||
extraGroups = [ "networkmanager" "wheel" "video" "input" ];
|
extraGroups = [ "networkmanager" "wheel" "video" "input" ];
|
||||||
hashedPassword = "$6$El6e2NhPrhVFjbFU$imlGZqUiizWw5fMP/ib0CeboOcFhYjIVb8oR1V1dP2NjDeri3jMoUm4ZABOB2uAF8UEDjAGHhFuZxhtbHg647/";
|
hashedPassword = "$6$El6e2NhPrhVFjbFU$imlGZqUiizWw5fMP/ib0CeboOcFhYjIVb8oR1V1dP2NjDeri3jMoUm4ZABOB2uAF8UEDjAGHhFuZxhtbHg647/";
|
||||||
extraImports = [ ./sw/theme.nix ./sw/nvim.nix ];
|
|
||||||
opensshKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBC7xzHxY2BfFUybMvG4wHSF9oEAGzRiLTFEndLvWV/X hdh20267@engr733847d.engr.uga.edu" ];
|
opensshKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBC7xzHxY2BfFUybMvG4wHSF9oEAGzRiLTFEndLvWV/X hdh20267@engr733847d.engr.uga.edu" ];
|
||||||
};
|
};
|
||||||
hdh20267 = {
|
hdh20267 = {
|
||||||
description = "Hunter Halloran";
|
description = "Hunter Halloran";
|
||||||
extraGroups = [ "networkmanager" "wheel" ];
|
extraGroups = [ "networkmanager" "wheel" ];
|
||||||
homePackages = [ pkgs.ghostty ];
|
homePackages = [ pkgs.ghostty ];
|
||||||
extraImports = [ ./sw/theme.nix ./sw/nvim.nix ];
|
|
||||||
# Example of using an external flake for configuration:
|
# Example of using an external flake for configuration:
|
||||||
# flakeUrl = "github:hdh20267/dotfiles";
|
# flakeUrl = "github:hdh20267/dotfiles";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user