tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
taoup: init at 1.1.14
Zak B. Elep
4 years ago
6c643509
d050e7df
+137
5 changed files
expand all
collapse all
unified
split
pkgs
tools
misc
taoup
cachefile.patch
default.nix
help.patch
tput.patch
top-level
all-packages.nix
+35
pkgs/tools/misc/taoup/cachefile.patch
···
1
1
+
--- a/taoup-fortune 2021-09-05 12:16:23.408295791 +0800
2
2
+
+++ b/taoup-fortune 2021-09-05 13:02:52.286440200 +0800
3
3
+
@@ -5,31 +5,9 @@
4
4
+
# - https://github.com/matheuss/parrotsay
5
5
+
# - https://github.com/busyloop/lolcat
6
6
+
# - https://github.com/sckott/cowsay (enhanced version)
7
7
+
-dir=`dirname "${BASH_SOURCE[0]}"`
8
8
+
-
9
9
+
-# USER ALERT!!! @ronjouch complained about execution speed at https://github.com/globalcitizen/taoup/issues/11
10
10
+
-# ... therefore we add caching ... therefore first ensure we have an up to date cache via one of ...
11
11
+
-# md5sum
12
12
+
-if [ `which md5sum 2>/dev/null` ]; then
13
13
+
- MD5SUM=`md5sum ${dir}/taoup | cut -d ' ' -f1`
14
14
+
-# md5
15
15
+
-elif [ `which md5 2>/dev/null` ]; then
16
16
+
- MD5SUM=`md5 -q ${dir}/taoup | cut -d ' ' -f1`
17
17
+
-# openssl
18
18
+
-elif [ `which openssl 2>/dev/null` ]; then
19
19
+
- MD5SUM=`cat ${dir}/taoup | openssl md5 | grep -o '[[:xdigit:]][[:xdigit:]]*$' |cut -d '=' -f2- |cut -c 2-`
20
20
+
-# ruby
21
21
+
-elif [ `which ruby 2>/dev/null` ]; then
22
22
+
- MD5SUM=`ruby -rdigest/md5 -e"puts Digest::MD5.file'${dir}/taoup'"`
23
23
+
-fi
24
24
+
25
25
+
# determine cachefile name
26
26
+
-cachefile=${dir}/.taoup-fortune.cache.${MD5SUM}
27
27
+
-
28
28
+
-# create if necessary
29
29
+
-if [ ! -r $cachefile ]; then
30
30
+
- ${dir}/taoup $@ >${cachefile}
31
31
+
-fi
32
32
+
+cachefile=@out@/lib/taoup/cache
33
33
+
34
34
+
# handle all classes of society
35
35
+
if [ `which cowsay 2>/dev/null` ]; then
+62
pkgs/tools/misc/taoup/default.nix
···
1
1
+
{ lib, stdenv, fetchFromGitHub, ruby, bash, ncurses }:
2
2
+
let
3
3
+
rubyEnv = ruby.withPackages (ps: with ps; [ ansi ]);
4
4
+
in
5
5
+
stdenv.mkDerivation rec {
6
6
+
pname = "taoup";
7
7
+
version = "1.1.14";
8
8
+
9
9
+
src = fetchFromGitHub {
10
10
+
owner = "globalcitizen";
11
11
+
repo = pname;
12
12
+
rev = "v${version}";
13
13
+
sha256 = "1gs6f66fg1l504riw481nvyw7cchbr3qjks4mkj2qb3s9147ad8j";
14
14
+
};
15
15
+
16
16
+
buildInputs = [ rubyEnv bash ncurses ];
17
17
+
18
18
+
patches = [
19
19
+
# Pre-create a cache within this derivation
20
20
+
./cachefile.patch
21
21
+
# Remove the need to test for `tput`, depend on ncurses directly
22
22
+
./tput.patch
23
23
+
# Fix the script name in `taoup --help` output
24
24
+
./help.patch
25
25
+
];
26
26
+
27
27
+
postPatch = ''
28
28
+
substituteInPlace taoup \
29
29
+
--subst-var-by ncurses ${ncurses} \
30
30
+
--subst-var-by pname ${pname}
31
31
+
substituteInPlace taoup-fortune \
32
32
+
--subst-var-by out $out \
33
33
+
--replace "/bin/bash" "${bash}/bin/bash"
34
34
+
'';
35
35
+
36
36
+
dontConfigure = true;
37
37
+
dontBuild = true;
38
38
+
39
39
+
installPhase = ''
40
40
+
mkdir -p $out/{bin,lib/taoup}
41
41
+
42
42
+
cp taoup $out/lib/taoup
43
43
+
cat > $out/bin/taoup <<EOF
44
44
+
#!${bash}/bin/bash
45
45
+
exec ${rubyEnv}/bin/ruby "$out/lib/taoup/taoup" "\$@"
46
46
+
EOF
47
47
+
chmod +x $out/bin/taoup
48
48
+
49
49
+
# Populate the cache created by cachedir.patch above
50
50
+
$out/bin/taoup > $out/lib/taoup/cache
51
51
+
52
52
+
cp taoup-fortune $out/bin
53
53
+
chmod +x $out/bin/taoup-fortune
54
54
+
'';
55
55
+
56
56
+
meta = {
57
57
+
description = "The Tao of Unix Programming (Ruby-powered ANSI colored fortunes)";
58
58
+
homepage = "https://github.com/globalcitizen/taoup";
59
59
+
license = lib.licenses.gpl3Only;
60
60
+
maintainers = [ lib.maintainers.zakame ];
61
61
+
};
62
62
+
}
+21
pkgs/tools/misc/taoup/help.patch
···
1
1
+
--- a/taoup 2021-09-07 16:45:00.000000000 +0800
2
2
+
+++ b/taoup 2021-09-07 16:46:00.000000000 +0800
3
3
+
@@ -7,12 +7,12 @@
4
4
+
5
5
+
# show help if requested
6
6
+
if ARGV[0] == '--help' or ARGV[0] == '-h' then
7
7
+
- puts "usage: " + $0 + " [arguments]"
8
8
+
- puts " " + $0 + " Display all fortunes and sections."
9
9
+
- puts " " + $0 + " < --help | -h > This help."
10
10
+
- puts " " + $0 + " --whitetrash Convert ANSI colors for light/white terminals."
11
11
+
- puts " " + $0 + " --machine Remove ANSI colors."
12
12
+
- puts " " + $0 + " --fortune Convert output to fortune format (and lose colors)."
13
13
+
+ puts "usage: " + "@pname@" + " [arguments]"
14
14
+
+ puts " " + "@pname@" + " Display all fortunes and sections."
15
15
+
+ puts " " + "@pname@" + " < --help | -h > This help."
16
16
+
+ puts " " + "@pname@" + " --whitetrash Convert ANSI colors for light/white terminals."
17
17
+
+ puts " " + "@pname@" + " --machine Remove ANSI colors."
18
18
+
+ puts " " + "@pname@" + " --fortune Convert output to fortune format (and lose colors)."
19
19
+
exit(0)
20
20
+
end
21
21
+
# ... but optionally make sure ANSI escape sequences are filtered out
+17
pkgs/tools/misc/taoup/tput.patch
···
1
1
+
--- a/taoup 2021-09-05 12:43:48.334615538 +0800
2
2
+
+++ b/taoup 2021-09-05 12:55:07.631617799 +0800
3
3
+
@@ -26,11 +26,9 @@
4
4
+
zero_colors = true
5
5
+
fortunify = true
6
6
+
else
7
7
+
- if `which tput` then
8
8
+
- colors = `tput colors`
9
9
+
- if colors.chop == "-1" then
10
10
+
- zero_colors = true
11
11
+
- end
12
12
+
+ colors = `@ncurses@/bin/tput colors`
13
13
+
+ if colors.chop == "-1" then
14
14
+
+ zero_colors = true
15
15
+
end
16
16
+
end
17
17
+
if ARGV[0] == '--whitetrash' then
+2
pkgs/top-level/all-packages.nix
···
14770
14770
inherit (darwin.apple_sdk.frameworks) Security;
14771
14771
};
14772
14772
14773
14773
+
taoup = callPackage ../tools/misc/taoup { };
14774
14774
+
14773
14775
tcptrack = callPackage ../development/tools/misc/tcptrack { };
14774
14776
14775
14777
teensyduino = arduino-core.override { withGui = true; withTeensyduino = true; };