Skip to content

Document optimising multi-member workspace dependency management #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bengsparks
Copy link

When reviewing the list of dependencies that are added to a virtualenv when using

default = util.mkApplication {
  venv = pythonSet.mkVirtualEnv "application-env" workspace.deps.default;
  package = pythonSet.hello-world;
};

you will find that if, you have more than one member in your workspace, all dependencies from all members of the workspace are added. This is not an issue in local development, but will bloat the size of containers when attempting to used the build program for an image, e.g. nix2container or dockerTools.

Instead, by specifying the name of the package that you want your container to hold, you can shrink this down to only what is necessary.

default = util.mkApplication {
  venv = pythonSet.mkVirtualEnv "application-env" {
    app = [ ];
  };
  package = pythonSet.hello-world;
};

NOTE: The content of this PR is adapted from #168 (comment), but documenting something like this explicitly (and perhaps in more places?) would really improve the deployment experience.

@bengsparks bengsparks changed the title Document how to create an application in a workspace with only required deps Document optimising multi-member workspace dependency management May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant