Commit fefeed98 authored by Chun Yu's avatar Chun Yu
Browse files

python3Packages.aider-chat: made withOptional a function with parameters

parent fca13125
Loading
Loading
Loading
Loading
+34 −48
Original line number Diff line number Diff line
@@ -188,55 +188,41 @@ 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"
          ];
        }
      );

      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 (
        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 ++ [
          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 [ ];

            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;
          }
        );
    };