mirror of
https://github.com/Jokiller230/puzzlevision.git
synced 2025-09-09 12:20:04 +00:00
✨ finalize home configuration loading as nixos module, and more stuffs :3
This commit is contained in:
parent
f89cbcc552
commit
dc87b2c186
16 changed files with 192 additions and 87 deletions
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
namespace,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
inherit (self) namespace;
|
||||
|
||||
cfg = config.${namespace}.desktop.gnome;
|
||||
in {
|
||||
options.${namespace}.desktop.gnome = {enable = mkEnableOption "Enable the gnome desktop environment ${namespace}";};
|
||||
|
|
86
modules/nixos/users/default.nix
Normal file
86
modules/nixos/users/default.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf mkOption types;
|
||||
inherit (self) namespace;
|
||||
inherit (self.lib) mkOpt dirToModuleList;
|
||||
|
||||
cfg = config.${namespace}.users;
|
||||
|
||||
system = builtins.currentSystem;
|
||||
systemClass =
|
||||
if builtins.match ".*-linux" system != null then "nixos"
|
||||
else if builtins.match ".*-darwin" system != null then "darwin"
|
||||
else "nixos"; # Default fallback
|
||||
|
||||
# Type for a user configuration
|
||||
userType = types.submodule {
|
||||
options = {
|
||||
enable = mkEnableOption "Enable this user";
|
||||
initialPassword = mkOpt (types.nullOr types.str) null "Initial password for the user";
|
||||
hashedPassword = mkOpt (types.nullOr types.str) null "Hashed password for the user";
|
||||
isNormalUser = mkOpt types.bool true "Whether this user is a normal user";
|
||||
extraGroups = mkOpt (types.listOf types.str) [] "Extra groups for the user";
|
||||
};
|
||||
};
|
||||
|
||||
# Function to get home configuration path for a username
|
||||
getHomeConfigPath = username: "${self.outPath}/homes/${systemClass}/${username}";
|
||||
|
||||
# Function to check if a home configuration exists for a username
|
||||
homeConfigExists = username:
|
||||
let path = getHomeConfigPath username;
|
||||
in builtins.pathExists "${path}/default.nix";
|
||||
|
||||
# Import all home-manager modules
|
||||
homeModules = dirToModuleList "${self.outPath}/modules/home";
|
||||
in {
|
||||
imports = [
|
||||
# Import home-manager NixOS module
|
||||
# This assumes home-manager is available as a flake input
|
||||
self.inputs.home-manager.nixosModules.home-manager
|
||||
];
|
||||
|
||||
options.${namespace}.users = mkOption {
|
||||
type = types.attrsOf userType;
|
||||
default = {};
|
||||
description = "User configurations with auto-imported home-manager setup";
|
||||
};
|
||||
|
||||
config = {
|
||||
# Create the actual users
|
||||
users.users = lib.mapAttrs (username: userConfig:
|
||||
mkIf userConfig.enable {
|
||||
name = username;
|
||||
isNormalUser = userConfig.isNormalUser;
|
||||
inherit (userConfig) extraGroups;
|
||||
initialPassword = userConfig.initialPassword;
|
||||
hashedPassword = userConfig.hashedPassword;
|
||||
}
|
||||
) cfg;
|
||||
|
||||
# Configure home-manager with auto-imported configs
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
|
||||
extraSpecialArgs = {
|
||||
inherit self;
|
||||
namespace = self.namespace;
|
||||
};
|
||||
|
||||
users = lib.mapAttrs (username: userConfig:
|
||||
mkIf (userConfig.enable && homeConfigExists username) (
|
||||
{ ... }: {
|
||||
imports = [
|
||||
(getHomeConfigPath username) # Import the user's specific home configuration
|
||||
] ++ homeModules; # Include all home modules from /modules/home
|
||||
}
|
||||
)
|
||||
) cfg;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,44 +1,26 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
namespace,
|
||||
puzzlelib,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge;
|
||||
inherit (puzzlelib) mkOpt mkBool;
|
||||
inherit (lib) mkIf;
|
||||
inherit (self) namespace;
|
||||
|
||||
cfg = config.${namespace}.utils.vm;
|
||||
in {
|
||||
options.${namespace}.utils.vm = {
|
||||
enable = mkBool true "Whether to enable custom vm presets";
|
||||
preset = mkOpt lib.types.str "performance" "Specify the prefered vm settings preset: performance, balance or powersave";
|
||||
enable = self.lib.mkBool true "Whether to enable custom vm presets";
|
||||
preset = self.lib.mkOpt lib.types.str "performance" "Specify the prefered vm settings preset: performance, balance or powersave";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
virtualisation.vmVariant = mkMerge [
|
||||
(mkIf cfg.preset
|
||||
== "performance" {
|
||||
virtualisation = {
|
||||
cores = 6;
|
||||
memorySize = 4096;
|
||||
graphics = true;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset
|
||||
== "balance" {
|
||||
virtualisation = {
|
||||
cores = 4;
|
||||
memorySize = 2048;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset
|
||||
== "powersave" {
|
||||
virtualisation = {
|
||||
cores = 2;
|
||||
memorySize = 1024;
|
||||
};
|
||||
})
|
||||
];
|
||||
virtualisation.vmVariant = {
|
||||
virtualisation = {
|
||||
cores = 6;
|
||||
memorySize = 4096;
|
||||
graphics = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue