summaryrefslogtreecommitdiff
path: root/pkgs/applications/backup/timeshift/wrapper.nix
blob: 781741e5984e551e5b5192aecde5bb5f754cea98 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
  stdenvNoCC,
  lib,
  wrapGAppsHook3,
  gdk-pixbuf,
  librsvg,
  lndir,
  shared-mime-info,
}:

timeshift-unwrapped: runtimeDeps:
stdenvNoCC.mkDerivation {
  inherit (timeshift-unwrapped) pname version outputs;

  dontUnpack = true;

  nativeBuildInputs = [
    wrapGAppsHook3
    lndir
  ];

  installPhase = ''
    runHook preInstall
  ''
  + lib.concatMapStrings (outputName: ''
    mkdir -p "''$${outputName}"
    lndir -silent "${timeshift-unwrapped.${outputName}}" "''$${outputName}"
  '') timeshift-unwrapped.outputs
  + ''
    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[@]}"
    # Substitute app_command to look for the `timeshift-gtk` in $out.
    unlink "$out/bin/timeshift-launcher"
    substitute ${lib.getExe' timeshift-unwrapped "timeshift-launcher"} "$out/bin/timeshift-launcher" \
      --replace-fail "app_command=${lib.getExe' timeshift-unwrapped "timeshift-gtk"}" "app_command=$out/bin/timeshift-gtk"
    chmod +x "$out/bin/timeshift-launcher"
  '';

  inherit (timeshift-unwrapped) meta;
}