2021-05-20 23:08:51 +00:00
|
|
|
{ lib
|
2023-07-15 17:15:38 +00:00
|
|
|
, buildPythonApplication
|
2021-05-20 23:08:51 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, importlib-metadata
|
2023-07-15 17:15:38 +00:00
|
|
|
, makeWrapper
|
2021-05-20 23:08:51 +00:00
|
|
|
, markdown-it-py
|
|
|
|
, poetry-core
|
|
|
|
, pytestCheckHook
|
2023-07-15 17:15:38 +00:00
|
|
|
, python3
|
2021-05-20 23:08:51 +00:00
|
|
|
, pythonOlder
|
2022-09-30 11:47:45 +00:00
|
|
|
, setuptools
|
2021-12-06 16:07:01 +00:00
|
|
|
, tomli
|
2021-05-20 23:08:51 +00:00
|
|
|
, typing-extensions
|
|
|
|
}:
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
let
|
|
|
|
withPlugins = plugins: buildPythonApplication {
|
|
|
|
pname = "${package.pname}";
|
|
|
|
inherit (package) version;
|
|
|
|
format = "other";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
dontUnpack = true;
|
|
|
|
dontBuild = true;
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
makeWrapper ${package}/bin/mdformat $out/bin/mdformat \
|
|
|
|
--prefix PYTHONPATH : "${package}/${python3.sitePackages}:$PYTHONPATH"
|
|
|
|
ln -sfv ${package}/lib $out/lib
|
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = package.propagatedBuildInputs ++ plugins;
|
|
|
|
|
|
|
|
passthru = package.passthru // {
|
|
|
|
withPlugins = morePlugins: withPlugins (morePlugins ++ plugins);
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.mainProgram = "mdformat";
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
package = buildPythonPackage rec {
|
|
|
|
pname = "mdformat";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "0.7.17";
|
2023-07-15 17:15:38 +00:00
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "executablebooks";
|
|
|
|
repo = pname;
|
2023-10-09 19:29:22 +00:00
|
|
|
rev = "refs/tags/${version}";
|
|
|
|
hash = "sha256-umtfbhN6sDR/rFr1LwmJ21Ph9bK1Qq43bmMVzGCPD5s=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
poetry-core
|
|
|
|
setuptools
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
markdown-it-py
|
|
|
|
tomli
|
|
|
|
] ++ lib.optionals (pythonOlder "3.10") [
|
|
|
|
importlib-metadata
|
|
|
|
] ++ lib.optionals (pythonOlder "3.7") [
|
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
# AssertionError
|
|
|
|
"test_no_codeblock_trailing_newline"
|
|
|
|
# Issue with upper/lower case
|
|
|
|
"default_style.md-options0"
|
|
|
|
];
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"mdformat"
|
|
|
|
];
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
passthru = { inherit withPlugins; };
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "CommonMark compliant Markdown formatter";
|
|
|
|
homepage = "https://mdformat.rtfd.io/";
|
2023-10-09 19:29:22 +00:00
|
|
|
changelog = "https://github.com/executablebooks/mdformat/blob/${version}/docs/users/changelog.md";
|
2023-07-15 17:15:38 +00:00
|
|
|
license = with licenses; [ mit ];
|
|
|
|
maintainers = with maintainers; [ fab aldoborrero ];
|
2023-08-10 07:59:29 +00:00
|
|
|
mainProgram = "mdformat";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
2023-08-10 07:59:29 +00:00
|
|
|
in
|
|
|
|
package
|