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 b43e457edc
commit c7c8101b81
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 #### Adding a New User
1. Edit `users.nix` to add user definition under `ugaif.users.accounts` 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` 3. Test: `nix flake check`
#### Adding a New Host #### Adding a New Host

View File

@@ -18,7 +18,7 @@
default = null; default = null;
description = '' description = ''
Convenience option to configure a host for a specific user. 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. Value should be a username from ugaif.users.accounts.
''; '';
}; };

View File

@@ -52,14 +52,14 @@ let
name: user: name: user:
if (user ? home && user.home != null) then if (user ? home && user.home != null) then
let let
homePath = homePath =
if builtins.isAttrs user.home && user.home ? outPath then if builtins.isAttrs user.home && user.home ? outPath then user.home.outPath else user.home;
user.home.outPath
else
user.home;
nixosModulePath = homePath + "/nixos.nix"; nixosModulePath = homePath + "/nixos.nix";
in 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; } import nixosModulePath { inherit inputs; }
else else
{ } { }
@@ -75,19 +75,9 @@ let
else else
throw "Host type '${hostType}' not found in hosts/types/"; 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 # External module from fetchGit/fetchurl
externalPathModule = externalPathModule =
if externalModulePath != null then if externalModulePath != null then import externalModulePath { inherit inputs; } else { };
import externalModulePath { inherit inputs; }
else
{ };
# Config override module - translate special keys to ugaif options # Config override module - translate special keys to ugaif options
overrideModule = overrideModule =
@@ -99,26 +89,11 @@ let
"devices" "devices"
"overrides" "overrides"
"defaultCount" "defaultCount"
"extraUsers"
"flakeUrl"
"hostname"
"buildMethods" "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 in
{ {
config = lib.mkMerge [ config = lib.mkMerge [
@@ -134,7 +109,6 @@ let
overrideModule overrideModule
{ networking.hostName = hostName; } { networking.hostName = hostName; }
] ]
++ lib.optional (configOverrides ? flakeUrl) externalFlakeModule
++ lib.optional (externalModulePath != null) externalPathModule; ++ lib.optional (externalModulePath != null) externalPathModule;
in in
{ {
@@ -208,7 +182,8 @@ let
# If external module, we use base config + overrides as the config # If external module, we use base config + overrides as the config
# and pass the module path separately # 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) # Merge: base config -> overrides -> device-specific config (only if not external module)
mergedConfig = mergedConfig =
@@ -236,7 +211,12 @@ let
{ {
name = hostName; name = hostName;
value = mkHost { value = mkHost {
inherit hostName system hostType externalModulePath; inherit
hostName
system
hostType
externalModulePath
;
configOverrides = mergedConfig; configOverrides = mergedConfig;
}; };
} }

View File

@@ -50,7 +50,13 @@ let
default = [ ]; default = [ ];
}; };
home = lib.mkOption { 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; default = null;
description = '' description = ''
External home-manager configuration. Can be: External home-manager configuration. Can be:
@@ -146,23 +152,26 @@ in
let let
# Check if user has external home configuration # Check if user has external home configuration
hasExternalHome = user.home != null; hasExternalHome = user.home != null;
# Extract path from fetchGit/fetchTarball if needed # Extract path from fetchGit/fetchTarball if needed
externalHomePath = externalHomePath =
if hasExternalHome then if hasExternalHome then
if builtins.isAttrs user.home && user.home ? outPath then if builtins.isAttrs user.home && user.home ? outPath then user.home.outPath else user.home
user.home.outPath
else
user.home
else else
null; null;
# Import external module if it's a path # Import external module if it's a path
externalHomeModule = 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; } import (externalHomePath + "/home.nix") { inherit inputs; }
else if builtins.isAttrs user.home && !(user.home ? outPath) then else if builtins.isAttrs user.home && !(user.home ? outPath) then
user.home # Direct attrset configuration user.home # Direct attrset configuration
else else
{ }; { };

View File

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

View File

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

View File

@@ -22,16 +22,16 @@
config, config,
lib, lib,
pkgs, pkgs,
osConfig, # Access to the OS-level config osConfig, # Access to the OS-level config
... ...
}: }:
{ {
# ========== Home Manager Configuration ========== # ========== Home Manager Configuration ==========
# User identity (required) # User identity (required)
home.username = lib.mkDefault config.home.username; # Set by system home.username = lib.mkDefault config.home.username; # Set by system
home.homeDirectory = lib.mkDefault config.home.homeDirectory; # Set by system home.homeDirectory = lib.mkDefault config.home.homeDirectory; # Set by system
home.stateVersion = lib.mkDefault "25.11"; home.stateVersion = lib.mkDefault "25.11";
# ========== Packages ========== # ========== Packages ==========
@@ -44,7 +44,7 @@
]; ];
# ========== Programs ========== # ========== Programs ==========
# Git configuration # Git configuration
programs.git = { programs.git = {
enable = true; enable = true;
@@ -70,22 +70,22 @@
# }; # };
# ========== Shell Environment ========== # ========== Shell Environment ==========
home.sessionVariables = { home.sessionVariables = {
EDITOR = "vim"; EDITOR = "vim";
# Add your custom environment variables # Add your custom environment variables
}; };
# ========== Dotfiles ========== # ========== Dotfiles ==========
# You can manage dotfiles with home.file # You can manage dotfiles with home.file
# home.file.".bashrc".source = ./dotfiles/bashrc; # home.file.".bashrc".source = ./dotfiles/bashrc;
# home.file.".vimrc".source = ./dotfiles/vimrc; # home.file.".vimrc".source = ./dotfiles/vimrc;
# Or use programs.* options for better integration # Or use programs.* options for better integration
# ========== XDG Configuration ========== # ========== XDG Configuration ==========
xdg.enable = true; xdg.enable = true;
# xdg.configFile."app/config.conf".source = ./config/app.conf; # xdg.configFile."app/config.conf".source = ./config/app.conf;
} }

View File

@@ -23,7 +23,7 @@
{ {
# ========== System Configuration ========== # ========== System Configuration ==========
# Example: Enable a system service for this user # Example: Enable a system service for this user
# systemd.services.my-user-service = { # systemd.services.my-user-service = {
# description = "My User Service"; # description = "My User Service";