From c7c8101b81c022b861dd365e83eda2c0bb4eb727 Mon Sep 17 00:00:00 2001 From: Hunter Halloran Date: Wed, 17 Dec 2025 09:15:11 -0500 Subject: [PATCH] remove deprecated uses with external flakes and more consistent ugaif namespace usage --- .github/copilot-instructions.md | 2 +- hosts/boot.nix | 2 +- hosts/default.nix | 56 +++++++++++---------------------- hosts/user-config.nix | 31 +++++++++++------- installer/modules.nix | 4 +-- inventory.nix | 9 +++--- templates/user/home.nix | 18 +++++------ templates/user/nixos.nix | 2 +- 8 files changed, 55 insertions(+), 69 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 1cd86ed..bf6e97a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -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 diff --git a/hosts/boot.nix b/hosts/boot.nix index a78dacb..e1843de 100644 --- a/hosts/boot.nix +++ b/hosts/boot.nix @@ -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. ''; }; diff --git a/hosts/default.nix b/hosts/default.nix index 62b0a89..1fddb52 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -52,14 +52,14 @@ let name: user: if (user ? home && user.home != null) then let - homePath = - if builtins.isAttrs user.home && user.home ? outPath then - user.home.outPath - else - user.home; + homePath = + 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; }; } diff --git a/hosts/user-config.nix b/hosts/user-config.nix index 966d0c2..23578d9 100644 --- a/hosts/user-config.nix +++ b/hosts/user-config.nix @@ -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: @@ -146,23 +152,26 @@ in let # Check if user has external home configuration hasExternalHome = user.home != null; - + # Extract path from fetchGit/fetchTarball if needed - externalHomePath = + 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 + externalHomeModule = + 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 { }; diff --git a/installer/modules.nix b/installer/modules.nix index 9af1356..43253d9 100644 --- a/installer/modules.nix +++ b/installer/modules.nix @@ -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; })); } diff --git a/inventory.nix b/inventory.nix index 664a521..4e75a40 100644 --- a/inventory.nix +++ b/inventory.nix @@ -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 @@ # }; # }; } - diff --git a/templates/user/home.nix b/templates/user/home.nix index 866a5f5..3717854 100644 --- a/templates/user/home.nix +++ b/templates/user/home.nix @@ -22,16 +22,16 @@ config, lib, pkgs, - osConfig, # Access to the OS-level config + osConfig, # Access to the OS-level config ... }: { # ========== 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 ========== @@ -44,7 +44,7 @@ ]; # ========== Programs ========== - + # Git configuration programs.git = { enable = true; @@ -70,22 +70,22 @@ # }; # ========== Shell Environment ========== - + home.sessionVariables = { EDITOR = "vim"; # Add your custom environment variables }; # ========== Dotfiles ========== - + # You can manage dotfiles with home.file # home.file.".bashrc".source = ./dotfiles/bashrc; # home.file.".vimrc".source = ./dotfiles/vimrc; # Or use programs.* options for better integration - + # ========== XDG Configuration ========== - + xdg.enable = true; # xdg.configFile."app/config.conf".source = ./config/app.conf; } diff --git a/templates/user/nixos.nix b/templates/user/nixos.nix index afd98aa..d88819d 100644 --- a/templates/user/nixos.nix +++ b/templates/user/nixos.nix @@ -23,7 +23,7 @@ { # ========== System Configuration ========== - + # Example: Enable a system service for this user # systemd.services.my-user-service = { # description = "My User Service";