summary refs log tree commit diff
path: root/pkgs/applications/misc/terminal-colors
diff options
context:
space:
mode:
authorDmitry Bogatov <git#v1@kaction.cc>2021-07-11 17:36:47 -0400
committerDmitry Bogatov <git#v1@kaction.cc>2021-08-27 17:10:05 -0400
commit3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f (patch)
tree88b02f3df444a71868726ccaf18203f3f2da5b0b /pkgs/applications/misc/terminal-colors
parentb6312861504c24b206b1dfac898f3a22b9943aad (diff)
downloadnixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.tar
nixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.tar.gz
nixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.tar.bz2
nixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.tar.lz
nixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.tar.xz
nixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.tar.zst
nixpkgs-3ef54d2032dda4e3c7c1cd26f4456d11fe6d129f.zip
terminal-colors: init at 3.0.1
Diffstat (limited to 'pkgs/applications/misc/terminal-colors')
-rw-r--r--pkgs/applications/misc/terminal-colors/default.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/pkgs/applications/misc/terminal-colors/default.nix b/pkgs/applications/misc/terminal-colors/default.nix
new file mode 100644
index 00000000000..08e810a13f8
--- /dev/null
+++ b/pkgs/applications/misc/terminal-colors/default.nix
@@ -0,0 +1,55 @@
+{ stdenv, lib, help2man, python3, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "terminal-colors";
+  version = "3.0.1";
+  outputs = [ "out" "man" ];
+
+  src = fetchFromGitHub {
+    owner = "eikenb";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-hekt77/FhSTMEARVuck49/Q1dIuqkwbOYmgGD1IItyc=";
+  };
+
+  buildInputs = [ python3 ];
+  nativeBuildInputs = [ help2man ];
+
+  postPatch =
+    # This sed command modifies output of --version command in way that
+    # makes manpage generated by help2man(1) prettier.
+    ''
+      sed -r -i "3s/([0-9.]+)/$pname - \1\\n/" ./$pname
+    ''
+    # Upstream shebang of "terminal-colors" python script uses
+    # /usr/bin/env, which is not present in Nix sandbox, so we need to
+    # patch it before running help2man, otherwise it would fail with "no
+    # such file or directory".
+    + ''
+      patchShebangs ./$pname
+    '';
+
+  buildPhase = ''
+    runHook preBuild
+
+    help2man -n 'display terminal colors' -N ./$pname > $pname.1
+
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    install -D -m755 ./$pname -t $out/bin
+    install -D -m644 ./$pname.1 -t $man/share/man/man1
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Script displaying terminal colors in various formats";
+    homepage = "https://github.com/eikenb/terminal-colors";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ kaction ];
+  };
+}