From 6aa630437f937505fb72a28001a8ee2df6339072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:13:22 -0800 Subject: [PATCH 01/13] python311Packages.mdformat-admon: don't override and propagate dependencies --- .../python-modules/mdformat-admon/default.nix | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/pkgs/development/python-modules/mdformat-admon/default.nix b/pkgs/development/python-modules/mdformat-admon/default.nix index a7fd0f940373..6c02ef8266dd 100644 --- a/pkgs/development/python-modules/mdformat-admon/default.nix +++ b/pkgs/development/python-modules/mdformat-admon/default.nix @@ -1,30 +1,16 @@ { lib , buildPythonPackage , fetchFromGitHub +, flit-core , mdformat -, python3 +, mdit-py-plugins , 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"; @@ -35,20 +21,17 @@ in python.pkgs.buildPythonPackage rec { 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 ]; 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 ]; From ef637c6e8a09ed8c9ddbfe28c6caadbd91a87639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:14:09 -0800 Subject: [PATCH 02/13] python311Packages.mdformat-beautysh: propagate dependencies --- .../python-modules/mdformat-beautysh/default.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 ]; From 6b91fd45ca40f45d445c85356628336ce7d6e2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:11:14 -0800 Subject: [PATCH 03/13] python311Packages.mdformat-footnote: propagate dependencies --- pkgs/development/python-modules/mdformat-footnote/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ]; From f83bb37a0bbb729f4c8e0eb9031d071a3c008e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:15:04 -0800 Subject: [PATCH 04/13] python311Packages.mdformat-frontmatter: propagate dependencies --- .../python-modules/mdformat-frontmatter/default.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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; From fb5f409d2dc78dc3bf9de5fb3cb5778058551255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:15:43 -0800 Subject: [PATCH 05/13] python311Packages.mdformat-gfm: propagate dependencies --- pkgs/development/python-modules/mdformat-gfm/default.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 ]; From 699f0073d340ecfcb356851f387dab74351a2f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:16:08 -0800 Subject: [PATCH 06/13] python311Packages.mdformat-mkdocs: propagate dependencies --- pkgs/development/python-modules/mdformat-mkdocs/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From caef5a82a25e8d7d913c120386bbc2781d55e80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:16:49 -0800 Subject: [PATCH 07/13] python311Packages.mdformat-nix-alejandra: propagate dependencies --- .../python-modules/mdformat-nix-alejandra/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix b/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix index 6323312072ff..a5688b2a3afe 100644 --- a/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix +++ b/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix @@ -9,7 +9,7 @@ buildPythonPackage rec { pname = "mdformat-nix-alejandra"; version = "0.1.0"; - format = "pyproject"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -24,7 +24,7 @@ buildPythonPackage rec { poetry-core ]; - buildInputs = [ + propagatedBuildInputs = [ mdformat ]; From 4f022fe55f850ae111ce6b02f3d9b7170353a783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:17:44 -0800 Subject: [PATCH 08/13] python311Packages.mdformat-simple-breaks: propagate dependencies --- .../python-modules/mdformat-simple-breaks/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 ]; From 6d97f6ba8933a23c4a91da8cb8eae08f5ec7f901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:19:41 -0800 Subject: [PATCH 09/13] python311Packages.mdformat-tables: propagate dependencies --- pkgs/development/python-modules/mdformat-tables/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ]; From f8a2e6f1ff39f02a9a54f80a735ea0048ec20d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:20:05 -0800 Subject: [PATCH 10/13] python311Packages.mdformat-toc: propagate dependencies --- pkgs/development/python-modules/mdformat-toc/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ]; From f7205efda36e6cc54c4e791a346a0e44cfd59f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 16:56:29 -0800 Subject: [PATCH 11/13] mdformat: move withPlugins to top-level attribute --- pkgs/by-name/md/mdformat/package.nix | 28 +++++ .../python-modules/mdformat/default.nix | 118 ++++++------------ 2 files changed, 66 insertions(+), 80 deletions(-) create mode 100644 pkgs/by-name/md/mdformat/package.nix 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/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"; + }; +} From 414ddac8a4b74ed0da8fb9e68127362fddfbffb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 17:20:41 -0800 Subject: [PATCH 12/13] python311Packages.mdformat-nix-alejandra: hardcode path to alejandra --- .../mdformat-nix-alejandra/default.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix b/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix index a5688b2a3afe..d59e09f999e0 100644 --- a/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix +++ b/pkgs/development/python-modules/mdformat-nix-alejandra/default.nix @@ -1,8 +1,10 @@ { lib +, alejandra , buildPythonPackage , fetchFromGitHub , mdformat , poetry-core +, pytestCheckHook , pythonOlder }: @@ -15,11 +17,16 @@ buildPythonPackage rec { 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 ]; @@ -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"; From 97cbadde8a3b7c81f00f0c1d1715045051690ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 7 Feb 2024 17:26:34 -0800 Subject: [PATCH 13/13] python311Packages.mdformat-admon: run tests --- .../python-modules/mdformat-admon/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/mdformat-admon/default.nix b/pkgs/development/python-modules/mdformat-admon/default.nix index 6c02ef8266dd..3db893042d88 100644 --- a/pkgs/development/python-modules/mdformat-admon/default.nix +++ b/pkgs/development/python-modules/mdformat-admon/default.nix @@ -4,6 +4,7 @@ , flit-core , mdformat , mdit-py-plugins +, pytestCheckHook , pythonOlder }: @@ -12,11 +13,11 @@ buildPythonPackage rec { version = "1.0.2"; 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="; }; @@ -30,6 +31,10 @@ buildPythonPackage rec { mdit-py-plugins ]; + nativeCheckInputs = [ + pytestCheckHook + ]; + meta = with lib; { description = "Mdformat plugin for admonitions"; homepage = "https://github.com/KyleKing/mdformat-admon";