about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/backup/timeshift
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/backup/timeshift')
-rw-r--r--nixpkgs/pkgs/applications/backup/timeshift/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/backup/timeshift/minimal.nix15
-rw-r--r--nixpkgs/pkgs/applications/backup/timeshift/timeshift-launcher.patch26
-rw-r--r--nixpkgs/pkgs/applications/backup/timeshift/unwrapped.nix70
-rw-r--r--nixpkgs/pkgs/applications/backup/timeshift/wrapper.nix45
5 files changed, 189 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/backup/timeshift/default.nix b/nixpkgs/pkgs/applications/backup/timeshift/default.nix
new file mode 100644
index 000000000000..0a6a9bf38865
--- /dev/null
+++ b/nixpkgs/pkgs/applications/backup/timeshift/default.nix
@@ -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
+    '';
+  };
+})
diff --git a/nixpkgs/pkgs/applications/backup/timeshift/minimal.nix b/nixpkgs/pkgs/applications/backup/timeshift/minimal.nix
new file mode 100644
index 000000000000..96946fa72e05
--- /dev/null
+++ b/nixpkgs/pkgs/applications/backup/timeshift/minimal.nix
@@ -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.
+    '';
+  };
+})
diff --git a/nixpkgs/pkgs/applications/backup/timeshift/timeshift-launcher.patch b/nixpkgs/pkgs/applications/backup/timeshift/timeshift-launcher.patch
new file mode 100644
index 000000000000..765c101e1629
--- /dev/null
+++ b/nixpkgs/pkgs/applications/backup/timeshift/timeshift-launcher.patch
@@ -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
diff --git a/nixpkgs/pkgs/applications/backup/timeshift/unwrapped.nix b/nixpkgs/pkgs/applications/backup/timeshift/unwrapped.nix
new file mode 100644
index 000000000000..bcf6ff6af721
--- /dev/null
+++ b/nixpkgs/pkgs/applications/backup/timeshift/unwrapped.nix
@@ -0,0 +1,70 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, gettext
+, help2man
+, meson
+, ninja
+, pkg-config
+, vala
+, gtk3
+, json-glib
+, libgee
+, util-linux
+, vte
+, xapp
+}:
+
+stdenv.mkDerivation rec {
+  pname = "timeshift";
+  version = "23.12.2";
+
+  src = fetchFromGitHub {
+    owner = "linuxmint";
+    repo = "timeshift";
+    rev = version;
+    sha256 = "xeO1/YQGRTCCGMRPr6Dqb9+89lP24fPBDBJpvtcr2X0=";
+  };
+
+  patches = [
+    ./timeshift-launcher.patch
+  ];
+
+  postPatch = ''
+    while IFS="" read -r -d $'\0' FILE; do
+      substituteInPlace "$FILE" \
+        --replace "/sbin/blkid" "${util-linux}/bin/blkid"
+    done < <(find ./src -mindepth 1 -name "*.vala" -type f -print0)
+    substituteInPlace ./src/Utility/IconManager.vala \
+      --replace "/usr/share" "$out/share"
+  '';
+
+  nativeBuildInputs = [
+    gettext
+    help2man
+    meson
+    ninja
+    pkg-config
+    vala
+  ];
+
+  buildInputs = [
+    gtk3
+    json-glib
+    libgee
+    vte
+    xapp
+  ];
+
+  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.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ ShamrockLee bobby285271 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/backup/timeshift/wrapper.nix b/nixpkgs/pkgs/applications/backup/timeshift/wrapper.nix
new file mode 100644
index 000000000000..e72052fda1ba
--- /dev/null
+++ b/nixpkgs/pkgs/applications/backup/timeshift/wrapper.nix
@@ -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;
+}