Skip to content
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

Nix language support improvements, including smaller Cachix #1352

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

therealpxc
Copy link
Contributor

This fix saves 7 GB in the closure size of my devenv projects which have Nix language support enabled.

Background: Currently, with languages.nix.enable = true;, all outputs of the cachix package in Nixpkgs get installed. Unlike the Cachix package provided by the cachix/cachix flake, this is a massive multi-output derivation that includes a huge Haskell runtime with libs in .out and more than a gigabyte of library documentation in .doc.

The original issue here raises some questions for me about how devenv profiles are constructed and whether they do or should honor meta.outputsToInstall-- maybe there's something to think about there, too. (The Cachix package in nixpkgs has only "bin" in meta.outputsToInstall.)

Anyway, this fix works now and is a huge quality of life improvement for me!

@domenkozar
Copy link
Member

Maybe we should just use devenv.bin?

@therealpxc therealpxc changed the title use smaller Cachix package, make Cachix package configurable Nix language support improvements, including smaller Cachix Jul 31, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@domenkozar you wrote:

Maybe we should just use devenv.bin?

You mean cachix.bin? Devenv doesn't have a bin output either in Nixpkgs or our flake.

At any rate, that's essentially all we do here: lib.getBin will get the bin output of the provided Cachix derivation, unless it doesn't have one. If it doesn't have one, it'll fall back to cachix.out. This makes the Cachix module compatible both with Cachix from Nixpkgs and Cachix from the github:cachix/cachix flake, which I suppose might be nice if you want old Nixpkgs but new Cachix.

We use string interpolation because lib.getBin actually produces a derivation with some magic that makes it yield the bin output when coerced into a string. Functions that expect derivations will thus end up getting the same old .out as always. The same thing happens when naively putting just cachix.bin in for the package-- you end up with cachix.out and cachix.doc alongside cachix.bin. But interpolate it in a string and you get just the bin output as expected.

@domenkozar domenkozar merged commit 384f935 into cachix:main Aug 1, 2024
267 of 275 checks passed
@therealpxc therealpxc deleted the smaller-cachix-pls branch August 9, 2024 20:56
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