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

Static binaries for releases #183

Closed
2 of 3 tasks
itamarst opened this issue May 14, 2020 · 20 comments
Closed
2 of 3 tasks

Static binaries for releases #183

itamarst opened this issue May 14, 2020 · 20 comments
Assignees
Labels
help wanted Extra attention is needed such-is-nix "Why Nix?", "Nix alternative", etc.
Milestone

Comments

@itamarst
Copy link

itamarst commented May 14, 2020

As someone else commented on lobste.rs, it would be nice to have pre-generated static binaries so users who don't have Nix and Haskell setup don't have to install a whole new toolchain to use Neuron.


[text below added by @srid]

  • Static binaries for Linux (and Windows, through WSL2)
  • Static binaries for macOS
  • Host static binaries for release, and link to from docs
@srid srid added the help wanted Extra attention is needed label May 14, 2020
@srid
Copy link
Owner

srid commented May 14, 2020

I could use some help on this. It seems we will need to use this: https://github.com/nh2/static-haskell-nix#static-haskell-nix

@itamarst
Copy link
Author

itamarst commented May 14, 2020

FWIW a semi-static executable that only depends on libc would probably be fine for most people? Like what you get from Go and Rust, often. Unless you're linking against some other C libraries.

@srid
Copy link
Owner

srid commented May 15, 2020

FWIW, this is what the current executable links to (on linux):

$ ldd (which neuron)
        linux-vdso.so.1 (0x00007ffe79d92000)
        libm.so.6 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libm.so.6 (0x00007f7bb2490000)
        libz.so.1 => /nix/store/3bfzi6w3067hbdyl15vmypjn4q6az9j6-zlib-1.2.11/lib/libz.so.1 (0x00007f7bb2471000)
        liblua.so.5.3 => /nix/store/yaim51rzjyrp2dia8d954fywnwkp77na-lua-5.3.5/lib/liblua.so.5.3 (0x00007f7bb2436000)
        libncursesw.so.6 => /nix/store/zp8v7wkbplvmzyds87icn1rk070hizdc-ncurses-6.1-20190112/lib/libncursesw.so.6 (0x00007f7bb23c4000)
        libpthread.so.0 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libpthread.so.0 (0x00007f7bb23a3000)
        librt.so.1 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/librt.so.1 (0x00007f7bb2397000)
        libutil.so.1 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libutil.so.1 (0x00007f7bb2392000)
        libdl.so.2 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libdl.so.2 (0x00007f7bb238d000)
        libgmp.so.10 => /nix/store/av3zmkb577zk4ds4xhzixdhvdvh726r7-gmp-6.1.2/lib/libgmp.so.10 (0x00007f7bb22f7000)
        libffi.so.6 => /nix/store/j1gs46vkawlk9mz8lc9g0xfi94hwrcv7-libffi-3.2.1/lib/libffi.so.6 (0x00007f7bb22eb000)
        libc.so.6 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libc.so.6 (0x00007f7bb2135000)
        /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/ld-linux-x86-64.so.2 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib64/ld-linux-x86-64.so.2 (0x00007f7bb2628000)

@pjones
Copy link
Contributor

pjones commented Jun 8, 2020

FWIW I've been working on building static Haskell binaries for a couple of weeks now. I bundled all my work into my nix-hs tool. If you're open to the idea of moving this project over to nix-hs I'd be glad to help.

@srid
Copy link
Owner

srid commented Jun 8, 2020

@pjones Note that neuron uses reflex-platform (which has its own nixpkgs pinned), for GHCJS support (all of ./neuron/src/lib must compile on GHCJS) that is required for the upcoming web app (see #182).

That said, for compiling neuron itself we use only GHC (not GHCJS), so in theory it should be possible to support static binary builds in reflex-platform; though it pinning an older nixpkgs version might make it all tricky.

EDIT: neuron doesn't use reflex-platform anymore.

@pjones
Copy link
Contributor

pjones commented Jun 10, 2020

Neither nix-hs nor static-haskell-nix care which pinned version of nixpkgs you are using as long as it can produce a working GHC compiled/linked with musl. I imagine that you'd want to use GHCJS directly (without reaching through static-haskell-nix) but use GHC via the statically compiled route.

When I have some time I'll take a look at the current build system and try to understand it.

@srid srid added the such-is-nix "Why Nix?", "Nix alternative", etc. label Jun 19, 2020
@srid
Copy link
Owner

srid commented Jun 30, 2020

#262 might be a useful step towards this. cf. NixOS/nixpkgs#43795 (comment)

@srid
Copy link
Owner

srid commented Jul 20, 2020

We now have a docker image (autoupdates in CI) that weighs ~100MB: https://neuron.zettel.page/c6176636.html

@hazayan
Copy link

hazayan commented Jul 30, 2020

Static binaries are still an easier way to allow packaging for other distribution / operating systems.

@TanayB11
Copy link

TanayB11 commented Aug 2, 2020

I think that it is extremely important to get binaries going as soon as possible. I love the idea, but I definitely do not want to install a brand new package manager and Haskell support just to run this.

What I love about Neuron is that it's lightweight and portable; while that's definitely true with the markdown files, it's not true with Neuron itself yet. It should be as simple as a brew install or a brew cask install to get going. A Docker image is fine for now, but it won't cut it because on a PC the daemon has to be running 24/7.

@srid srid mentioned this issue Aug 30, 2020
@srid
Copy link
Owner

srid commented Sep 20, 2020

haskell.nix officially supports building static binaries: https://input-output-hk.github.io/haskell.nix/tutorials/cross-compilation/#static-executables-with-musl-libc

not sure if switching to it is worth it.

@srid
Copy link
Owner

srid commented Sep 29, 2020

I managed to produce a static Linux executable:

image

So the upcoming release of Neuron will have static executables, at least for Linux. And possibly macOS as well if I don't hit any annoying issues.

@srid srid self-assigned this Sep 29, 2020
@srid srid pinned this issue Sep 29, 2020
@srid srid added this to the 1.0 milestone Sep 29, 2020
@srid
Copy link
Owner

srid commented Sep 30, 2020

macOS binaries could not be built; see the linked PR comments for details. If somebody wants to give it a try, start by replacing pkgsMusl with pkgsStatic in ./static.nix. Then run nix-build static.nix (it will build for long time).

The upcoming release should contain at minimum Linux static binaries.

@srid srid unpinned this issue Oct 8, 2020
@srid
Copy link
Owner

srid commented Oct 8, 2020

v1.0 got released. The official Linux static binary is linked from here: https://neuron.zettel.page/install.html

I will close this; if somebody wants macOS binaries, let's open a new issue for that.

@srid srid closed this as completed Oct 8, 2020
@RoyiAvital
Copy link

Any chance for a native Static Binaries for Windows?

@srid
Copy link
Owner

srid commented Oct 31, 2020

@RoyiAvital Unlikely, but you can use wsl.exe to run the Linux static binary.

@RoyiAvital
Copy link

The issue is I don't want (Others just can't for instance Windows Home users) to install WSL.
It doesn't make sense to do it for a single application.

What's the blocker for having a static native binary for Windows?

@srid
Copy link
Owner

srid commented Oct 31, 2020 via email

@srid
Copy link
Owner

srid commented Oct 31, 2020

btw, WSL is available for Windows Home users

WSL 2 is available on all SKUs where WSL is currently available, including Windows 10 Home.

https://docs.microsoft.com/en-us/windows/wsl/wsl2-faq

@RoyiAvital
Copy link

@srid , any chance opening a dedicated issue for the Windows support effort?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed such-is-nix "Why Nix?", "Nix alternative", etc.
Projects
None yet
Development

No branches or pull requests

6 participants