{ name, displayName, fakeHome, binaryPath, environmentVariables, prepare ? "", before ? null }:
	{ lib, ... }: {
		users.groups.${name} = {};
		users.users.${name} = {
			description = "${name} Service User";
			isSystemUser = true;
			group = name;
		};

		systemd.services.${name} = {
			description = displayName;
			wantedBy = ["multi-user.target"];
			after = ["network.target"];
			before = lib.mkIf (before != null) before;

			serviceConfig = {
				ExecStart = binaryPath;
				User = name;
				Restart = "on-failure";
				# PermissionsStartOnly = true;
			};

			preStart = ''
				${lib.optionalString (prepare != null) prepare}
				${lib.optionalString fakeHome ''
					mkdir -m 0700 -p /tmp/${name}-home
					chown ${name} /tmp/${name}-home
				''}
			'';
			environment =  {
				HOME = lib.mkIf fakeHome "/tmp/${name}-home";
			} // environmentVariables;
		};
	}
