Regenerated
This commit is contained in:
+26
-44
@@ -370,66 +370,48 @@ in
|
||||
{ lib, config, inputs, ... }:
|
||||
|
||||
let
|
||||
# Default user
|
||||
username = config.defaultUser or "henrov";
|
||||
|
||||
modulesPath = ./generated/parked;
|
||||
importedModules = inputs.import-tree modulesPath;
|
||||
moduleSwitches = import ./assets/system/modules.conf;
|
||||
# Path to modules and config
|
||||
modulesPath = ./generated/modules;
|
||||
moduleSwitches = builtins.fromJSON (builtins.readFile ./assets/system/conf/modules.json);
|
||||
|
||||
# Import all modules recursively
|
||||
importedModules = inputs.import-tree modulesPath;
|
||||
|
||||
# Only enabled modules (according to modules.json)
|
||||
enabledModules =
|
||||
lib.filterAttrs (name: _: moduleSwitches.${name} or false)
|
||||
importedModules.imports;
|
||||
|
||||
# Flatten enabled modules to a list
|
||||
moduleList = builtins.attrValues enabledModules;
|
||||
|
||||
# Functie om fragment veilig te evalueren en debug info te verzamelen
|
||||
debugFragment = module:
|
||||
let
|
||||
frag =
|
||||
if builtins.hasAttr "homeManagerExtraUserFragment" module
|
||||
then module.homeManagerExtraUserFragment
|
||||
else {};
|
||||
evaluated =
|
||||
if builtins.isFunction frag then frag {} else frag;
|
||||
# Debug info / list of imported module files
|
||||
importedFiles = map (m:
|
||||
if builtins.hasAttr "file" m then m.file else "unknown"
|
||||
) moduleList;
|
||||
|
||||
isAttrs = builtins.isAttrs evaluated;
|
||||
isList = builtins.isList evaluated;
|
||||
isThunk = builtins.isFunction frag;
|
||||
in
|
||||
{
|
||||
fragment = if isAttrs then evaluated else {};
|
||||
debug = {
|
||||
name = if builtins.hasAttr "name" module then module.name else "unknown";
|
||||
isAttrs = isAttrs;
|
||||
isList = isList;
|
||||
isThunk = isThunk;
|
||||
};
|
||||
};
|
||||
# Extract and force each homeManagerExtraUserFragment to attrset
|
||||
fragmentsPerModule = map (m:
|
||||
if builtins.hasAttr "homeManagerExtraUserFragment" m
|
||||
then m.homeManagerExtraUserFragment
|
||||
else {}
|
||||
) moduleList;
|
||||
|
||||
# Alle fragments met debug info
|
||||
fragmentsWithDebug = map debugFragment moduleList;
|
||||
# Merge all fragments per username (top-level keys are usernames)
|
||||
mergedUserFragments = lib.foldl' lib.mkMerge {} fragmentsPerModule;
|
||||
|
||||
# Lijst van problematische modules
|
||||
problematicModules = builtins.filter
|
||||
(x: !(x.debug.isAttrs))
|
||||
fragmentsWithDebug;
|
||||
|
||||
# Merge alleen veilige fragments
|
||||
safeFragments = map (x: x.fragment) fragmentsWithDebug;
|
||||
mergedForUser = lib.foldl' lib.mkMerge {} safeFragments;
|
||||
|
||||
in
|
||||
{
|
||||
in {
|
||||
networking.hostName = "traveldroid";
|
||||
system.stateVersion = "26.05";
|
||||
|
||||
# Top-level key is username → value is attrset
|
||||
home-manager.users = {
|
||||
"${username}" = mergedForUser;
|
||||
};
|
||||
# Pass the merged fragments directly to home-manager
|
||||
home-manager.users = mergedUserFragments;
|
||||
|
||||
# Extra debug output, alleen zichtbaar als je `nix eval` gebruikt
|
||||
debug.problematicModules = problematicModules;
|
||||
# Bonus debug info: list of imported modules
|
||||
debug.importedFiles = importedFiles;
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
|
||||
Reference in New Issue
Block a user