about summary refs log tree commit diff
path: root/pkgs/tools/misc/pokemonsay/default.nix
blob: f61b93a874f225c26ddc051850e5f5eddb29796a (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
{ lib
, stdenvNoCC
, fetchFromGitHub
, cowsay
, coreutils
, findutils
}:

stdenvNoCC.mkDerivation rec {
  pname = "pokemonsay";
  version = "unstable-2021-10-05";

  src = fetchFromGitHub {
    owner = "HRKings";
    repo = "pokemonsay-newgenerations";
    rev = "baccc6d2fe1897c48f60d82ff9c4d4c018f5b594";
    hash = "sha256-IDTAZmOzkUg0kLUM0oWuVbi8EwE4sEpLWrNAtq/he+g=";
  };

  postPatch = ''
    substituteInPlace pokemonsay.sh \
      --replace \
        'INSTALL_PATH=''${HOME}/.bin/pokemonsay' \
        "" \
      --replace \
        'POKEMON_PATH=''${INSTALL_PATH}/pokemons' \
        'POKEMON_PATH=${placeholder "out"}/share/pokemonsay' \
      --replace \
        '$(find ' \
        '$(${findutils}/bin/find ' \
      --replace \
        '$(basename ' \
        '$(${coreutils}/bin/basename ' \
      --replace \
        'cowsay -f ' \
        '${cowsay}/bin/cowsay -f ' \
      --replace \
        'cowthink -f ' \
        '${cowsay}/bin/cowthink -f '

    substituteInPlace pokemonthink.sh \
      --replace \
        './pokemonsay.sh' \
        "${placeholder "out"}/bin/pokemonsay"
  '';

  installPhase = ''
    mkdir -p $out/{bin,share/pokemonsay}
    cp pokemonsay.sh $out/bin/pokemonsay
    cp pokemonthink.sh $out/bin/pokemonthink
    cp pokemons/*.cow $out/share/pokemonsay
  '';

  checkPhase = ''
    $out/bin/pokemonsay --list-pokemon
  '';

  meta = with lib; {
    description = "Print pokemon in the CLI! An adaptation of the classic cowsay";
    homepage = "https://github.com/HRKings/pokemonsay-newgenerations";
    license = licenses.mit;
    platforms = platforms.all;
    maintainers = with maintainers; [ pbsds ];
  };
}