summary refs log tree commit diff
path: root/pkgs/tools/graphics/goverlay/default.nix
blob: d4f88a770a01d5fa640068202f711dfc090af95a (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{ lib
, writeScriptBin
, bash
, stdenv
, fetchFromGitHub
, fpc
, lazarus-qt
, wrapQtAppsHook
, breeze-qt5
, libGL
, libGLU
, libqt5pas
, libX11
, coreutils
, git
, gnugrep
, libnotify
, polkit
, procps
, systemd
, util-linux
, vulkan-tools
, which
, nix-update-script
}:

let
  # Finds data files using the XDG Base Directory Specification
  # See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
  find-xdg-data-files = writeScriptBin "find-xdg-data-files" ''
    #!${bash}/bin/sh
    IFS=:
    for xdg_data_dir in ''${XDG_DATA_HOME:-$HOME/.local/share}:''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do
      if [ -f "$xdg_data_dir/$1" ]; then
        echo "$xdg_data_dir/$1"
      fi
    done
  '';
in stdenv.mkDerivation rec {
  pname = "goverlay";
  version = "0.7.1";

  src = fetchFromGitHub {
    owner = "benjamimgois";
    repo = pname;
    rev = version;
    sha256 = "sha256-oXkGrMHjs8uui0pzGYW8jnttet/5IX0r8eat0n5saFk=";
  };

  outputs = [ "out" "man" ];

  patches = [
    # Find MangoHud & vkBasalt Vulkan layers using the XDG Base Directory Specification
    ./find-xdg-data-files.patch
  ];

  postPatch = ''
    substituteInPlace Makefile \
      --replace 'prefix = /usr/local' "prefix = $out"

    substituteInPlace overlayunit.pas \
      --replace '/usr/share/icons/hicolor/128x128/apps/goverlay.png' "$out/share/icons/hicolor/128x128/apps/goverlay.png"
  '';

  nativeBuildInputs = [
    fpc
    lazarus-qt
    wrapQtAppsHook
  ];

  buildInputs = [
    breeze-qt5
    libGL
    libGLU
    libqt5pas
    libX11
  ];

  NIX_LDFLAGS = "-lGLU -rpath ${lib.makeLibraryPath buildInputs}";

  buildPhase = ''
    runHook preBuild
    HOME=$(mktemp -d) lazbuild --lazarusdir=${lazarus-qt}/share/lazarus -B goverlay.lpi
    runHook postBuild
  '';

  qtWrapperArgs = [
    "--prefix PATH : ${lib.makeBinPath [
      bash
      coreutils
      find-xdg-data-files
      git
      gnugrep
      libnotify
      polkit
      procps
      systemd
      util-linux.bin
      vulkan-tools
      which
    ]}"

    # Force xcb since libqt5pas doesn't support Wayland
    # See https://github.com/benjamimgois/goverlay/issues/107
    "--set QT_QPA_PLATFORM xcb"
  ];

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

  meta = with lib; {
    description = "An opensource project that aims to create a Graphical UI to help manage Linux overlays";
    homepage = "https://github.com/benjamimgois/goverlay";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ kira-bruneau ];
    platforms = platforms.linux;
  };
}