unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: jgart <jgart@dismail.de>
To: Hartmut Goebel <h.goebel@crazy-compilers.com>
Cc: Guix Help <help-guix@gnu.org>
Subject: Re: Erlang Development with Guix
Date: Tue, 11 Oct 2022 22:13:31 -0500	[thread overview]
Message-ID: <20221011221331.GB23996@dismail.de> (raw)
In-Reply-To: <b1bf6670-e2f0-b551-4491-e16d82d5d70b@crazy-compilers.com>

On Thu, 30 Jun 2022 11:00:03 +0200 Hartmut Goebel <h.goebel@crazy-compilers.com> wrote:
> The rebar-build-system I created was published just a few weeks ago. 
> Anyhow, I'm not a Erlang/OTP user, so this build-system might still need 
> improvement. Any help on this is welcome.

Hi Hartmut,

Good News!

I found out what environment variable we need to set in order for Guix to find Erlang libraries:

It's ERL_LIBS that needs to be set in order for Erlang to find
installed libraries in /guix/store/.../lib/erlang/lib/

Here's an example of what Nix does:

https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/hex/default.nix#L21

I tested this with a guix shell and erlang-jsx:

https://issues.guix.gnu.org/58458

All I did was enter an erlang repl (erl) and run the following code:

 λ guix shell -D guix --pure
hint: Consider passing the `--check' option once to make sure your shell does not clobber environment variables.

 guix-shell  ./pre-inst-env guix shell erlang erlang-jsx --search-paths --pure
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/python.scm
;;;       newer than compiled /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/python.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/python.scm
;;;       newer than compiled /home/jgart/.guix-profile/lib/guile/3.0/site-ccache/gnu/packages/python.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/erlang.scm
;;;       newer than compiled /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/erlang.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/erlang.scm
;;;       newer than compiled /home/jgart/.guix-profile/lib/guile/3.0/site-ccache/gnu/packages/erlang.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/guix/build-system/rebar.scm
;;;       newer than compiled /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/guix/build-system/rebar.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/guix/build-system/rebar.scm
;;;       newer than compiled /home/jgart/.guix-profile/lib/guile/3.0/site-ccache/guix/build-system/rebar.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/entr.scm
;;;       newer than compiled /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/entr.go
;;; note: source file /home/jgart/7a41616f-b6b7-4643-898b-5771ddf02d32-guix/gnu/packages/entr.scm
;;;       newer than compiled /home/jgart/.guix-profile/lib/guile/3.0/site-ccache/gnu/packages/entr.go

;;; Ignore this. This was printed courtesy of the pk macro ;()
;;; (#<procedure 7fc6c0e41000 at ice-9/eval.scm:333:13 (a)>)
export PATH="/gnu/store/95i56pzs3g1hysaj32c8jzchw5n30fhz-profile/bin"
export XDG_DATA_DIRS="/gnu/store/95i56pzs3g1hysaj32c8jzchw5n30fhz-profile/share"
 guix-shell  ls /gnu/store/95i56pzs3g1hysaj32c8jzchw5n30fhz-profile/bin
ct_run    erl      fc-cache     fc-list     fc-query     freetype-config  png-fix-itxt  to_erl
dialyzer  erlc     fc-cat       fc-match    fc-scan      libpng-config    pngfix        typer
epmd      escript  fc-conflist  fc-pattern  fc-validate  libpng16-config  run_erl       xmlwf
 guix-shell  erl
bash: erl: command not found
(reverse-i-search)`s': ./pre-inst-env guix shell erlang erlang-jsx --search-path^C--pure
 guix-shell   export ERL_LIBS=/gnu/store/95i56pzs3g1hysaj32c8jzchw5n30fhz-profile/lib/erlang/lib
 guix-shell  /gnu/store/95i56pzs3g1hysaj32c8jzchw5n30fhz-profile/bin/erl
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]

Eshell V13.0.4  (abort with ^G)
1> jsx:decode(<<"{\"library\": \"jsx\", \"awesome\": true}">>, []).
#{<<"awesome">> => true,<<"library">> => <<"jsx">>}


As you can see above we don't need to import anything into the repl
because we just namespace with installed library in order to use it. I
think this may be what erlangers normally do at the repl instead of
importing.

See the erlang-jsx README:

https://github.com/talentdeficit/jsx#to-convert-a-utf8-binary-containing-a-json-string-into-an-erlang-term

I'll try to find the time to add setting this environment variable to
the rebar-build-system, otherwise if you'd like to proceed with adding
it that is also fine by me :)

all best,

jgart


      reply	other threads:[~2022-10-12  3:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30  1:27 Erlang Development with Guix jgart
2022-06-30  9:00 ` Hartmut Goebel
2022-10-12  3:13   ` jgart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221011221331.GB23996@dismail.de \
    --to=jgart@dismail.de \
    --cc=h.goebel@crazy-compilers.com \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).