{ config, pkgs, lib, flakeRoot, ... }: let username = config.users.users.defaultUser or "henrov"; configDir = "/home/${username}/.config"; assetPath = "${flakeRoot}/.config"; in { environment.systemPackages = [ pkgs.rsync ]; systemd.services.copyAssets = { description = "Copy assets to ${username}'s .config directory"; wantedBy = [ "multi-user.target" ]; # oneshot service runs once at boot serviceConfig.Type = "oneshot"; # Always use /bin/sh -c for multi-line commands serviceConfig.ExecStart = '' /bin/sh -c ' echo "Copying assets from ${assetPath} to ${configDir} ..." if [ ! -d "${assetPath}" ]; then echo "ERROR: ${assetPath} does not exist" exit 1 fi mkdir -p "${configDir}" chown -R u+rwx ${username}:${username} "${configDir}" ${pkgs.rsync}/bin/rsync -a --no-owner --no-group "${assetPath}/" "${configDir}/" # Fix .config permissions mkdir -p "${configDir}" chown -R ${username}:${username} "${configDir}" chmod -R u+rwx "${configDir}" echo "Done copying config files." ' ''; }; }