about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/emojipick/default.nix
blob: 9c28c98bf0473634486310f0de29cf972d8e6245 (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
{ stdenvNoCC
, fetchFromGitHub
, lib
, python3
, xclip
, libnotify
, dmenu
, rofi
, emojipick-use-rofi ? false
, emojipick-copy-to-clipboard ? true
, emojipick-show-notifications ? true
, emojipick-print-emoji ? true
, emojipick-font-family ? "Noto Color Emoji"
, emojipick-font-size ? "18"
}:

let
  boolToInt = b: if b then "1" else "0"; # Convert boolean to integer string
in
stdenvNoCC.mkDerivation {
  pname = "emojipick";
  version = "2021-01-27";

  src = fetchFromGitHub {
    owner = "thingsiplay";
    repo = "emojipick";
    rev = "20210127";
    sha256 = "1kib3cyx6z9v9qw6yrfx5sklanpk5jbxjc317wi7i7ljrg0vdazp";
  };

  dontConfigure = true;
  dontBuild = true;

  # Patch configuration
  # notify-send has to be patched in a bash file
  postPatch = ''
    substituteInPlace emojipick \
      --replace "use_rofi=0" "use_rofi=${boolToInt emojipick-use-rofi}" \
      --replace "copy_to_clipboard=1" "copy_to_clipboard=${boolToInt emojipick-copy-to-clipboard}" \
      --replace "show_notification=1" "show_notification=${boolToInt emojipick-show-notifications}" \
      --replace "print_emoji=1" "print_emoji=${boolToInt emojipick-print-emoji}" \
      --replace "font_family='\"Noto Color Emoji\"'" "font_family='\"${emojipick-font-family}\"'" \
      --replace 'font_size="18"' 'font_size="${emojipick-font-size}"' \
      ${lib.optionalString emojipick-use-rofi "--replace 'rofi ' '${rofi}/bin/rofi '"} \
      --replace notify-send ${libnotify}/bin/notify-send
  '';

  buildInputs = [
    python3
    xclip
    libnotify
  ] ++ (if emojipick-use-rofi then [rofi] else [dmenu]);

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp ./emojipick $out/bin
    cp ./emojiget.py $out/bin

    runHook postInstall
  '';

  meta = with lib; {
    description = "Get a selection of emojis with dmenu or rofi";
    homepage = "https://github.com/thingsiplay/emojipick";
    license = licenses.mit;
    maintainers = with maintainers; [ alexnortung ];
    platforms = platforms.linux;
  };
}