home manager flake fixes
This commit is contained in:
@@ -92,6 +92,11 @@ hdh20267 = {
|
||||
|
||||
The external flake must provide a `nixosModules.default` output. This module is imported into the system configuration, allowing the user to override their own system settings (like `shell`, `extraGroups`) and define their Home Manager configuration.
|
||||
|
||||
You can also opt-out of the default system configurations for Zsh and Neovim if you prefer to manage them entirely yourself:
|
||||
|
||||
* `useZshTheme` (default: `true`): Set to `false` to disable the system-wide Zsh theme and configuration.
|
||||
* `useNvimPlugins` (default: `true`): Set to `false` to disable the system-wide Neovim plugins and configuration.
|
||||
|
||||
### Using External Flakes for System Configuration
|
||||
|
||||
You can also override the system-level configuration for a specific host using an external flake. This is useful for adding system services (like Docker), changing boot parameters, installing system-wide packages, or even overriding hardware settings (like swap size) without modifying `inventory.nix`.
|
||||
@@ -136,6 +141,10 @@ Note that `inputs` are omitted. This ensures the flake uses the exact same `nixp
|
||||
modules.users.accounts.hdh20267 = {
|
||||
shell = pkgs.fish;
|
||||
extraGroups = [ "docker" ];
|
||||
|
||||
# Optional: Disable system defaults if you manage your own
|
||||
useZshTheme = false;
|
||||
useNvimPlugins = false;
|
||||
};
|
||||
|
||||
# Enable programs needed for the shell
|
||||
|
||||
@@ -22,6 +22,8 @@ let
|
||||
flakeUrl = lib.mkOption { type = lib.types.str; default = ""; description = "URL of a flake to import Home Manager configuration from (e.g. github:user/dotfiles)."; };
|
||||
opensshKeys = lib.mkOption { type = lib.types.listOf lib.types.str; default = []; description = "List of SSH public keys for the user."; };
|
||||
shell = lib.mkOption { type = lib.types.nullOr lib.types.package; default = null; description = "The shell for this user."; };
|
||||
useZshTheme = lib.mkOption { type = lib.types.bool; default = true; description = "Whether to apply the system Zsh theme."; };
|
||||
useNvimPlugins = lib.mkOption { type = lib.types.bool; default = true; description = "Whether to apply the system Neovim configuration."; };
|
||||
};
|
||||
};
|
||||
in
|
||||
@@ -78,13 +80,28 @@ in
|
||||
let
|
||||
enabledAccounts = lib.filterAttrs (name: _: lib.elem name config.modules.users.enabledUsers) config.modules.users.accounts;
|
||||
in
|
||||
lib.mapAttrs (name: user: { ... }: {
|
||||
imports = user.extraImports ++ [ ../sw/theme.nix ../sw/nvim.nix ];
|
||||
home.username = name;
|
||||
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
|
||||
home.stateVersion = "25.11";
|
||||
home.packages = user.homePackages;
|
||||
}) enabledAccounts;
|
||||
lib.mapAttrs (name: user: { ... }:
|
||||
let
|
||||
isExternal = user.flakeUrl != "";
|
||||
|
||||
# Common imports based on flags
|
||||
commonImports =
|
||||
lib.optional user.useZshTheme ../sw/theme.nix
|
||||
++ lib.optional user.useNvimPlugins ../sw/nvim.nix;
|
||||
in
|
||||
if isExternal then {
|
||||
# External users: Only apply requested system modules.
|
||||
# The external flake is responsible for home.username, home.packages, etc.
|
||||
imports = commonImports;
|
||||
} else {
|
||||
# Local users: Apply full configuration.
|
||||
imports = user.extraImports ++ commonImports;
|
||||
home.username = name;
|
||||
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
|
||||
home.stateVersion = "25.11";
|
||||
home.packages = user.homePackages;
|
||||
}
|
||||
) enabledAccounts;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user