{ lib, config, pkgs, ... }: let username = config.users.users.defaultUser or "henrov"; homeDir = config.home.homeDirectory or "/home/${username}"; assetPath = "${config.flakeRoot}/assets/copy_2_home"; in { _module.args.hmUsers = { ${username} = { # Ensure rsync is available for the activation script home.packages = [ pkgs.rsync ]; # Activation script: copy assets after all other Home Manager activations home.activation.copyAssets = lib.hm.dag.entryAfter [ "writeBoundary" ] '' echo "Copying assets from ${assetPath} to ${homeDir} ..." if [ ! -d "${assetPath}" ]; then echo "Error: source directory ${assetPath} does not exist" exit 1 fi mkdir -p "${homeDir}" # Copy recursively, preserve symlinks, overwrite existing files rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/" echo "Done copying assets." ''; }; }; }