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

Support for Static Linking on Desktop #690

Open
ProofOfKeags opened this issue Sep 26, 2020 · 4 comments
Open

Support for Static Linking on Desktop #690

ProofOfKeags opened this issue Sep 26, 2020 · 4 comments

Comments

@ProofOfKeags
Copy link

It's really cool that I can build an app that compiles to native via webkitgtk, but I also can't use it outside of NixOS because the executable is dynamically linked against the nix store. I'd like to be able to statically link everything except for glibc. It seems that the approach has been that desktop is a fast way to test front ends, but I actually want it to work this way as the end product. Would this be hard to accomplish?

@ryantrinkle
Copy link
Member

In theory, this shouldn't be too hard, and I'm pretty sure some people have done it.

You could try using justStaticExecutables on the frontend Nix derivation, which might get you fairly close. You would probably need to modify the resulting binary to change the glibc path. That might be enough to get you what you need.

One intermediate step that should definitely work straightforwardly would be to use Nix on non-NixOS hosts. This should already be fully supported on Linux and MacOS.

@ProofOfKeags
Copy link
Author

So for what it's worth, I'm not actually developing on NixOS, but rather an Ubuntu based Linux and it's dynamically linking gtk to the nix store. So if it is supported, I'm clearly doing it wrong. What does it mean to "use justStaticExecutables"?

@srid
Copy link
Contributor

srid commented Sep 27, 2020

What does it mean to "use justStaticExecutables"?

See here for example: https://github.com/srid/neuron/blob/746eccc636ca2bca557154c3c3e687aadf97e614/project.nix#L59

It doesn't build a full static binary though, as the resulting binary will still link to core system libraries like libz.

I believe what we need is NixOS/nixpkgs#43795

@ProofOfKeags
Copy link
Author

In genera, I'm OK with partial static compilation. Dynamic dependencies on libz and glibc don't bother me. I'm more concerned about dynamic dependencies on gtk, which there is no reason to believe a user would have on their own. The project I'm making I'd like to make reasonably portable (even to Windows/Mac) and not to have to package it with nix in order for it to work properly. I'd be willing to use reflex without nix in order to accomplish that but my attempts to do so have been thwarted on multiple occasions.

Stack doesn't work very well here due to the reflex libraries not building properly with only adjustments to stack.yaml. I haven't fully grokked exactly why it's failing yet, so I don't have any suggestions as to the cause yet.

As far as going straight cabal (no stack, no nix), I'm intimidated by cabal hell and haven't read enough of the cabal manual yet to know how to approximate stack's behavior using sandboxes.

I'm fully aware that my inability to do this is tied to myself being a n00b at non-stack builds for Haskell. But I'd imagine lowering the barrier to being able to do such things is within the scope of goals for reflex-platform.

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

3 participants