From fefeed987af810fd92a8cb3463647411aaf57be4 Mon Sep 17 00:00:00 2001 From: Chun Yu Date: Fri, 28 Mar 2025 01:52:31 +0800 Subject: [PATCH] python3Packages.aider-chat: made withOptional a function with parameters --- .../python-modules/aider-chat/default.nix | 80 ++++++++----------- 1 file changed, 33 insertions(+), 47 deletions(-) diff --git a/pkgs/development/python-modules/aider-chat/default.nix b/pkgs/development/python-modules/aider-chat/default.nix index d4879ed33c9f..d02baf5434dc 100644 --- a/pkgs/development/python-modules/aider-chat/default.nix +++ b/pkgs/development/python-modules/aider-chat/default.nix @@ -188,57 +188,43 @@ let }; passthru = { - withPlaywright = aider-chat.overridePythonAttrs ( + withOptional = { - dependencies, - makeWrapperArgs, - propagatedBuildInputs ? [ ], + withPlaywright ? false, + withBrowser ? false, + withHelp ? false, + withAll ? false, ... }: - { - dependencies = dependencies ++ aider-chat.optional-dependencies.playwright; - propagatedBuildInputs = propagatedBuildInputs ++ [ playwright-driver.browsers ]; - makeWrapperArgs = makeWrapperArgs ++ [ - "--set PLAYWRIGHT_BROWSERS_PATH ${playwright-driver.browsers}" - "--set PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true" - ]; - } - ); + aider-chat.overridePythonAttrs ( + { + dependencies, + makeWrapperArgs, + propagatedBuildInputs ? [ ], + ... + }: + let + playwrightDeps = + if withPlaywright || withAll then aider-chat.optional-dependencies.playwright else [ ]; + browserDeps = if withBrowser || withAll then aider-chat.optional-dependencies.browser else [ ]; + helpDeps = if withHelp || withAll then aider-chat.optional-dependencies.help else [ ]; - withBrowser = aider-chat.overridePythonAttrs ( - { dependencies, ... }: - { - dependencies = dependencies ++ aider-chat.optional-dependencies.browser; - } - ); - - withHelp = aider-chat.overridePythonAttrs ( - { dependencies, ... }: - { - dependencies = dependencies ++ aider-chat.optional-dependencies.help; - } - ); - - withOptional = aider-chat.overridePythonAttrs ( - { - dependencies, - makeWrapperArgs, - propagatedBuildInputs ? [ ], - ... - }: - { - dependencies = - dependencies - ++ aider-chat.optional-dependencies.playwright - ++ aider-chat.optional-dependencies.browser - ++ aider-chat.optional-dependencies.help; - propagatedBuildInputs = propagatedBuildInputs ++ [ playwright-driver.browsers ]; - makeWrapperArgs = makeWrapperArgs ++ [ - "--set PLAYWRIGHT_BROWSERS_PATH ${playwright-driver.browsers}" - "--set PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true" - ]; - } - ); + playwrightInputs = if withPlaywright || withAll then [ playwright-driver.browsers ] else [ ]; + playwrightArgs = + if withPlaywright || withAll then + [ + "--set PLAYWRIGHT_BROWSERS_PATH ${playwright-driver.browsers}" + "--set PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true" + ] + else + [ ]; + in + { + dependencies = dependencies ++ playwrightDeps ++ browserDeps ++ helpDeps; + propagatedBuildInputs = propagatedBuildInputs ++ playwrightInputs; + makeWrapperArgs = makeWrapperArgs ++ playwrightArgs; + } + ); }; meta = {