diff --git a/pkgs/by-name/md/mdformat/package.nix b/pkgs/by-name/md/mdformat/package.nix new file mode 100644 index 000000000000..24cbd66d864c --- /dev/null +++ b/pkgs/by-name/md/mdformat/package.nix @@ -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: [ ]) diff --git a/pkgs/development/python-modules/mdformat-admon/default.nix b/pkgs/development/python-modules/mdformat-admon/default.nix index a7fd0f940373..3db893042d88 100644 --- a/pkgs/development/python-modules/mdformat-admon/default.nix +++ b/pkgs/development/python-modules/mdformat-admon/default.nix @@ -1,54 +1,42 @@ { lib , buildPythonPackage , fetchFromGitHub +, flit-core , mdformat -, python3 +, mdit-py-plugins +, pytestCheckHook , pythonOlder }: -let - python = python3.override { - packageOverrides = self: super: { - mdit-py-plugins = super.mdit-py-plugins.overridePythonAttrs (_prev: rec { - version = "0.4.0"; - doCheck = false; - src = fetchFromGitHub { - owner = "executablebooks"; - repo = "mdit-py-plugins"; - rev = "refs/tags/v${version}"; - hash = "sha256-YBJu0vIOD747DrJLcqiZMHq34+gHdXeGLCw1OxxzIJ0="; - }; - }); - }; - }; -in python.pkgs.buildPythonPackage rec { +buildPythonPackage rec { pname = "mdformat-admon"; version = "1.0.2"; - format = "pyproject"; + pyproject = true; - disabled = pythonOlder "3.7"; + disabled = pythonOlder "3.8"; src = fetchFromGitHub { owner = "KyleKing"; - repo = pname; + repo = "mdformat-admon"; rev = "v${version}"; hash = "sha256-33Q3Re/axnoOHZ9XYA32mmK+efsSelJXW8sD7C1M/jU="; }; - nativeBuildInputs = with python.pkgs; [ + nativeBuildInputs = [ flit-core ]; - buildInputs = with python.pkgs; [ + propagatedBuildInputs = [ mdformat - ]; - - propagatedBuildInputs = with python.pkgs; [ mdit-py-plugins ]; + nativeCheckInputs = [ + pytestCheckHook + ]; + meta = with lib; { - description = "mdformat plugin for admonitions"; + description = "Mdformat plugin for admonitions"; homepage = "https://github.com/KyleKing/mdformat-admon"; license = licenses.mit; maintainers = with maintainers; [ aldoborrero ]; diff --git a/pkgs/development/python-modules/mdformat-beautysh/default.nix b/pkgs/development/python-modules/mdformat-beautysh/default.nix index a117fea936eb..940e4754c270 100644 --- a/pkgs/development/python-modules/mdformat-beautysh/default.nix +++ b/pkgs/development/python-modules/mdformat-beautysh/default.nix @@ -13,7 +13,7 @@ buildPythonPackage rec { pname = "mdformat-beautysh"; version = "0.1.1"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -28,16 +28,13 @@ buildPythonPackage rec { poetry-core ]; - buildInputs = [ + propagatedBuildInputs = [ + beautysh mdformat mdformat-gfm mdit-py-plugins ]; - propagatedBuildInputs = [ - beautysh - ]; - nativeCheckInputs = [ pytestCheckHook ]; diff --git a/pkgs/development/python-modules/mdformat-footnote/default.nix b/pkgs/development/python-modules/mdformat-footnote/default.nix index 4d7b56f0c2fa..4d452ce5e452 100644 --- a/pkgs/development/python-modules/mdformat-footnote/default.nix +++ b/pkgs/development/python-modules/mdformat-footnote/default.nix @@ -12,7 +12,7 @@ buildPythonPackage rec { pname = "mdformat-footnote"; version = "0.1.1"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -27,7 +27,7 @@ buildPythonPackage rec { flit-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat mdit-py-plugins ]; diff --git a/pkgs/development/python-modules/mdformat-frontmatter/default.nix b/pkgs/development/python-modules/mdformat-frontmatter/default.nix index 333cb5651130..ee2fe29693b2 100644 --- a/pkgs/development/python-modules/mdformat-frontmatter/default.nix +++ b/pkgs/development/python-modules/mdformat-frontmatter/default.nix @@ -28,12 +28,9 @@ buildPythonPackage rec { flit-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat mdit-py-plugins - ]; - - propagatedBuildInputs = [ ruamel-yaml ]; @@ -42,7 +39,7 @@ buildPythonPackage rec { ]; meta = with lib; { - description = "mdformat plugin to ensure frontmatter is respected"; + description = "Mdformat plugin to ensure frontmatter is respected"; homepage = "https://github.com/butler54/mdformat-frontmatter"; changelog = "https://github.com/butler54/mdformat-frontmatter/blob/v{version}/CHANGELOG.md"; license = licenses.mit; diff --git a/pkgs/development/python-modules/mdformat-gfm/default.nix b/pkgs/development/python-modules/mdformat-gfm/default.nix index 90cb3b357841..15a79eb0f4ca 100644 --- a/pkgs/development/python-modules/mdformat-gfm/default.nix +++ b/pkgs/development/python-modules/mdformat-gfm/default.nix @@ -29,14 +29,11 @@ buildPythonPackage rec { poetry-core ]; - buildInputs = [ - mdformat - markdown-it-py - mdit-py-plugins - ]; - propagatedBuildInputs = [ + markdown-it-py + mdformat mdformat-tables + mdit-py-plugins linkify-it-py ]; diff --git a/pkgs/development/python-modules/mdformat-mkdocs/default.nix b/pkgs/development/python-modules/mdformat-mkdocs/default.nix index b35a1eb348b5..52ad5f97b20e 100644 --- a/pkgs/development/python-modules/mdformat-mkdocs/default.nix +++ b/pkgs/development/python-modules/mdformat-mkdocs/default.nix @@ -27,7 +27,7 @@ buildPythonPackage rec { flit-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat mdformat-gfm mdit-py-plugins @@ -42,7 +42,7 @@ buildPythonPackage rec { ]; meta = with lib; { - description = "mdformat plugin for MkDocs"; + description = "Mdformat plugin for MkDocs"; homepage = "https://github.com/KyleKing/mdformat-mkdocs"; changelog = "https://github.com/KyleKing/mdformat-mkdocs/releases/tag/v${version}"; license = licenses.mit; diff --git a/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix b/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix index 6323312072ff..d59e09f999e0 100644 --- a/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix +++ b/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix @@ -1,30 +1,37 @@ { lib +, alejandra , buildPythonPackage , fetchFromGitHub , mdformat , poetry-core +, pytestCheckHook , pythonOlder }: buildPythonPackage rec { pname = "mdformat-nix-alejandra"; version = "0.1.0"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; src = fetchFromGitHub { owner = "aldoborrero"; - repo = pname; - rev = "${version}"; + repo = "mdformat-nix-alejandra"; + rev = "refs/tags/${version}"; hash = "sha256-jUXApGsxCA+pRm4m4ZiHWlxmVkqCPx3A46oQdtyKz5g="; }; + postPatch = '' + substituteInPlace mdformat_nix_alejandra/__init__.py \ + --replace-fail '"alejandra"' '"${lib.getExe alejandra}"' + ''; + nativeBuildInputs = [ poetry-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat ]; @@ -32,6 +39,10 @@ buildPythonPackage rec { "mdformat_nix_alejandra" ]; + nativeCheckInputs = [ + pytestCheckHook + ]; + meta = with lib; { description = "Mdformat plugin format Nix code blocks with alejandra"; homepage = "https://github.com/aldoborrero/mdformat-nix-alejandra"; diff --git a/pkgs/development/python-modules/mdformat-simple-breaks/default.nix b/pkgs/development/python-modules/mdformat-simple-breaks/default.nix index c5bbeeb46de9..9bff43e4d402 100644 --- a/pkgs/development/python-modules/mdformat-simple-breaks/default.nix +++ b/pkgs/development/python-modules/mdformat-simple-breaks/default.nix @@ -10,7 +10,7 @@ buildPythonPackage rec { pname = "mdformat-simple-breaks"; version = "0.0.1"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -25,7 +25,7 @@ buildPythonPackage rec { flit-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat ]; @@ -34,7 +34,7 @@ buildPythonPackage rec { ]; meta = with lib; { - description = "mdformat plugin to render thematic breaks using three dashes"; + description = "Mdformat plugin to render thematic breaks using three dashes"; homepage = "https://github.com/csala/mdformat-simple-breaks"; license = licenses.mit; maintainers = with maintainers; [ aldoborrero ]; diff --git a/pkgs/development/python-modules/mdformat-tables/default.nix b/pkgs/development/python-modules/mdformat-tables/default.nix index 018371ada82f..cfd468d9cc6e 100644 --- a/pkgs/development/python-modules/mdformat-tables/default.nix +++ b/pkgs/development/python-modules/mdformat-tables/default.nix @@ -11,7 +11,7 @@ buildPythonPackage rec { pname = "mdformat-tables"; version = "0.4.1"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -26,7 +26,7 @@ buildPythonPackage rec { flit-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat ]; diff --git a/pkgs/development/python-modules/mdformat-toc/default.nix b/pkgs/development/python-modules/mdformat-toc/default.nix index 56d7ce69a0d4..1597dcec197a 100644 --- a/pkgs/development/python-modules/mdformat-toc/default.nix +++ b/pkgs/development/python-modules/mdformat-toc/default.nix @@ -11,7 +11,7 @@ buildPythonPackage rec { pname = "mdformat-toc"; version = "0.3.0"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -26,7 +26,7 @@ buildPythonPackage rec { poetry-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat ]; diff --git a/pkgs/development/python-modules/mdformat/default.nix b/pkgs/development/python-modules/mdformat/default.nix index a25a632f5150..eec56ee47944 100644 --- a/pkgs/development/python-modules/mdformat/default.nix +++ b/pkgs/development/python-modules/mdformat/default.nix @@ -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"; + }; +}