summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/me/megapixels/package.nix
blob: 31ec3e7593fb24029dda2cab151e24eddc8d32fa (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
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
{
  stdenv,
  lib,
  fetchFromGitLab,
  glib,
  gperf,
  meson,
  ninja,
  pkg-config,
  wrapGAppsHook4,
  feedbackd,
  gtk4,
  libdng,
  libepoxy,
  libmegapixels,
  libpulseaudio,
  libxrandr,
  zbar,
  tiffSupport ? true,
  libraw,
  jpgSupport ? true,
  graphicsmagick,
  exiftool,
}:

assert jpgSupport -> tiffSupport;

let
  inherit (lib)
    makeBinPath
    optional
    optionals
    optionalString
    ;
  runtimePath = makeBinPath (
    optional tiffSupport libraw
    ++ optionals jpgSupport [
      graphicsmagick
      exiftool
    ]
  );
in
stdenv.mkDerivation (finalAttrs: {
  pname = "megapixels";
  version = "2.1.0";

  src = fetchFromGitLab {
    owner = "megapixels-org";
    repo = "Megapixels";
    tag = finalAttrs.version;
    hash = "sha256-fnG8fei3x0UkWJWBm8rB2r9bcKOhtFxG0Zaq+qjd7dE=";
  };

  nativeBuildInputs = [
    glib
    gperf
    meson
    ninja
    pkg-config
    wrapGAppsHook4
  ];

  buildInputs = [
    feedbackd
    gtk4
    libdng
    libepoxy
    libmegapixels
    libpulseaudio
    libxrandr
    zbar
  ];

  patches = [
    # In the settings menu of Megapixels the user can select a different postprocessing script. The path to the script is then stored in a dconf setting. If the path changes, for example because it is in the Nix store and a dependency of the postprocessor changes, Megapixels will try to use this now non-existing old path. This will cause Megapixels to not save any images that were taken until the user opens the settings again and selects a postprocessor again. Using a global path allows the setting to keep working.
    # Note that this patch only fixes the issue for external postprocessors like postprocessd but the postprocessor script that comes with Megapixels is still referred to by the Nix store path.
    ./search-for-postprocessors-in-NixOS-specific-global-location.patch
  ];

  postInstall = ''
    glib-compile-schemas $out/share/glib-2.0/schemas
  '';

  preFixup = optionalString (tiffSupport || jpgSupport) ''
    gappsWrapperArgs+=(
      --prefix PATH : ${lib.escapeShellArg runtimePath}
    )
  '';

  strictDeps = true;

  meta = {
    description = "GTK4 camera application that knows how to deal with the media request api";
    homepage = "https://gitlab.com/megapixels-org/Megapixels";
    changelog = "https://gitlab.com/megapixels-org/Megapixels/-/tags/${finalAttrs.src.tag}";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [
      dotlambda
      Luflosi
    ];
    platforms = lib.platforms.linux;
    mainProgram = "megapixels";
  };
})