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

dealing with Cabal "data-files" when minimizing closures #12

Open
shajra opened this issue Jan 28, 2017 · 7 comments
Open

dealing with Cabal "data-files" when minimizing closures #12

shajra opened this issue Jan 28, 2017 · 7 comments

Comments

@shajra
Copy link

shajra commented Jan 28, 2017

When minimizing closures, dependencies on projects like ekg that use Cabal "data-files" will have resultant binaries with baked-in references to the shared library of ekg in /nix/store. This makes the transitive closure bloat out again -- even when following the practice of statically linking and copying the final executable into a standalone derivation.

So I ended up doing the hack in this gist: https://gist.github.com/shajra/afed560778a556e487b201b5b4c2ad52

It's definitely a hack, but it works. I tried to figure out a less hacky way to do this with Cabal, but made no real progress.

This is one of those things that's half Haskell, half Nix, so it's not always clear which community to go to first for help. This project seems like a way to get some intersectional conversation.

I'll leave it to @Gabriel439's discretion of how/whether to adjust this project. I don't know if there's a point where advanced topics are more of a distraction than help. Mostly, I wanted feedback. And if we reach a consensus, we can see how it affects the guide or not.

@Gabriella439
Copy link
Owner

This sort of thing is definitely welcome in this project! Give me some time to review this more closely but I would like to include a solution for this if possible

@Gabriella439
Copy link
Owner

@shajra: Have you considered contributing this strings-replace utility upstream to nixpkgs? It seems like something generally useful to add to the standard environment

@shajra
Copy link
Author

shajra commented Jan 29, 2017

@Gabriel439 I just wrote it recently, so I just started vetting it here, but a next step might well be to vet it in nixpkgs. It sounds like the approach makes sense to you, even given what you know about Cabal (which I'm guessing is more than me). Nixpkgs already has enough hair-brained hacks, so I'd hate to push through one more -- only to find out it wasn't really needed.

Someone pointed out a nukeReferences in nixpkgs, which is in a similar vein. strings-replace would probably end up a sibling to it. I'll point this issue to that PR when I make it, and we can both continue the conversation there.

@Gabriella439
Copy link
Owner

So really the right solution is NixOS/nixpkgs#4504. I recommend reading that thread which also discusses this same issue

@shajra
Copy link
Author

shajra commented Jan 29, 2017

Thanks for finding that issue and linking to it. My current thinking is that strings-replace might help us with a stop gap, while they sort out NixOS/nixpkgs#4504. But I'd understand if someone said, "no, let's do this right." In which case, nothing stops me from having an external copy of strings-replace to help me in a pinch. Thanks again, and I'll keep you in the loop.

@shajra
Copy link
Author

shajra commented Jan 31, 2017

@Gabriel439 you may have seen this, but Eelco showed me a nifty replace-literal tool that does something very similar to what I'm doing with strings-replace -- similar enough that I really don't need strings-replace at all.

My example-nix project has this change integrated -- in case you want to see it in play.

I'll leave it to you to leave this issue open or closed as you see fit. Thanks for helping me work this out.

@Gabriella439
Copy link
Owner

I believe this is actually fixed in nixpkgs 17.09. They now support separate data outputs (and newer versions of cabal2nix enable that by default) so that should produce smaller closures

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

No branches or pull requests

2 participants