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

Is Nix a replacement for Stack? #69

Closed
saurabhnanda opened this issue Aug 12, 2016 · 11 comments
Closed

Is Nix a replacement for Stack? #69

saurabhnanda opened this issue Aug 12, 2016 · 11 comments

Comments

@saurabhnanda
Copy link

I don't think this issue is related to reflex-platform, per se, but from a newbies perspective, I'm wondering why this isn't using Stack? Or is it using Stack along with Nix? Why is Nix required? Is Nix only a development time dependency, or will I need to install it on my production servers as well? Also, if I have a Haskell app which works with Stack, how do I build the UI in reflex? Do I need to "Nix-ify" my entire project?

@vyp
Copy link

vyp commented Aug 12, 2016

Nix existed before stack! ;)

Here's a blog post that talks about nix, stack and haskell: http://www.tweag.io/blog/stack-nix-portable-reproducible-builds
HTH!

@saurabhnanda
Copy link
Author

If I understood this correctly, Nix is for handling the stuff that Stack doesn't handle. Nix will delegate Haskell related dependencies to Stack itself. However, why is try-reflex compiling every single Haskell package all over again (I already have them as part of some other Haskell project via Stack).

@BartAdv
Copy link

BartAdv commented Aug 12, 2016

There is some effort to use stack, don't know if it's up-to-date though:
https://github.com/yamafaktory/reflex-starter

Other references:
#35
https://github.com/luigy/try-stack-reflex
https://github.com/reinh/reflex-dom-stack-demo

@saurabhnanda
Copy link
Author

So, right now it's not using stack at all?

@cgibbard
Copy link
Contributor

We don't also use Stack on top of Nix, though one might. The point of
Nix is that it's kind of like Stack, but taken to an extreme where
every system dependency is appropriately hashed and versioned. You
might have built some Haskell packages before outside of the Nix
environment, but they probably wouldn't be byte-for-byte identical to
the ones Nix is building (and it doesn't know about them anyway) and
so it doesn't matter.

Nix can be a bit of a pain with respect to how long things can take to
build when some basic dependency changes in a mostly-inconsequential
way, but in exchange, you get a rather extreme level of
reproducibility, which makes it nice in production as well as when
debugging (you can know that the thing you're running on your machine
is identical to the thing running in production and against which bugs
were reported).

Another thing which this hashing enables is that if the exact
packages you want have already been built by someone else, then you
can get them from a cache server and be quite assured that what you're
getting from the cache is exactly what would have been built if you
did it yourself.

On 12/08/2016, Saurabh Nanda notifications@github.com wrote:

If I understood this correctly, Nix is for handling the stuff that Stack
doesn't handle. Nix will delegate Haskell related dependencies to Stack
itself. However, why is try-reflex compiling every single Haskell package
all over again (I already have them as part of some other Haskell project
via Stack).

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#69 (comment)

@saurabhnanda
Copy link
Author

Well, then this brings me back to my original question. Without stack, how do I use this with an existing stack-ified project? With Intero as my editor?

@BartAdv
Copy link

BartAdv commented Aug 12, 2016

First of all, have you tried the starter reflex app I've linked to?

Anyway, there are probably few options, I remember, once (before intero,
but that doesn't matter), I was having a nix build open that was using
ghcjs to produce real output and stack setup that was using "normal" ghc to
feed me with typechecking errors. In this way, you could even have
stack-with-ghc for intero while producing JS output separately...but that
just seems a bit crazy, doesn't it :)

On Fri, Aug 12, 2016 at 3:53 PM, Saurabh Nanda notifications@github.com
wrote:

Well, then this brings me back to my original question. Without stack, how
do I use this with an existing stack-ified project? With Intero as my
editor?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#69 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAsGhJ-bWfALTIEcZuuGhSsRV_FLVvu7ks5qfHr1gaJpZM4JjAbp
.

@saurabhnanda
Copy link
Author

@BartAdv not tried your links. Want to stick with the most supported/mainstream repo.

@BartAdv
Copy link

BartAdv commented Aug 12, 2016

But reflex-starter-app boils down to stack.yaml file set up to build reflex and ghcjs with stack instead of nix....

@ryantrinkle
Copy link
Member

Nix is a general package manager, which can be used to manage Haskell packages as well as system-level packages (and even the entire OS, in the case of NixOS). It's used here because it was the best way I could find to distribute binaries for everything you need to use Reflex (ghcjs, etc.).

I use Nix because it gives me reproducible builds for everything, locking down the version of everything - system libraries, database software, etc. Since Nix already handles all my package management needs, I don't use stack, cabal-install, or other tools like that to do it. This repo is where I put any useful tools I've built relating to using Nix and reflex together.

If you're working on a serious project with Reflex and you prefer not to use Nix, reflex-platform may not be too useful to you as it currently stands. However, if there are cross-package-manager support features I can add, I'll be happy to do so.

I'm closing this issue because I don't think there's an immediate action to be taken, but please feel free to continue the discussion.

@CMCDragonkai
Copy link

CMCDragonkai commented Feb 21, 2018

It's not clear from the nix documentation when you're on a NixOS platform whether to use stack to run nix, or to use nix to run stack. Most thing seem to think that you're not on NixOS, so nix is just another tool, and that stack is in your profile PATH and you would use stack to run nix. But actually with NixOS, most times one should be using nix-shell to create "mutable" dev environments. So then stack can be brought into that environment. When you're already inside a nix-shell environment that has all the system (non-haskell) dependencies imported, why would you need stack's nix integration? It becomes irrelevant, stack can just be used without knowledge of the fact that it's in a nix environment. Then the whole software project would still be usable by your co-devs who are not using nix.

I wrote the above not really in relation to reflex, but in general regarding the usage of stack and nix.

matthewbauer pushed a commit that referenced this issue Nov 20, 2019
Add macos instructions for setting environment variables for nix daemon
matthewbauer pushed a commit that referenced this issue Nov 20, 2019
Show error message when backend crashes
mzabani pushed a commit to mzabani/reflex-platform that referenced this issue Jun 2, 2020
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

6 participants