{ config, pkgs, lib, flakeRoot, ... }: let username = config.users.users.defaultUser or "henrov"; homeDir = "/home/${username}"; assetPath = "${flakeRoot}/assets/copy_2_home"; in { environment.systemPackages = [ pkgs.rsync ]; systemd.services.copyAssets = { description = "Copy assets to ${username}'s home 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 ${homeDir}/Droidnix ..." if [ ! -d "${assetPath}" ]; then echo "ERROR: ${assetPath} does not exist" exit 1 fi mkdir -p "${homeDir}/Droidnix" chown u+rwx ${username}:${username} "${homeDir}/Droidnix" ${pkgs.rsync}/bin/rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/" # Fix .config permissions mkdir -p "${homeDir}/.config" chown -R ${username}:${username} "${homeDir}/.config" chmod u+rwx "${homeDir}/.config" echo "Done copying assets." ' ''; }; }