{ config, pkgs, lib, flakeRoot, ... }: let # Default to the configured default user username = config.users.users.defaultUser or "henrov"; homeDir = "/home/${username}"; assetPath = "${flakeRoot}/assets/copy_2_home"; in { # Ensure rsync is available system-wide environment.systemPackages = [ pkgs.rsync ]; # System service to copy assets to the user home at boot systemd.services.copyAssets = { description = "Copy assets to ${username}'s home directory"; wantedBy = [ "multi-user.target" ]; serviceConfig.Type = "oneshot"; ExecStart = '' echo "Copying assets from ${assetPath} to ${homeDir} ..." if [ ! -d "${assetPath}" ]; then echo "ERROR: ${assetPath} does not exist" exit 1 fi mkdir -p "${homeDir}" chown ${username}:${username} "${homeDir}" ${pkgs.rsync}/bin/rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/" echo "Done copying assets." ''; }; }