From b201cc703f531a54d6e04552c6ed402753a8465c Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sat, 7 Dec 2024 20:08:05 +0800 Subject: [PATCH] timeshift: patch timeshift-launcher with escapeShellArg instead of a patch file --- .../backup/timeshift/timeshift-launcher.patch | 26 ------------------- .../backup/timeshift/unwrapped.nix | 8 +++--- 2 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 pkgs/applications/backup/timeshift/timeshift-launcher.patch diff --git a/pkgs/applications/backup/timeshift/timeshift-launcher.patch b/pkgs/applications/backup/timeshift/timeshift-launcher.patch deleted file mode 100644 index 765c101e1629..000000000000 --- a/pkgs/applications/backup/timeshift/timeshift-launcher.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/src/timeshift-launcher b/src/timeshift-launcher -index 29b8fc4..5f6cb17 100755 ---- a/src/timeshift-launcher -+++ b/src/timeshift-launcher -@@ -1,6 +1,6 @@ - #!/bin/bash - --app_command='timeshift-gtk' -+app_command=''"$(realpath "$(dirname "$0")")"'/timeshift-gtk' - - if [ "$(id -u)" -eq 0 ]; then - # user is admin -@@ -14,11 +14,11 @@ else - # script is running in non-interactive mode - if [ "$XDG_SESSION_TYPE" = "wayland" ] ; then - xhost +SI:localuser:root -- pkexec ${app_command} -+ pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" "${app_command}" - xhost -SI:localuser:root - xhost - elif command -v pkexec >/dev/null 2>&1; then -- pkexec ${app_command} -+ pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" "${app_command}" - elif command -v sudo >/dev/null 2>&1; then - x-terminal-emulator -e "sudo ${app_command}" - elif command -v su >/dev/null 2>&1; then diff --git a/pkgs/applications/backup/timeshift/unwrapped.nix b/pkgs/applications/backup/timeshift/unwrapped.nix index 357f533bd845..cb62703ab37c 100644 --- a/pkgs/applications/backup/timeshift/unwrapped.nix +++ b/pkgs/applications/backup/timeshift/unwrapped.nix @@ -26,10 +26,6 @@ stdenv.mkDerivation rec { hash = "sha256-2qNLgUZLMcfoemdLvvjdkR7Ln5loSKGqbd402y5Id8k="; }; - patches = [ - ./timeshift-launcher.patch - ]; - postPatch = '' for FILE in src/Core/Main.vala src/Utility/Device.vala; do substituteInPlace "$FILE" \ @@ -38,6 +34,10 @@ stdenv.mkDerivation rec { substituteInPlace ./src/Utility/IconManager.vala \ --replace-fail "/usr/share" "$out/share" + + substituteInPlace ./src/timeshift-launcher \ + --replace-fail "app_command='timeshift-gtk'" ${lib.escapeShellArg ''app_command="$(realpath "$(dirname "$0")")/timeshift-gtk"''} \ + --replace-fail ${lib.escapeShellArg ''pkexec ''${app_command}''} ${lib.escapeShellArg ''pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" "''${app_command}"''} ''; nativeBuildInputs = [