Merge pull request #126481 from ShamrockLee/timeshift

This commit is contained in:
Sandro 2022-06-11 15:01:49 +02:00 committed by GitHub
commit 332ff38e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,33 @@
{ callPackage
, timeshift-unwrapped
, lib
, rsync
, coreutils
, mount
, umount
, psmisc
, cron
, btrfs-progs
, grubPackage
}:
let
timeshift-wrapper = callPackage ./wrapper.nix { };
in
(timeshift-wrapper timeshift-unwrapped ([
rsync
coreutils
mount
umount
psmisc
cron
btrfs-progs
grubPackage
])).overrideAttrs (oldAttrs: {
meta = oldAttrs.meta // {
description = oldAttrs.meta.description;
longDescription = oldAttrs.meta.longDescription + ''
This package comes with runtime dependencies of command utilities provided by rsync, coreutils, mount, umount, psmisc, cron and (optionally) btrfs.
If you want to use the commands provided by the system, override the propagatedBuildInputs or use timeshift-minimal instead
'';
};
})

View File

@ -0,0 +1,15 @@
{ callPackage
, timeshift-unwrapped
}:
let
timeshift-wrapper = callPackage ./wrapper.nix { };
in
(timeshift-wrapper timeshift-unwrapped [ ]).overrideAttrs (oldAttrs: {
meta = oldAttrs.meta // {
description = oldAttrs.meta.description + " (without runtime dependencies)";
longDescription = oldAttrs.meta.longDescription + ''
This package is a wrapped version of timeshift-unwrapped
without runtime dependencies of command utilities.
'';
};
})

View File

@ -0,0 +1,26 @@
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

View File

@ -0,0 +1,77 @@
{ lib
, stdenv
, fetchFromGitHub
, gettext
, pkg-config
, vala
, which
, gtk3
, json-glib
, libgee
, utillinux
, vte
, xapps
}:
stdenv.mkDerivation rec {
pname = "timeshift";
version = "22.06.1";
src = fetchFromGitHub {
owner = "linuxmint";
repo = "timeshift";
rev = "v${version}";
sha256 = "XcxwVBKMv2YwbrI3FFWDQFs8hHruhkZq3YqzkptE6KE=";
};
patches = [
./timeshift-launcher.patch
];
postPatch = ''
while IFS="" read -r -d $'\0' FILE; do
substituteInPlace "$FILE" \
--replace "/sbin/blkid" "${utillinux}/bin/blkid"
done < <(find ./src -mindepth 1 -name "*.vala" -type f -print0)
substituteInPlace ./src/Utility/IconManager.vala \
--replace "/usr/share" "$out/share"
substituteInPlace ./src/Core/Main.vala \
--replace "/etc/timeshift/default.json" "$out/etc/timeshift/default.json" \
--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);"
'';
nativeBuildInputs = [
gettext
pkg-config
vala
which
];
buildInputs = [
gtk3
json-glib
libgee
vte
xapps
];
preBuild = ''
makeFlagsArray+=( \
"-C" "src" \
"prefix=$out" \
"sysconfdir=$out/etc" \
)
'';
meta = with lib; {
description = "A system restore tool for Linux";
longDescription = ''
TimeShift creates filesystem snapshots using rsync+hardlinks or BTRFS snapshots.
Snapshots can be restored using TimeShift installed on the system or from Live CD or USB.
'';
homepage = "https://github.com/linuxmint/timeshift";
license = licenses.gpl3;
platforms = platforms.linux;
maintainers = with maintainers; [ ShamrockLee ];
};
}

View File

@ -0,0 +1,45 @@
{ stdenvNoCC
, lib
, wrapGAppsHook
, gdk-pixbuf
, librsvg
, xorg
, shared-mime-info
}:
timeshift-unwrapped:
runtimeDeps:
stdenvNoCC.mkDerivation {
inherit (timeshift-unwrapped) pname version;
dontUnpack = true;
nativeBuildInputs = [
xorg.lndir
wrapGAppsHook
];
installPhase = ''
runHook preInstall
mkdir -p "$out"
lndir "${timeshift-unwrapped}" "$out"
runHook postInstall
'';
dontWrapGApps = true;
preFixup = ''
makeWrapperArgs=(
--prefix PATH : "${lib.makeBinPath runtimeDeps}"
)
gappsWrapperArgs+=(
# Thumbnailers
--prefix XDG_DATA_DIRS : "${lib.makeSearchPath "share" [ gdk-pixbuf librsvg shared-mime-info ]}"
"''${makeWrapperArgs[@]}"
)
wrapProgram "$out/bin/timeshift" "''${makeWrapperArgs[@]}"
wrapProgram "$out/bin/timeshift-gtk" "''${gappsWrapperArgs[@]}"
'';
inherit (timeshift-unwrapped) meta;
}

View File

@ -30040,6 +30040,12 @@ with pkgs;
timelimit = callPackage ../tools/misc/timelimit { };
timeshift-unwrapped = callPackage ../applications/backup/timeshift/unwrapped.nix { inherit (cinnamon) xapps; };
timeshift = callPackage ../applications/backup/timeshift { grubPackage = grub2_full; };
timeshift-minimal = callPackage ../applications/backup/timeshift/minimal.nix { };
timewarrior = callPackage ../applications/misc/timewarrior { };
timew-sync-server = callPackage ../applications/misc/timew-sync-server { };