about summary refs log tree commit diff
path: root/pkgs/by-name/bt/btrfs-assistant/package.nix
blob: fce0bd8fc6eb7b45c756fb7d9da20dbd6c18fb4e (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
  lib,
  stdenv,
  fetchFromGitLab,
  bash,
  btrfs-progs,
  cmake,
  coreutils,
  git,
  pkg-config,
  qt6,
  snapper,
  util-linux,
  enableSnapper ? true,
  nix-update-script,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "btrfs-assistant";
  version = "2.1.1";

  src = fetchFromGitLab {
    owner = "btrfs-assistant";
    repo = "btrfs-assistant";
    rev = finalAttrs.version;
    hash = "sha256-I4nbQmHwk84qN1SngKzKnPtQN5Dz1QSSEpHJxV8wkJw=";
  };

  nativeBuildInputs = [
    cmake
    git
    pkg-config
    qt6.wrapQtAppsHook
  ];

  buildInputs = [
    btrfs-progs
    coreutils
    qt6.qtbase
    qt6.qtsvg
    qt6.qttools
    qt6.qtwayland
    util-linux
  ] ++ lib.optionals enableSnapper [ snapper ];

  prePatch =
    ''
      substituteInPlace src/util/System.cpp \
        --replace-fail '/bin/bash' "${lib.getExe bash}"

      substituteInPlace src/main.cpp \
        --replace-fail 'if (!qEnvironmentVariableIsEmpty("DISPLAY"))' ' if(!qEnvironmentVariableIsEmpty("DISPLAY") || !qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY"))'
    ''
    + lib.optionalString enableSnapper ''
      substituteInPlace src/main.cpp \
        --replace-fail '/usr/bin/snapper' "${lib.getExe snapper}"
    '';

  postPatch =
    ''
      substituteInPlace src/org.btrfs-assistant.pkexec.policy \
        --replace-fail '/usr/bin' "$out/bin"

      substituteInPlace src/btrfs-assistant \
        --replace-fail 'btrfs-assistant-bin' "$out/bin/btrfs-assistant-bin"

      substituteInPlace src/btrfs-assistant-launcher \
        --replace-fail 'btrfs-assistant' "$out/bin/btrfs-assistant"
    ''
    + lib.optionalString enableSnapper ''
      substituteInPlace src/btrfs-assistant.conf \
        --replace-fail '/usr/bin/snapper' "${lib.getExe snapper}"
    '';

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "GUI management tool to make managing a Btrfs filesystem easier";
    homepage = "https://gitlab.com/btrfs-assistant/btrfs-assistant";
    license = lib.licenses.gpl3Only;
    mainProgram = "btrfs-assistant-bin";
    maintainers = with lib.maintainers; [ khaneliman ];
    platforms = lib.platforms.linux;
  };
})