summary refs log tree commit diff
path: root/pkgs/tools/misc/cowsay/default.nix
blob: 095c8bab48f58950735f1f3438391b3fbafcecfd (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
{ lib, stdenv, perl, installShellFiles, fetchFromGitHub }:

stdenv.mkDerivation rec {
  pname = "cowsay";
  version = "3.04";

  src = fetchFromGitHub {
    owner = "tnalpgge";
    repo = "rank-amateur-cowsay";
    rev = "cowsay-${version}";
    sha256 = "sha256-9jCaQ6Um6Nl9j0/urrMCRcsGeubRN3VWD3jDM/AshRg=";
  };

  buildInputs = [ perl ];

  nativeBuildInputs = [ installShellFiles ];

  # overriding buildPhase because we don't want to use the install.sh script
  buildPhase = ''
    runHook preBuild;
    substituteInPlace cowsay --replace "%BANGPERL%" "!${perl}/bin/perl" \
      --replace "%PREFIX%" "$out"
    runHook postBuild;
  '';

  installPhase = ''
    runHook preInstall
    install -Dm755 cowsay $out/bin/cowsay
    ln -s $out/bin/cowsay $out/bin/cowthink

    installManPage cowsay.1
    ln -s $man/share/man/man1/cowsay.1.gz $man/share/man/man1/cowthink.1.gz

    install -Dm644 cows/* -t $out/share/cows/
    runHook postInstall
  '';

  outputs = [ "out" "man" ];

  meta = with lib; {
    description = "A program which generates ASCII pictures of a cow with a message";
    homepage = "https://github.com/tnalpgge/rank-amateur-cowsay";
    license = licenses.gpl3Only;
    platforms = platforms.all;
    maintainers = [ maintainers.rob ];
  };
}