Racket installation with Nix (Newbie)


Complete noob here, learning both nix and starting racket at the same time - might not be a good idea.

I installed Racket using nix, below is my derivation to install it

  pkgs = import <nixpkgs> { };
pkgs.mkShell {
  buildInputs = [

I ran racket - played around with the repl and things looked good. I ran drracket which resulted in ffi-lib error

ffi-lib: could not load foreign library
  path: libX11.6.dylib

Update my nix derivation

  pkgs = import <nixpkgs> { };
pkgs.mkShell {
  buildInputs = [

This both installs libX11 and set up the library load path environment variable. At this point I tried drracket again with no luck - same error.

After browsing documentation and blog posts I came to the conclusion that I might need additional changes to the configuration

This is the configuration code/dictionary set up by nix when installing racket

;; generated by unixstyle-install
      (doc-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/doc/racket")
      (lib-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/lib/racket")
      (pkgs-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/racket/pkgs")
      (share-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/racket")
      (include-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/include/racket")
      (bin-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/bin")
      (apps-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/applications")
      (man-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/man")
      (absolute-installation? . #t)
      (compiled-file-roots . (same "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/lib/racket/compiled"))
      (build-stamp . "")
      (doc-search-url . "https://download.racket-lang.org/releases/8.8/doc/local-redirect/index.html")
      (catalogs . ("https://download.racket-lang.org/releases/8.8/catalog/" #f))

What (in) or how do I update the configuration for racket to look at environment load path?

I understand this might be a question that is more nix centric. Attempt to ask a question here because my belief that racket configuration can be updated to use the LD_LIBRARY_PATH


Output from racket

➜  tspl git:(main) ✗ racket                                                                                                                               ~/workspace/tspl
Welcome to Racket v8.8 [cs].
> (require setup/dirs)
> (get-lib-search-dirs)

It does not see the LD_LIBRARY_PATH env var

➜  tspl git:(main) ✗ echo $LD_LIBRARY_PATH                                                                                                                ~/workspace/tspl

I'm sorry I don't know much about Nix.

There is building guidance at 1 Building Racket from Source

I hope this helps.

Best regards,

Thank you. I think it has more to do with how racket looks for dynamic libraries to load. I will take a look a the building from source link.

1 Like

I did get to the point that racket found the library using DYLD_LIBRARY_PATH but got a memory corruption run time error the version I had of X11 wasn't right.

At that point I was wasting time on Nix dependencies. I decide to install the from the racket distribution. For anyone who comes after me the Nix package definition for racket needs a lot more work and probably not the right place to start.

1 Like

Thanks @maddalab for this report. I've made some suggestions for the Nix package maintainers over at Racket FFI can't find external libraries · Issue #209660 · NixOS/nixpkgs · GitHub.

1 Like