mdformat: move withPlugins to top-level attribute
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
{ lib
|
||||
, python3
|
||||
, runCommand
|
||||
}:
|
||||
|
||||
let
|
||||
python = python3;
|
||||
|
||||
# selector is a function mapping pythonPackages to a list of plugins
|
||||
# e.g. `mdformat.withPlugins (ps: with ps; [ mdformat-footnote ])`
|
||||
withPlugins = selector: runCommand "mdformat-wrapped" {
|
||||
inherit (python.pkgs.mdformat) pname version meta;
|
||||
|
||||
nativeBuildInputs = [
|
||||
python.pkgs.wrapPython
|
||||
];
|
||||
|
||||
plugins = selector python.pkgs;
|
||||
|
||||
passthru = {
|
||||
inherit withPlugins;
|
||||
};
|
||||
} ''
|
||||
buildPythonPath $plugins
|
||||
makeWrapper ${lib.getExe python.pkgs.mdformat} $out/bin/mdformat \
|
||||
--suffix PYTHONPATH : "$program_PYTHONPATH"
|
||||
'';
|
||||
in withPlugins (ps: [ ])
|
||||
@@ -5,99 +5,57 @@
|
||||
, importlib-metadata
|
||||
, makeWrapper
|
||||
, markdown-it-py
|
||||
, poetry-core
|
||||
, pytestCheckHook
|
||||
, python3
|
||||
, pythonOlder
|
||||
, setuptools
|
||||
, tomli
|
||||
, typing-extensions
|
||||
}:
|
||||
|
||||
let
|
||||
withPlugins = plugins: buildPythonApplication {
|
||||
pname = "${package.pname}";
|
||||
inherit (package) version;
|
||||
format = "other";
|
||||
buildPythonPackage rec {
|
||||
pname = "mdformat";
|
||||
version = "0.7.17";
|
||||
pyproject = true;
|
||||
|
||||
disabled = pythonOlder "3.7";
|
||||
disabled = pythonOlder "3.8";
|
||||
|
||||
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";
|
||||
src = fetchFromGitHub {
|
||||
owner = "executablebooks";
|
||||
repo = "mdformat";
|
||||
rev = "refs/tags/${version}";
|
||||
hash = "sha256-umtfbhN6sDR/rFr1LwmJ21Ph9bK1Qq43bmMVzGCPD5s=";
|
||||
};
|
||||
|
||||
package = buildPythonPackage rec {
|
||||
pname = "mdformat";
|
||||
version = "0.7.17";
|
||||
format = "pyproject";
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
];
|
||||
|
||||
disabled = pythonOlder "3.7";
|
||||
propagatedBuildInputs = [
|
||||
markdown-it-py
|
||||
] ++ lib.optionals (pythonOlder "3.11") [
|
||||
tomli
|
||||
] ++ lib.optionals (pythonOlder "3.10") [
|
||||
importlib-metadata
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "executablebooks";
|
||||
repo = pname;
|
||||
rev = "refs/tags/${version}";
|
||||
hash = "sha256-umtfbhN6sDR/rFr1LwmJ21Ph9bK1Qq43bmMVzGCPD5s=";
|
||||
};
|
||||
nativeCheckInputs = [
|
||||
pytestCheckHook
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
poetry-core
|
||||
setuptools
|
||||
];
|
||||
pythonImportsCheck = [
|
||||
"mdformat"
|
||||
];
|
||||
|
||||
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"
|
||||
];
|
||||
|
||||
passthru = { inherit withPlugins; };
|
||||
|
||||
meta = with lib; {
|
||||
description = "CommonMark compliant Markdown formatter";
|
||||
homepage = "https://mdformat.rtfd.io/";
|
||||
changelog = "https://github.com/executablebooks/mdformat/blob/${version}/docs/users/changelog.md";
|
||||
license = with licenses; [ mit ];
|
||||
maintainers = with maintainers; [ fab aldoborrero ];
|
||||
mainProgram = "mdformat";
|
||||
};
|
||||
passthru = {
|
||||
withPlugins = throw "Use pkgs.mdformat.withPlugins, i.e. the top-level attribute.";
|
||||
};
|
||||
in
|
||||
package
|
||||
|
||||
meta = with lib; {
|
||||
description = "CommonMark compliant Markdown formatter";
|
||||
homepage = "https://mdformat.rtfd.io/";
|
||||
changelog = "https://github.com/executablebooks/mdformat/blob/${version}/docs/users/changelog.md";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ fab aldoborrero ];
|
||||
mainProgram = "mdformat";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user