Files
nix-config/modules/nixos/home/default.nix
mjallen18 70002a19e2 hmm
2026-04-07 18:39:42 -05:00

91 lines
2.7 KiB
Nix
Executable File

{
config,
lib,
options,
namespace,
inputs,
...
}:
let
hasDestopEnvironment =
config.${namespace}.desktop.cosmic.enable
|| config.${namespace}.desktop.gnome.enable
|| config.${namespace}.desktop.hyprland.enable
|| config.${namespace}.desktop.plasma.enable;
in
{
options.${namespace}.home = with lib.types; {
configFile = lib.mkOption {
type = attrs;
default = { };
description = "A set of files to be managed by home-manager's <option>xdg.configFile</option>.";
};
extraOptions = lib.mkOption {
type = attrs;
default = { };
description = "Options to pass directly to home-manager.";
};
file = lib.mkOption {
type = attrs;
default = { };
description = "A set of files to be managed by home-manager's <option>home.file</option>.";
};
};
config = {
assertions =
let
desktopCount = lib.count lib.id [
config.${namespace}.desktop.gnome.enable
config.${namespace}.desktop.hyprland.enable
config.${namespace}.desktop.cosmic.enable
config.${namespace}.desktop.plasma.enable
];
in
[
{
assertion = desktopCount <= 1;
message = ''
At most one desktop environment may be enabled simultaneously.
Currently enabled: ${
lib.concatStringsSep ", " (
lib.optional config.${namespace}.desktop.gnome.enable "gnome"
++ lib.optional config.${namespace}.desktop.hyprland.enable "hyprland"
++ lib.optional config.${namespace}.desktop.cosmic.enable "cosmic"
++ lib.optional config.${namespace}.desktop.plasma.enable "plasma"
)
}.
'';
}
];
# ${namespace}.home.extraOptions = {
# home.file = lib.mkAliasDefinitions options.${namespace}.home.file;
# home.stateVersion = lib.mkOptionDefault config.system.stateVersion;
# xdg.configFile = lib.mkAliasDefinitions options.${namespace}.home.configFile;
# xdg.enable = lib.mkOptionDefault true;
# };
home-manager = {
# enables backing up existing files instead of erroring if conflicts exist
backupFileExtension = "backup";
useGlobalPkgs = true;
useUserPackages = false;
# Pass inputs so external modules can access them
extraSpecialArgs = {
inherit inputs namespace hasDestopEnvironment;
};
users.${config.${namespace}.user.name} =
lib.mkAliasDefinitions
options.${namespace}.home.extraOptions;
# users.admin = lib.mkAliasDefinitions options.${namespace}.home.extraOptions;
verbose = true;
};
};
}