-
Notifications
You must be signed in to change notification settings - Fork 11
chore: add devbox integration #38
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
chore: add devbox integration #38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @seanstrom !
Some minor feedback.
Also; when I run devbox shell and then stack ghci I see this error printed out about 120 times:
gcc: error: unrecognized command-line option '--target=arm64-apple-darwin'
Any idea why? I see gcc is version pinned, I guess latest had some issues?
| # Automatically sets up your devbox environment whenever you cd into this | ||
| # directory via our direnv integration: | ||
|
|
||
| eval "$(devbox generate direnv --print-envrc)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice, but I don't think this should be the default for direnv, as I think more folks use direnv than they do devbox so the first thing they'd get greeted with is an odd error upon entering the project dir.
Happy to keep it as .envrc-devbox and add a note in the readme that a devbox setup is available and that optionally you can also use it automatically with direnv if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah good point!
I'll rename the file to .envrc-devbox and update the docs too 👍
I think this error happens when dependencies use the GCC compiler and attempt to cross-compile. I recall reading that GCC doesn't support the flag At the moment, I'm not able to reproduce that issue again, so I'll need a moment to figure out how to reset my env to test this again. In the mean time, maybe try overriding / exporting an environment variable like: On a side note, what is the reason for needing GCC in this project? Would Clang be okay for compiling the dependencies? |
|
It's a long time since I set things up so I don't recall if gcc specifically was required. Just tried running a recompile in ghci and that seems to have a hard failure if that helps repro; |
|
@supermario I've pushed up some changes that should set the desired C compiler to be Clang during compilation. Can you pull down these changes and try re-entering the devbox shell? Also it would be good to confirm what running: |
|
@seanstrom hrm different issue now 🤔 $ stack install
[1 of 2] Compiling Main ( /Users/mario/.stack/setup-exe-src/setup-CKvAmRb3.hs, /Users/mario/.stack/setup-exe-src/setup-CKvAmRb3.o )
gcc: error: unrecognized command-line option '--target=arm64-apple-darwin'
`gcc' failed in phase `Assembler'. (Exit code: 1)
Error: [S-6374]
While building simple Setup.hs (scroll up to its section to see the error) using:
/Users/mario/.ghcup/ghc/9.2.8/bin/ghc -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.6.3.0 /Users/mario/.stack/setup-exe-src/setup-CKvAmRb3.hs /Users/mario/.stack/setup-exe-src/setup-shim-CKvAmRb3.hs -o /Users/mario/.stack/setup-exe-cache/aarch64-osx/tmp-Cabal-simple_CKvAmRb3_3.6.3.0_ghc-9.2.8
Process exited with code: ExitFailure 1$ echo $CC
clang
$ which `echo $CC`
/nix/store/wkadfwbhn9b4kdih88j7izzy20qw79bk-clang-wrapper-19.1.5/bin/clang |
|
@supermario Alrighty I think I've figured out what's been going on, and I hope to have a solution too. I think the gist of the issue stems from how Stack is installing GHC and how GHC is possibly linked to a different C compiler. So in this case, I think we need to configure Stack to avoid installing a separate GHC and use one that's provided by the Devbox environment. Currently, the setup that I'm experimenting with involves using Nix-Flakes to configure the devbox environment with some extra overrides. For example, I'm using a flake to override stack to not install GHC, and I'm using the flake to pin the given GHC version to 9.2.8 (which matches the Overall, I think this solution is promising, but it did require a fair amount of tinkering to resolve multiple issues related to Nix, GHC, Apple C Header files, and etc. The good news is that I can now compile the project inside Hopefully these new changes resolve those compilation issues you mentioned, please let me know how it goes and what you think when you have a chance 🙏 |
|
Hey @seanstrom – that appears to be working for me now! I was able to build a binary; One last odd thing is this; My guess would be this is because I'm on MacOS 14.4 and my Unsure if that has any impact, but I'm happy to merge as is for now if you're unsure the cause of this. |
|
@supermario great to hear that this is working 🙌 About the linking warning you mentioned:
I'm pretty sure this is because we're using the 11.0 Apple headers in the devbox environment, but I think 14.0 is available in NixPkgs, so we would just need to find a way to dynamically choose the best Apple headers for the environment based on the host macOS version. This might be complicated to do, but it could be a simple change, just need to read through some nix stuff since I imagine someone has needed to do this kind of thing before. |
|
@seanstrom okay cool – I'll merge this in for now as it's a great start anyway, and if you find any insight on dynamically selecting apple libs then another PR would be 👌 Thank you! |
Summary
.envrcfile for integrating Direnv with Devbox. This is an optional feature, but it can be convenient for entering a Devbox workspace and automatically have the shell env prepared.stack install,stack build, andstack ghci.