{ 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.user.services.copyAssets = { description = "Copy assets to home directory"; wantedBy = [ "default.target" ]; serviceConfig = { Type = "oneshot"; }; # This is the proper field for commands ExecStart = '' echo "Copying assets from ${assetPath} to ${homeDir} ..." if [ ! -d "${assetPath}" ]; then echo "ERROR: ${assetPath} does not exist" exit 1 fi mkdir -p "${homeDir}" ${pkgs.rsync}/bin/rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/" echo "Done copying assets." ''; }; # Make sure the user manager is enabled for the default user users.users.${username}.extraGroups = [ "wheel" ]; # optional systemd.enableUserServices = true; }