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

Minimize closure with `keep-derivations = false` #13

Open
wants to merge 1 commit into
base: master
from

Conversation

@Infinisil
Copy link
Member

@Infinisil Infinisil commented Feb 6, 2020

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 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

@Infinisil Infinisil commented Feb 7, 2020

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 Infinisil force-pushed the Infinisil:nix-build-shell branch from 036554e to 801231b Feb 7, 2020
@Infinisil
Copy link
Member Author

@Infinisil Infinisil commented Feb 7, 2020

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 Infinisil force-pushed the Infinisil:nix-build-shell branch from 801231b to c798344 Feb 7, 2020
@Infinisil
Copy link
Member Author

@Infinisil Infinisil commented Feb 7, 2020

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

@Infinisil Infinisil commented Feb 18, 2020

Ping?

@peti
Copy link
Member

@peti 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.