about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/misc/btrfs-assistant/default.nix
blob: 936409c3c0197a9450227bf1b520d30ec242bd0c (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
86
87
88
89
{ lib
, stdenv
, fetchFromGitLab
, bash
, btrfs-progs
, cmake
, coreutils
, git
, pkg-config
, qtbase
, qtsvg
, qttools
, snapper
, util-linux
, wrapQtAppsHook
, enableSnapper ? true
}:

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

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

  nativeBuildInputs = [
    cmake
    git
    pkg-config
  ];

  buildInputs = [
    btrfs-progs
    qtbase
    qtsvg
    qttools
  ];

  propagatedBuildInputs = [ wrapQtAppsHook ];

  prePatch = ''
    substituteInPlace src/util/System.cpp \
      --replace '/bin/bash' "${lib.getExe bash}"
  ''
  + lib.optionalString enableSnapper ''
    substituteInPlace src/main.cpp \
      --replace '/usr/bin/snapper' "${lib.getExe snapper}"
  '';

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

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

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

  qtWrapperArgs =
    let
      runtimeDeps = lib.makeBinPath ([
        coreutils
        util-linux
      ]
      ++ lib.optionals enableSnapper [ snapper ]);
    in
    [
      "--prefix PATH : ${runtimeDeps}"
    ];

  meta = {
    description = "A 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;
  };
})