Commit f93b8349 authored by Robert Schütz's avatar Robert Schütz Committed by Robert Schütz
Browse files

txt2tags: 2.6 -> unstable-2022-10-17

(cherry picked from commit 51a14752)
parent 19778f66
Loading
Loading
Loading
Loading
+26 −23
Original line number Diff line number Diff line
{ lib, stdenv, fetchurl, python2 }:
{ lib
, python3
, fetchFromGitHub
, fetchpatch
}:

stdenv.mkDerivation rec {
  version = "2.6";
python3.pkgs.buildPythonApplication rec {
  pname = "txt2tags";
  version = "unstable-2022-10-17";

  dontBuild = true;
  format = "setuptools";

  # Python script, needs the interpreter
  propagatedBuildInputs = [ python2 ];
  src = fetchFromGitHub {
    owner = "txt2tags";
    repo = "txt2tags";
    rev = "114ab24ea9111060df136bfc1c8b1a35a59fe0f2";
    hash = "sha256-h2OtlUMzEHKyJ9AIO1Uo9Lx7jMYZNMtC6U+usBu7gNU=";
  };

  installPhase = ''
    mkdir -p "$out/bin"
    mkdir -p "$out/share/doc"
    mkdir -p "$out/share/man/man1/"
    sed '1s|/usr/bin/env python|${python2}/bin/python|' < txt2tags > "$out/bin/txt2tags"
    chmod +x "$out/bin/txt2tags"
    gzip - < doc/manpage.man > "$out/share/man/man1/txt2tags.1.gz"
    cp doc/userguide.pdf "$out/share/doc"
    cp -r extras/ samples/ test/ "$out/share"
  postPatch = ''
    substituteInPlace test/lib.py \
      --replace 'TXT2TAGS = os.path.join(TEST_DIR, "..", "txt2tags.py")' \
                'TXT2TAGS = "${placeholder "out"}/bin/txt2tags"' \
      --replace "[PYTHON] + TXT2TAGS" "TXT2TAGS"
  '';

  src = fetchurl {
    url = "http://txt2tags.googlecode.com/files/${pname}-${version}.tgz";
    sha256 = "0p5hql559pk8v5dlzgm75yrcxwvz4z30f1q590yzng0ghvbnf530";
  };
  checkPhase = ''
    ${python3.interpreter} test/run.py
  '';

  meta = {
    changelog = "https://github.com/txt2tags/txt2tags/blob/${src.rev}/CHANGELOG.md";
    description = "Convert between markup languages";
    homepage = "https://txt2tags.org/";
    description = "A KISS markup language";
    license  = lib.licenses.gpl2;
    maintainers = with lib.maintainers; [ kovirobi ];
    platforms = with lib.platforms; unix;
    license  = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ dotlambda kovirobi ];
  };
}