remove deprecated uses with external flakes and more consistent ugaif namespace usage
This commit is contained in:
2
.github/copilot-instructions.md
vendored
2
.github/copilot-instructions.md
vendored
@@ -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
|
||||
|
||||
@@ -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.
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{ };
|
||||
|
||||
|
||||
@@ -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; }));
|
||||
}
|
||||
|
||||
@@ -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 @@
|
||||
# };
|
||||
# };
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
{
|
||||
# ========== System Configuration ==========
|
||||
|
||||
|
||||
# Example: Enable a system service for this user
|
||||
# systemd.services.my-user-service = {
|
||||
# description = "My User Service";
|
||||
|
||||
Reference in New Issue
Block a user