reflex-platform
reflex-platform copied to clipboard
Better support for Stack
We currently have a bunch of stuff in reflex-platform that stack users need to replicate in order to get a working setup. We should do something about this.
For anything we're overriding, provide instructions, a stack yaml file, a stack resolver, or something like that; ideally, this should be generated automatically from the nix files so that it stays current Upstream as much as possible into nixpkgs, dependencies, etc.
@ryantrinkle Hey, Ryan. I'm using a custom stack.yaml
file to build reflex-platform
, actually I have stack also for reflex
and reflex-dom
packages. How do you feel about adding stack.yaml
file into this and dependent repos? I can provide those, but they should be in sync with nix updates. I'm not sure if that possible to derive stack file from nix but I image workflow like you change deps or something and ping me, so I can update stack file. Doing similar way on servant-snap
package
@sigrlami That sounds great, but I do think the nix integration is the tricky part. There is a halfway measure possible though: rather than auto-generating the stack.yaml, we could instead write tests that check that it's the same. If the tests fail, I know I need to update stack.yaml. I can take on that maintenance burden - I just can't count on myself to remember to update it 100% of the time, especially when merging other people's PRs.
@ryantrinkle there is page in the docs on integration https://docs.haskellstack.org/en/stable/nix_integration/ but I didn't try them out yet, doing just synchronous config to nix. It's good place to start, I think number of stack users is quite big.
Stack's Nix integration is solely for getting the required versions of GHC and system packages. reflex-platform
uses Nix to change a number of Haskell dependencies, so Stack's Nix integration won't be enough there. Plus, you can't use it with GHCJS.
And it won't work on Windows because Nix doesn't work there.
Stack is pretty much the only sane choice on Windows.
@ElvishJerricco I know but there are non-haskell deps also.
@3noch I use Linux, but for Windows my colleagues are using Docker image. I should provide that too, probably. Production env also docker based
@3noch Nix support for Windows is becoming more feasible, now that Windows Subsystem for Linux is around. However, I definitely wouldn't bet the farm on it yet.
Agreed. Although that's very exciting.
@3noch vagrant also might be an option
There was an issue where we were discussing docker just earlier today :)
@sigrlami True. I suppose with GHCJS you don't really need interop with Windows binaries since it's all just JS.
@sigrlami However, if someone is also writing their "backend" on Windows (for whatever reason) then it would be pretty darn convenient if they didn't have to dish the work to a VM. But beggars can't be choosers I suppose.
@3noch yes, if you build with GHCJS that's fine, but as I remember there are gtk3 deps for reflex-dom
for GHC build.
If @ryantrinkle is ok with having couple more files in repo - docker, vagrant. I can also provide those for Windows users convinience.
@sigrlami Good point. That nightmare wouldn't be worth it. VM is a great solution. :D
@sigrlami I'm definitely OK with having docker and vagrant in the repo, but only if we can make sure they stay up to date - just like the stack stuff. So I think that means we need tests for them, and, ideally, a way of generating them automatically when the nix expressions change.
@ryantrinkle roger that. I'll add tests then. Will provide PR on the weekend, so you can check it out.
@sigrlami Awesome; I look forward to it!
Hey @sigrlami, any update on your ghcjs reflex(-dom) stack.yaml
files?
I've gotten a much older versions working with stack, but I'm attempting to use https://github.com/imalsogreg/servant-reflex and I'm struggling to find anything semi-recent that will build on my machine (macOS).
Any help would be appreciated! (Even if it's just a separate gist for those of use willing to go off the beaten path.)
@SamProtas I got busy with my day job, but I have working local setup with lts-8, will try to publish everything this weekend.
Looking forward to it, thanks!
@sigrlami any update?
Would really love to have that support for stack
resolver: ghc-8.0.2
system-ghc: true
install-ghc: false
Courtesy of @fresheyeball, this is a stack.yaml that seems to allow stack to defer more or less completely to nix; this way, you can run regular stack commands inside a nix shell.
I'm not super familiar with stack personally, but if you try it out and it works for you, maybe we can add this workflow to our test suite so it's officially supported moving forward.
Thanks @ryantrinkle , tried this, getting the following error when running stack install
inside the ./try-reflex
shell (on OSX):
-- While building custom Setup.hs for package frontend-0.1.0 using:
/Users/ababkin/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build exe:frontend --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /Users/ababkin/work/nova/.stack-work/logs/frontend-0.1.0.log
Configuring frontend-0.1.0...
Preprocessing executable 'frontend' for frontend-0.1.0...
[1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/frontend/frontend-tmp/Main.o )
Linking .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/frontend/frontend ...
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_NSURL", referenced from:
objc-class-ref in libHSjsaddle-wkwebview-0.9.4.0-2SHufpCZa9lIA8lareALCO.a(WKWebView.o)
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
It would be very useful if someone writes minimal steps and an example primer app that can get one going with stack
based development. I could do that, but things are not working on my end yet.
my stack.yaml
:
resolver: ghc-8.0.2
system-ghc: true
install-ghc: false
packages:
- 'common'
- 'frontend'
extra-deps:
- protolude-0.2.1
- mtl-compat-0.2.1.3
That error is separate: for OSX binaries, you must always give -threaded and -dynamic; see https://github.com/reflex-frp/reflex-platform/blob/bcb09e6894228792197fad66f03fb61570b371e4/notes/macOS.md
On Sun, Feb 4, 2018 at 3:00 PM, Alex Babkin [email protected] wrote:
Thanks @ryantrinkle https://github.com/ryantrinkle , tried this, getting the following error when running stack install inside the ./try-reflex shell (on OSX):
-- While building custom Setup.hs for package frontend-0.1.0 using: /Users/ababkin/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build exe:frontend --ghc-options " -ddump-hi -ddump-to-file" Process exited with code: ExitFailure 1 Logs have been written to: /Users/ababkin/work/nova/.stack-work/logs/frontend-0.1.0.log
Configuring frontend-0.1.0... Preprocessing executable 'frontend' for frontend-0.1.0... [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/frontend/frontend-tmp/Main.o ) Linking .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/frontend/frontend ... Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_NSURL", referenced from: objc-class-ref in libHSjsaddle-wkwebview-0.9.4.0-2SHufpCZa9lIA8lareALCO.a(WKWebView.o) ld: symbol(s) not found for architecture x86_64 clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation) `cc' failed in phase `Linker'. (Exit code: 1)
It would be very useful if someone writes minimal steps and an example primer app that can get one going with stack based development. I could do that, but things are not working on my end yet.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/reflex-frp/reflex-platform/issues/116#issuecomment-362934798, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGlYK5VMwHqpksyhmIzwoEdVpfKmHDeks5tRgxzgaJpZM4M6kBi .
OK, getting somewhere
changed the stack.yaml
to:
resolver: ghc-8.0.2
system-ghc: true
install-ghc: false
packages:
- 'common'
- 'frontend'
extra-deps:
- protolude-0.2.1
- mtl-compat-0.2.1.3
ghc-options:
frontend:
-dynamic
-threaded
and stack install
has completed successfully
Building all executables for `frontend' once. After a successful build of all of them, only specified executables will be rebuilt.
frontend-0.1.0: configure (exe)
frontend-0.1.0: build (exe)
frontend-0.1.0: copy/register
Log files have been written to: /Users/ababkin/work/nova/.stack-work/logs/
Copying from /Users/ababkin/work/nova/.stack-work/install/x86_64-osx/ghc-8.0.2/8.0.2/bin/frontend to /Users/ababkin/.local/bin/frontend
Copied executables to /Users/ababkin/.local/bin:
- frontend
if i run it, I see an empty WebKit window (i should see some html elements i've added)
I however expect it to create the frontend.jsexe
with index.html
that i could open in a browser
That just means you're building with ghc instead of ghcjs. Make sure
you're in a nix-shell that has ghcjs available (and that ghcjs-pkgs list
shows reflex-dom
among its output). Then, you will probably need to tell
stack to use ghcjs instead of ghc, which I don't know how to do, but I
would hope is easy.
On Sun, Feb 4, 2018 at 3:30 PM, Alex Babkin [email protected] wrote:
OK, getting somewhere changed the stack.yaml to:
resolver: ghc-8.0.2 system-ghc: true install-ghc: false
packages:
- 'common'
- 'frontend'
extra-deps:
- protolude-0.2.1
- mtl-compat-0.2.1.3
ghc-options: frontend: -dynamic -threaded
and stack install has completed successfully
Building all executables for `frontend' once. After a successful build of all of them, only specified executables will be rebuilt. frontend-0.1.0: configure (exe) frontend-0.1.0: build (exe) frontend-0.1.0: copy/register Log files have been written to: /Users/ababkin/work/nova/.stack-work/logs/ Copying from /Users/ababkin/work/nova/.stack-work/install/x86_64-osx/ghc-8.0.2/8.0.2/bin/frontend to /Users/ababkin/.local/bin/frontend
Copied executables to /Users/ababkin/.local/bin:
- frontend
if i run it, I see an empty WebKit window (i should see some html elements i've added)
I however expect it to create the frontend.jsexe with index.html that i could open in a browser
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/reflex-frp/reflex-platform/issues/116#issuecomment-362936962, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGlYA6v5K_a_7mnIkKXWis1lA8wMxzMks5tRhNVgaJpZM4M6kBi .
if i run it, I see an empty WebKit window (i should see some html elements i've added)
If you right-click the webkit window and choose the developer console, is there an error there? I've run into that behavior due to https://github.com/reflex-frp/reflex-platform/issues/209