all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Remco van 't Veer <remco@remworks.net>
To: Daniel Littlewood <danielittlewood@gmail.com>
Cc: help-guix <help-guix@gnu.org>
Subject: Re: Ruby without RVM - what to do if the version I want is missing?
Date: Sat, 15 Jun 2024 09:43:33 +0200	[thread overview]
Message-ID: <87y176ejmi.fsf@remworks.net> (raw)
In-Reply-To: <CAFDSbVcda1Bw+4J_eiNtfXC=DW5LqbDrMGuAw2Bvd=rmE3RzHw@mail.gmail.com> (Daniel Littlewood's message of "Fri, 14 Jun 2024 16:43:05 +0100")

Hi Daniel,

I replaced rvm on guix with direnv and guix manifests.  Most for the
projects I work on are on different versions of ruby and some which are
not packaged for guix.  The way I do this is as follows.

First I create a .guix.scm file in the root of my project as follows:

  (use-modules (gnu packages)
               (gnu packages ruby)
               (guix packages)
               (guix utils))

  (let* ((ruby-version "3.3.0")
         (ruby (package
                 (inherit ruby-3.2)
                 (version ruby-version)
                 (source
                  (origin
                    (inherit (package-source ruby-3.2))
                    (uri (string-append "http://cache.ruby-lang.org/pub/ruby/"
                                        (version-major+minor ruby-version)
                                        "/ruby-" ruby-version ".tar.xz"))
                    (sha256
                     (base32
                      "0nwpgf27i43yd8ccsk838n86n9xki68hayxmhbwr0zk3dsinasv7")))))))

         (concatenate-manifests
          (list
           (packages->manifest (list ruby))

           ;; base for building extensions
           (package->development-manifest ruby))))

And run:

  guix package -p .guix -m .guix.scm

This creates a profile containing ruby-3.3.0 in the .guix directory
(with is actually a link the a version of that profile) which includes
enough to build basic gems with native code (the development manifest
for ruby itself) kinda like installing debians build-essentials.  If you
need any libraries to compile some gem add them here too.

Now create a .envrc file as follows:

  GUIX_PROFILE="$(expand_path .guix)"
  [ -f "$GUIX_PROFILE/etc/profile" ] ||
      guix package -p "$GUIX_PROFILE" -m .guix.scm
  source "$GUIX_PROFILE/etc/profile"

  export GEM_HOME="$(expand_path .gems)"
  export GEM_PATH="$GEM_HOME"
  PATH_add $GEM_HOME/bin

This makes sure the profile gets automatically loaded when you "enter"
the project and sets up GEM_HOME so all gems installed for this project
are kept in the local .gems.  Read the direnv documentation to figure
out how to set that up to make "entering" the project work for your dev
environment.  I use the envrc emacs package which work very well for me.

I use the about method for other kinds of projects too.

Cheers,
Remco


      parent reply	other threads:[~2024-06-15  7:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 15:43 Ruby without RVM - what to do if the version I want is missing? Daniel Littlewood
2024-06-14 16:15 ` Felix Lechner via
2024-06-14 17:36 ` Andreas Enge
2024-06-15  6:39   ` Nils Landt
2024-06-16 10:27   ` Andreas Enge
2024-06-17 19:09     ` Daniel Littlewood
2024-06-17 19:09       ` [bug#71559] " Daniel Littlewood
2024-06-19 15:50       ` Remco van 't Veer
2024-06-20 17:09       ` Andreas Enge
2024-06-15  7:43 ` Remco van 't Veer [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

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

  git send-email \
    --in-reply-to=87y176ejmi.fsf@remworks.net \
    --to=remco@remworks.net \
    --cc=danielittlewood@gmail.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.