Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Minimize closure with keep-derivations = false #13

Closed
wants to merge 1 commit into from

Conversation

infinisil
Copy link
Member

If this is not done, nix-shell tries to use in NIX_PATH to get
a bash, which is a problem if that doesn't exist.

Also because nix-shell doesn't gcroot the bash it uses from <nixpkgs>, this can lead to it having to build/fetch bash first before it can start, which slows it down a couple seconds.

This increases the image size from 161MB to 175MB (~8%), but considering that bash is something almost always needed I think this is reasonable.

This PR is sponsored by Niteo

@peti
Copy link
Member

peti commented Feb 7, 2020

I have mixed feelings about this change. My intention with this image has always been to provide the smallest possible working nix installation. An image that's particularly well suited for, say, interactive shell use I'd rather define separately on top of this one.

@infinisil
Copy link
Member Author

Apparently there are 2 glibc's in the closure, one of which comes from this installed bash and another from the installed Nix. I'll try to figure out how both can use the same glibc to decrease closure size.

Reduces image size from 161MB to 147MB
@infinisil
Copy link
Member Author

I was able to minimize closure size from 161MB to 149MB, while adding bash at no extra cost :)

This is done by:

  • Using keep-derivations = false
  • Reinstalling Nix and cacert from the available channel to share dependencies with other things installed from the channel

See commits for more details

@infinisil
Copy link
Member Author

After thinking about it some more, what you suggested sounds fine to me. I removed all but the first commit which minimizes the closure a bit more.

@infinisil infinisil changed the title Set NIX_BUILD_SHELL to a persistent bash Minimize closure with keep-derivations = false Feb 7, 2020
@infinisil
Copy link
Member Author

Ping?

@peti
Copy link
Member

peti commented Feb 18, 2020

Sorry for being unresponsive. I have a bad cold and can't do much productive work at the moment. Give me another day or two, please, then I'll revisit this PR!

@garbas
Copy link
Member

garbas commented Dec 15, 2021

With the work in #31 (which was upstreamed to nixos/nix) I think this PR becomes obsolete.

We can look at the closure size of nixos/nix docker image as we would for any other nix derivation. But since we are using multi layered image I'm not sure the size matters as much as it did before.

@garbas garbas closed this Dec 15, 2021
@infinisil infinisil deleted the nix-build-shell branch December 15, 2021 11:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants