{ lib, config, pkgs, flakeRoot, ... }: let username = config.defaultUser or "henrov"; # Base directory in the user's home homeDir = "${config.home.homeDirectory or "/home/${username}"}/MyStuff"; # Absolute path to your assets folder assetPath = "${flakeRoot}/assets/copy_2_home"; # Recursively list all files in a folder recursiveFiles = path: let entries = builtins.attrNames (builtins.readDir path); in lib.concatMap (name: let full = "${path}/${name}"; in if builtins.isDir full then recursiveFiles full else [ full ] ) entries; # Get all files in assetPath allFiles = recursiveFiles assetPath; # Map each file to a home.file entry using writable symlinks homeFiles = lib.genAttrs allFiles (f: let relative = lib.replaceStrings [ "${assetPath}/" ] [ "" ] f; target = "${homeDir}/${relative}"; in { name = target; value = { source = lib.makeOutOfStoreSymlink f; }; } ); in { _module.args.hmUsers = { ${username} = { home.file = lib.mkMerge [ homeFiles ]; }; }; }