Merge pull request #126481 from ShamrockLee/timeshift

authored by Sandro and committed by GitHub 332ff38e ae977832

+202
+33
pkgs/applications/backup/timeshift/default.nix
···
··· 1 + { callPackage 2 + , timeshift-unwrapped 3 + , lib 4 + , rsync 5 + , coreutils 6 + , mount 7 + , umount 8 + , psmisc 9 + , cron 10 + , btrfs-progs 11 + , grubPackage 12 + }: 13 + let 14 + timeshift-wrapper = callPackage ./wrapper.nix { }; 15 + in 16 + (timeshift-wrapper timeshift-unwrapped ([ 17 + rsync 18 + coreutils 19 + mount 20 + umount 21 + psmisc 22 + cron 23 + btrfs-progs 24 + grubPackage 25 + ])).overrideAttrs (oldAttrs: { 26 + meta = oldAttrs.meta // { 27 + description = oldAttrs.meta.description; 28 + longDescription = oldAttrs.meta.longDescription + '' 29 + This package comes with runtime dependencies of command utilities provided by rsync, coreutils, mount, umount, psmisc, cron and (optionally) btrfs. 30 + If you want to use the commands provided by the system, override the propagatedBuildInputs or use timeshift-minimal instead 31 + ''; 32 + }; 33 + })
+15
pkgs/applications/backup/timeshift/minimal.nix
···
··· 1 + { callPackage 2 + , timeshift-unwrapped 3 + }: 4 + let 5 + timeshift-wrapper = callPackage ./wrapper.nix { }; 6 + in 7 + (timeshift-wrapper timeshift-unwrapped [ ]).overrideAttrs (oldAttrs: { 8 + meta = oldAttrs.meta // { 9 + description = oldAttrs.meta.description + " (without runtime dependencies)"; 10 + longDescription = oldAttrs.meta.longDescription + '' 11 + This package is a wrapped version of timeshift-unwrapped 12 + without runtime dependencies of command utilities. 13 + ''; 14 + }; 15 + })
+26
pkgs/applications/backup/timeshift/timeshift-launcher.patch
···
··· 1 + diff --git a/src/timeshift-launcher b/src/timeshift-launcher 2 + index 29b8fc4..5f6cb17 100755 3 + --- a/src/timeshift-launcher 4 + +++ b/src/timeshift-launcher 5 + @@ -1,6 +1,6 @@ 6 + #!/bin/bash 7 + 8 + -app_command='timeshift-gtk' 9 + +app_command=''"$(realpath "$(dirname "$0")")"'/timeshift-gtk' 10 + 11 + if [ "$(id -u)" -eq 0 ]; then 12 + # user is admin 13 + @@ -14,11 +14,11 @@ else 14 + # script is running in non-interactive mode 15 + if [ "$XDG_SESSION_TYPE" = "wayland" ] ; then 16 + xhost +SI:localuser:root 17 + - pkexec ${app_command} 18 + + pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" "${app_command}" 19 + xhost -SI:localuser:root 20 + xhost 21 + elif command -v pkexec >/dev/null 2>&1; then 22 + - pkexec ${app_command} 23 + + pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" "${app_command}" 24 + elif command -v sudo >/dev/null 2>&1; then 25 + x-terminal-emulator -e "sudo ${app_command}" 26 + elif command -v su >/dev/null 2>&1; then
+77
pkgs/applications/backup/timeshift/unwrapped.nix
···
··· 1 + { lib 2 + , stdenv 3 + , fetchFromGitHub 4 + , gettext 5 + , pkg-config 6 + , vala 7 + , which 8 + , gtk3 9 + , json-glib 10 + , libgee 11 + , utillinux 12 + , vte 13 + , xapps 14 + }: 15 + 16 + stdenv.mkDerivation rec { 17 + pname = "timeshift"; 18 + version = "22.06.1"; 19 + 20 + src = fetchFromGitHub { 21 + owner = "linuxmint"; 22 + repo = "timeshift"; 23 + rev = "v${version}"; 24 + sha256 = "XcxwVBKMv2YwbrI3FFWDQFs8hHruhkZq3YqzkptE6KE="; 25 + }; 26 + 27 + patches = [ 28 + ./timeshift-launcher.patch 29 + ]; 30 + 31 + postPatch = '' 32 + while IFS="" read -r -d $'\0' FILE; do 33 + substituteInPlace "$FILE" \ 34 + --replace "/sbin/blkid" "${utillinux}/bin/blkid" 35 + done < <(find ./src -mindepth 1 -name "*.vala" -type f -print0) 36 + substituteInPlace ./src/Utility/IconManager.vala \ 37 + --replace "/usr/share" "$out/share" 38 + substituteInPlace ./src/Core/Main.vala \ 39 + --replace "/etc/timeshift/default.json" "$out/etc/timeshift/default.json" \ 40 + --replace "file_copy(app_conf_path_default, app_conf_path);" "if (!dir_exists(file_parent(app_conf_path))){dir_create(file_parent(app_conf_path));};file_copy(app_conf_path_default, app_conf_path);" 41 + ''; 42 + 43 + nativeBuildInputs = [ 44 + gettext 45 + pkg-config 46 + vala 47 + which 48 + ]; 49 + 50 + buildInputs = [ 51 + gtk3 52 + json-glib 53 + libgee 54 + vte 55 + xapps 56 + ]; 57 + 58 + preBuild = '' 59 + makeFlagsArray+=( \ 60 + "-C" "src" \ 61 + "prefix=$out" \ 62 + "sysconfdir=$out/etc" \ 63 + ) 64 + ''; 65 + 66 + meta = with lib; { 67 + description = "A system restore tool for Linux"; 68 + longDescription = '' 69 + TimeShift creates filesystem snapshots using rsync+hardlinks or BTRFS snapshots. 70 + Snapshots can be restored using TimeShift installed on the system or from Live CD or USB. 71 + ''; 72 + homepage = "https://github.com/linuxmint/timeshift"; 73 + license = licenses.gpl3; 74 + platforms = platforms.linux; 75 + maintainers = with maintainers; [ ShamrockLee ]; 76 + }; 77 + }
+45
pkgs/applications/backup/timeshift/wrapper.nix
···
··· 1 + { stdenvNoCC 2 + , lib 3 + , wrapGAppsHook 4 + , gdk-pixbuf 5 + , librsvg 6 + , xorg 7 + , shared-mime-info 8 + }: 9 + 10 + timeshift-unwrapped: 11 + runtimeDeps: 12 + stdenvNoCC.mkDerivation { 13 + inherit (timeshift-unwrapped) pname version; 14 + 15 + dontUnpack = true; 16 + 17 + nativeBuildInputs = [ 18 + xorg.lndir 19 + wrapGAppsHook 20 + ]; 21 + 22 + installPhase = '' 23 + runHook preInstall 24 + mkdir -p "$out" 25 + lndir "${timeshift-unwrapped}" "$out" 26 + runHook postInstall 27 + ''; 28 + 29 + dontWrapGApps = true; 30 + 31 + preFixup = '' 32 + makeWrapperArgs=( 33 + --prefix PATH : "${lib.makeBinPath runtimeDeps}" 34 + ) 35 + gappsWrapperArgs+=( 36 + # Thumbnailers 37 + --prefix XDG_DATA_DIRS : "${lib.makeSearchPath "share" [ gdk-pixbuf librsvg shared-mime-info ]}" 38 + "''${makeWrapperArgs[@]}" 39 + ) 40 + wrapProgram "$out/bin/timeshift" "''${makeWrapperArgs[@]}" 41 + wrapProgram "$out/bin/timeshift-gtk" "''${gappsWrapperArgs[@]}" 42 + ''; 43 + 44 + inherit (timeshift-unwrapped) meta; 45 + }
+6
pkgs/top-level/all-packages.nix
··· 30040 30041 timelimit = callPackage ../tools/misc/timelimit { }; 30042 30043 timewarrior = callPackage ../applications/misc/timewarrior { }; 30044 30045 timew-sync-server = callPackage ../applications/misc/timew-sync-server { };
··· 30040 30041 timelimit = callPackage ../tools/misc/timelimit { }; 30042 30043 + timeshift-unwrapped = callPackage ../applications/backup/timeshift/unwrapped.nix { inherit (cinnamon) xapps; }; 30044 + 30045 + timeshift = callPackage ../applications/backup/timeshift { grubPackage = grub2_full; }; 30046 + 30047 + timeshift-minimal = callPackage ../applications/backup/timeshift/minimal.nix { }; 30048 + 30049 timewarrior = callPackage ../applications/misc/timewarrior { }; 30050 30051 timew-sync-server = callPackage ../applications/misc/timew-sync-server { };