@@ -0,0 +1,62 @@
1+{ lib, stdenv, fetchFromGitHub, ruby, bash, ncurses }:
2+let
3+ rubyEnv = ruby.withPackages (ps: with ps; [ ansi ]);
4+in
5+stdenv.mkDerivation rec {
6+ pname = "taoup";
7+ version = "1.1.14";
8+
9+ src = fetchFromGitHub {
10+ owner = "globalcitizen";
11+ repo = pname;
12+ rev = "v${version}";
13+ sha256 = "1gs6f66fg1l504riw481nvyw7cchbr3qjks4mkj2qb3s9147ad8j";
14+ };
15+
16+ buildInputs = [ rubyEnv bash ncurses ];
17+
18+ patches = [
19+ # Pre-create a cache within this derivation
20+ ./cachefile.patch
21+ # Remove the need to test for `tput`, depend on ncurses directly
22+ ./tput.patch
23+ # Fix the script name in `taoup --help` output
24+ ./help.patch
25+ ];
26+
27+ postPatch = ''
28+ substituteInPlace taoup \
29+ --subst-var-by ncurses ${ncurses} \
30+ --subst-var-by pname ${pname}
31+ substituteInPlace taoup-fortune \
32+ --subst-var-by out $out \
33+ --replace "/bin/bash" "${bash}/bin/bash"
34+ '';
35+
36+ dontConfigure = true;
37+ dontBuild = true;
38+
39+ installPhase = ''
40+ mkdir -p $out/{bin,lib/taoup}
41+
42+ cp taoup $out/lib/taoup
43+ cat > $out/bin/taoup <<EOF
44+ #!${bash}/bin/bash
45+ exec ${rubyEnv}/bin/ruby "$out/lib/taoup/taoup" "\$@"
46+ EOF
47+ chmod +x $out/bin/taoup
48+
49+ # Populate the cache created by cachedir.patch above
50+ $out/bin/taoup > $out/lib/taoup/cache
51+
52+ cp taoup-fortune $out/bin
53+ chmod +x $out/bin/taoup-fortune
54+ '';
55+
56+ meta = {
57+ description = "The Tao of Unix Programming (Ruby-powered ANSI colored fortunes)";
58+ homepage = "https://github.com/globalcitizen/taoup";
59+ license = lib.licenses.gpl3Only;
60+ maintainers = [ lib.maintainers.zakame ];
61+ };
62+}