about summary refs log tree commit diff
path: root/pkgs/sternenseemann/tep/default.nix
blob: 16cd9cb37949f88db9a610291b6861917e5124ac (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
{ writeHaskell, writeBashBin, writeText, runCommandLocal
, emoji-generic, utf8-light, attoparsec, text, bytestring
, bemenu
, fromTep ? "cut -d' ' -f1"
, copy ? "wl-copy --trim-newline"
, emojiTestTxt
}:

let
  tepData = writeHaskell "tep-data" {
    libraries = [ emoji-generic utf8-light attoparsec text bytestring ];
  } ./tepData.hs;

  static = writeText "static-tep.txt" ''
    · dot time character
  '';

  emojis = runCommandLocal "emojis.txt" {} ''
    ${tepData} < ${emojiTestTxt} > tep-data.txt
    cat ${static} tep-data.txt > "$out"
  '';
in

writeBashBin "tep" ''
  copy=false
  if [[ "$1" = "copy" ]]; then
    copy=true
    shift
  fi
  ${bemenu}/bin/bemenu $@ < ${emojis} | ${fromTep} | \
  if $copy; then
    ${copy}
  else
    cat
  fi
''