Skip to content

Build the workspace in the flake #2200

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 6 commits into
base: master
Choose a base branch
from
Open

Build the workspace in the flake #2200

wants to merge 6 commits into from

Conversation

jneem
Copy link
Member

@jneem jneem commented Mar 28, 2025

This changes the nix packages so that they build the whole workspace instead of going package-by-package. Because of the way feature unification works in cargo, this should reduce the number of times we need to build dependencies.

As a consequence, this also runs more tests in CI: nix flake check now runs the tests for all crates, not just the few that we selected.

It may be possible to get back to package-by-package builds in the future, since cargo would like to improve this on their end: https://rust-lang.github.io/rfcs/3692-feature-unification.html

Copy link
Contributor

github-actions bot commented Mar 28, 2025

@jneem jneem marked this pull request as ready for review April 3, 2025 02:46
@jneem jneem requested a review from yannham April 3, 2025 02:50
@jneem jneem force-pushed the flake-build-workspace branch from 9c55b63 to e65a1de Compare April 18, 2025 07:39
Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Do we have any way of measuring, quantitatively or qualitatively the effect of this PR? I always find it a bit hard to know if this has any positive or negative effects, given that the CI run time is also impacted by previous caching. We still seem to build a lot of things in the action, but is it less or more than before? 🤷‍♂️

buildStaticPackage = { pnameSuffix, cargoPackage, extraBuildArgs ? "", extraArgs ? { } }:
(buildPackage {
inherit pnameSuffix cargoPackage;
buildStaticWorkspace = { pnameSuffix, extraBuildArgs ? "", extraArgs ? { } }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a detail but the ability to decouple pnameSuffix from the original cargo package name had a small upside, which is that the derivations would exhibit more specific names (nickel-lang-cli-pkg for example, instead of just nickel-lang-cli). It's not very important, but was reason for sometimes having a pnameSuffix that doesn't match precisely the package name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand: we don't use cargo package names anymore, so why would we need to decouple them from suffices? We can still have derivations with more specific names (like nickel-lang-pkg vs nickel-lang)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, my point I guess is that as it is, this PR will show nickel-lang-cli> in the logs for both nickel-lang-cli and nickel-lang-cli-pkg, while it didn't use to be the case, is that correct? I agree that we don't really care about the pnameSuffix mechanism in particular.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think the latest version is using pnameSuffix correctly now.

@jneem
Copy link
Member Author

jneem commented Apr 18, 2025

is it less or more than before?

Good question, I'll see if I can measure this somehow

@jneem
Copy link
Member Author

jneem commented Apr 21, 2025

I can confirm that this approach reduces the size of the cached cargo dependencies. Previously, I had

3.7M /nix/store/1pbz3gqq1vfykwjs3h408s404655i2yr-nickel-lang-core-lalrpop-1.11.0/target.tar.zst
851M /nix/store/1pbz3gqq1vfykwjs3h408s404655i2yr-nickel-lang-core-lalrpop-1.11.0/target.tar.zst.prev

After this patch, I have

151M /nix/store/9g01s3srgj6zd0fhv1k0zl38041ilv83-nickel-lang-core-lalrpop-1.11.0/target.tar.zst
429M /nix/store/9g01s3srgj6zd0fhv1k0zl38041ilv83-nickel-lang-core-lalrpop-1.11.0/target.tar.zst.prev

So, 850M -> 580M.

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.

2 participants