-
Notifications
You must be signed in to change notification settings - Fork 4
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
Tutorial: Rust FFI in Haskell #24
Conversation
I wanted to write a blog post about this, rather than publishing it as a tutorial in either community.flake.parts or here, as I wanted to describe the entire process, as I debugged, in the form of a story. |
Is this still being written? You also want to,
|
Yes, I have to resume work on this |
Associated repo (I think): https://github.com/shivaraj-bh/haskell-rust-ffi-template |
Additionally change the introduction to be more tutorial-like and add the rust library section. Also, add placeholders for other sections.
It is more appropriate as a tutorial series under Nix for development, so I have made the necessary changes and added placeholders, will be filling them up soon. |
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.
LGTM, after these changes.
en/haskell-rust-ffi.md
Outdated
nixpkgs_url="github:nixos/nixpkgs/$(nix flake metadata --json | nix run nixpkgs#jq -- '.locks.nodes.nixpkgs.locked.rev' -r)" && \ | ||
nix shell $nixpkgs_url#cabal-install $nixpkgs_url#ghc -c \ | ||
cabal init -n --exe -m --simple hello-haskell |
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.
nixpkgs_url="github:nixos/nixpkgs/$(nix flake metadata --json | nix run nixpkgs#jq -- '.locks.nodes.nixpkgs.locked.rev' -r)" && \ | |
nix shell $nixpkgs_url#cabal-install $nixpkgs_url#ghc -c \ | |
cabal init -n --exe -m --simple hello-haskell | |
nix shell nixpkgs#ghc nixpkgs#cabal-install -c cabal -- init -n --exe -m --simple hello-haskell |
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 will break the further steps in the tutorial, as we are assuming that the .cabal
file generated by cabal-install
in flake:nixpkgs
will work with the nixpkgs
input of the flake in the tutorial.
This was the initial command, but when I was following along the tutorial it fails, as constraints on base
depends on GHC
version, which can be different based on the nixpkgs commit. I doubt there is a way to cabal init
without any constraints on the base
package.
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.
Pass -d base
option?
❯ nix shell nixpkgs#ghc nixpkgs#cabal-install -c cabal -- init -n --exe -m --simple -d base --overwrite
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
[Log] Using cabal specification: 3.0
[Warning] unknown license type, you must put a copy in LICENSE yourself.
[Log] CHANGELOG.md already exists. Backing up old version in CHANGELOG.md.save0
[Log] Overwriting file CHANGELOG.md...
[Log] app already exists. Backing up old version in app.save1
[Log] Overwriting directory ./app...
[Log] Creating fresh file app/Main.hs...
[Log] hello-haskell.cabal already exists. Backing up old version in hello-haskell.cabal.save0
[Log] Overwriting file hello-haskell.cabal...
[Warning] No synopsis given. You should edit the .cabal file and add one.
[Info] You may want to edit the .cabal file and add a Description field.
srid on appreciate.intern /tmp/hello-haskell via λ
❯ rg base *.cabal
14: build-depends: base
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.
Thanks!
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.
Co-authored-by: Sridhar Ratnakumar <[email protected]>
Co-authored-by: Sridhar Ratnakumar <[email protected]>
Co-authored-by: Sridhar Ratnakumar <[email protected]>
Co-authored-by: Sridhar Ratnakumar <[email protected]>
Co-authored-by: Sridhar Ratnakumar <[email protected]>
Co-authored-by: Sridhar Ratnakumar <[email protected]>
… haskell-rust-ffi
@shivaraj-bh Feel free to announce in https://twitter.com/nixos_asia, Zulip, and elsewhere as you see fit. |
I probably should’ve linked this earlier here, but I was waiting on this before merging: srid/haskell-flake#283 (comment) |
Okay let's announce it after I fix that issue. |
@srid could you generate an image for this article? |
preview: