{ lib, config, pkgs, ... }: let scriptPath = "${pkgs.path}/../assets/scripts/end_script.sh"; scriptExists = builtins.pathExists scriptPath; in { systemd.user.services.endScript = lib.mkIf scriptExists { description = "Run end script after Home Manager"; wantedBy = [ "multi-user.target" ]; after = [ "home-manager-activate.service" ]; serviceConfig = { Type = "oneshot"; WorkingDirectory = "${config.nixpkgs.config}/.."; Environment = [ "HOME=${config.users.users.henrov.home}" ]; }; script = '' echo "Running script at: ${scriptPath}" ${scriptPath} ''; }; }