about summary refs log tree commit diff
path: root/modules/user/aszlig/programs/flameshot/default.nix
blob: 51799aa52fe7995f622de8a790a6e651dca45ea4 (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
{ config, pkgs, lib, ... }:

let
  cfg = config.vuizvui.user.aszlig.programs.flameshot;

  # TODO: Make configurable via module system.
  settings = {
    disabledTrayIcon = true;
    drawColor = "#ff0000";
    drawThickness = 2;
    savePath = "$HOME/screenshots";
    savePathFixed = true;
    checkForUpdates = false;
  };

in {
  options.vuizvui.user.aszlig.programs.flameshot = {
    enable = lib.mkEnableOption "Flameshot";

    package = lib.mkOption {
      type = lib.types.package;
      default = pkgs.flameshot.overrideAttrs (drv: {
        patches = (drv.patches or []) ++ lib.singleton ./config.patch;
        configFile = pkgs.writeText "flameshot.ini" (lib.generators.toINI {} {
          General = settings;
        });
        postPatch = (drv.postPatch or "") + ''
          substituteInPlace src/utils/confighandler.cpp --subst-var configFile
        '';
      });
      readOnly = true;
      internal = true;
      description = "The patched Flameshot package.";
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = lib.singleton cfg.package;

    vuizvui.requiresTests = [
      ["vuizvui" "aszlig" "programs" "flameshot"]
    ];

    services.dbus.packages = lib.singleton (pkgs.writeTextFile {
      name = "flameshot-dbus";
      destination = "/share/dbus-1/services/org.flameshot.Flameshot.service";
      text = lib.generators.toINI {} {
        "D-BUS Service" = {
          Name = "org.flameshot.Flameshot";
          Exec = "${cfg.package}/bin/flameshot";
        };
      };
    });
  };
}