fix: Remove deprecated uses with external flakes and more consistent ugaif namespace usage

This commit is contained in:
Hunter Halloran
2025-12-17 09:15:11 -05:00
parent 90b3f21472
commit f75b0be971
8 changed files with 55 additions and 69 deletions

View File

@@ -91,7 +91,7 @@ ugaif.forUser = "username"; # Convenience: enable user + set WSL user
#### Adding a New User
1. Edit `users.nix` to add user definition under `ugaif.users.accounts`
2. Enable user in `inventory.nix` via `extraUsers` or `ugaif.users.enabledUsers`
2. Enable user in `inventory.nix` via `ugaif.users.username.enable = true` or use `ugaif.forUser = "username"`
3. Test: `nix flake check`
#### Adding a New Host

View File

@@ -18,7 +18,7 @@
default = null;
description = ''
Convenience option to configure a host for a specific user.
Automatically adds the user to extraUsers and sets wslUser for WSL hosts.
Automatically enables the user (sets ugaif.users.username.enable = true).
Value should be a username from ugaif.users.accounts.
'';
};

View File

@@ -53,13 +53,13 @@ let
if (user ? home && user.home != null) then
let
homePath =
if builtins.isAttrs user.home && user.home ? outPath then
user.home.outPath
else
user.home;
if builtins.isAttrs user.home && user.home ? outPath then user.home.outPath else user.home;
nixosModulePath = homePath + "/nixos.nix";
in
if (builtins.isPath homePath || (builtins.isString homePath && lib.hasPrefix "/" homePath)) && builtins.pathExists nixosModulePath then
if
(builtins.isPath homePath || (builtins.isString homePath && lib.hasPrefix "/" homePath))
&& builtins.pathExists nixosModulePath
then
import nixosModulePath { inherit inputs; }
else
{ }
@@ -75,19 +75,9 @@ let
else
throw "Host type '${hostType}' not found in hosts/types/";
# External flake override if specified
externalFlakeModule =
if configOverrides ? flakeUrl then
(builtins.getFlake configOverrides.flakeUrl).nixosModules.default
else
{ };
# External module from fetchGit/fetchurl
externalPathModule =
if externalModulePath != null then
import externalModulePath { inherit inputs; }
else
{ };
if externalModulePath != null then import externalModulePath { inherit inputs; } else { };
# Config override module - translate special keys to ugaif options
overrideModule =
@@ -99,26 +89,11 @@ let
"devices"
"overrides"
"defaultCount"
"extraUsers"
"flakeUrl"
"hostname"
"buildMethods"
"wslUser"
];
specialConfig = lib.mkMerge [
(lib.optionalAttrs (configOverrides ? extraUsers) {
# Enable each user in the extraUsers list
ugaif.users = lib.genAttrs configOverrides.extraUsers (_: {
enable = true;
});
})
(lib.optionalAttrs (configOverrides ? buildMethods) {
ugaif.host.buildMethods = configOverrides.buildMethods;
})
(lib.optionalAttrs (configOverrides ? wslUser) {
ugaif.host.wsl.user = configOverrides.wslUser;
})
];
specialConfig = lib.optionalAttrs (configOverrides ? buildMethods) {
ugaif.host.buildMethods = configOverrides.buildMethods;
};
in
{
config = lib.mkMerge [
@@ -134,7 +109,6 @@ let
overrideModule
{ networking.hostName = hostName; }
]
++ lib.optional (configOverrides ? flakeUrl) externalFlakeModule
++ lib.optional (externalModulePath != null) externalPathModule;
in
{
@@ -208,7 +182,8 @@ let
# If external module, we use base config + overrides as the config
# and pass the module path separately
actualConfig = if isExternalModule then (lib.recursiveUpdate baseConfig overrides) else deviceConfig;
actualConfig =
if isExternalModule then (lib.recursiveUpdate baseConfig overrides) else deviceConfig;
# Merge: base config -> overrides -> device-specific config (only if not external module)
mergedConfig =
@@ -236,7 +211,12 @@ let
{
name = hostName;
value = mkHost {
inherit hostName system hostType externalModulePath;
inherit
hostName
system
hostType
externalModulePath
;
configOverrides = mergedConfig;
};
}

View File

@@ -50,7 +50,13 @@ let
default = [ ];
};
home = lib.mkOption {
type = lib.types.nullOr (lib.types.oneOf [ lib.types.path lib.types.package lib.types.attrs ]);
type = lib.types.nullOr (
lib.types.oneOf [
lib.types.path
lib.types.package
lib.types.attrs
]
);
default = null;
description = ''
External home-manager configuration. Can be:
@@ -150,19 +156,22 @@ in
# Extract path from fetchGit/fetchTarball if needed
externalHomePath =
if hasExternalHome then
if builtins.isAttrs user.home && user.home ? outPath then
user.home.outPath
else
user.home
if builtins.isAttrs user.home && user.home ? outPath then user.home.outPath else user.home
else
null;
# Import external module if it's a path
externalHomeModule =
if externalHomePath != null && (builtins.isPath externalHomePath || (builtins.isString externalHomePath && lib.hasPrefix "/" externalHomePath)) then
if
externalHomePath != null
&& (
builtins.isPath externalHomePath
|| (builtins.isString externalHomePath && lib.hasPrefix "/" externalHomePath)
)
then
import (externalHomePath + "/home.nix") { inherit inputs; }
else if builtins.isAttrs user.home && !(user.home ? outPath) then
user.home # Direct attrset configuration
user.home # Direct attrset configuration
else
{ };

View File

@@ -41,7 +41,5 @@
# Use ugaif.sw.type to select profile: "desktop", "tablet-kiosk", "headless", "stateless-kiosk"
# Use ugaif.sw.extraPackages to add additional packages
# Use ugaif.sw.kioskUrl to set kiosk mode URL
sw =
{ inputs, ... }@args:
(import ../sw/default.nix (args // { inherit inputs; }));
sw = { inputs, ... }@args: (import ../sw/default.nix (args // { inherit inputs; }));
}

View File

@@ -35,13 +35,13 @@
#
# # Common config for all devices in this group
# overrides = {
# extraUsers = [ "user1" ]; # Applied to all devices in this group
# ugaif.users.user1.enable = true; # Applied to all devices in this group
# # ... any other config
# };
# };
#
# Convenience options:
# ugaif.forUser = "username"; # Automatically adds user to extraUsers and sets wslUser for WSL
# ugaif.forUser = "username"; # Automatically enables user (sets ugaif.users.username.enable = true)
#
# External modules (instead of config):
# Device values can be either a config attrset OR a fetchGit/fetchurl call
@@ -56,7 +56,7 @@
# };
# "laptop" = {
# devices = 5;
# overrides.extraUsers = [ "student" ]; # All 5 laptops get this user
# overrides.ugaif.users.student.enable = true; # All 5 laptops get this user
# };
# "wsl" = {
# devices."alice".ugaif.forUser = "alice123"; # Sets up for user alice123
@@ -71,7 +71,7 @@
# Both get hdh20267 user via overrides
nix-laptop = {
devices = 2;
overrides.extraUsers = [ "hdh20267" ];
overrides.ugaif.users.hdh20267.enable = true;
};
# ========== Desktop ==========
@@ -149,4 +149,3 @@
# };
# };
}

View File

@@ -22,7 +22,7 @@
config,
lib,
pkgs,
osConfig, # Access to the OS-level config
osConfig, # Access to the OS-level config
...
}:
@@ -30,8 +30,8 @@
# ========== Home Manager Configuration ==========
# User identity (required)
home.username = lib.mkDefault config.home.username; # Set by system
home.homeDirectory = lib.mkDefault config.home.homeDirectory; # Set by system
home.username = lib.mkDefault config.home.username; # Set by system
home.homeDirectory = lib.mkDefault config.home.homeDirectory; # Set by system
home.stateVersion = lib.mkDefault "25.11";
# ========== Packages ==========