Subject: Re: Mutable guix shell environments

From: Liliana Marie Prikler <[email-masked]>
Date: Sun, 13 Mar 2022 20:51:43 +0100

Am Sonntag, dem 13.03.2022 um 18:21 +0000 schrieb Charles:

> Subject: [PATCH 2/2] guix: shell: Implicitly use a .guix-profile as -
> -profile option.
> 
> * guix/scripts/shell.scm (auto-detect-manifest): Add ".guix-profile"
> to matches as --profile option
This one LGTM and it even avoids some problems we're having with
caches.  I'll keep it open for bikeshedding suggestions w.r.t. the name
of the directory to detect, though.

> Subject: [PATCH 1/2] guix: environment: Enable mutable environments.
> 
> * guix/scripts/environment.scm (launch-environment launch-
> environment/fork
> launch-environment/container guix-environment*): Add #:set-profile?
> parameter set GUIX_PROFILE
> when --profile option is used.
> * guix/scripts/environment.scm (guix-environment*): Profile could
> point to a
> profile directory instead of a store directory.
This one not so much.  You already have GUIX_ENVIRONMENT set, which
should be enough for lookup purposes.  If it's about manipulating PATH
and other environment variables, I think it'd better to do this
manually – you could even spawn a lightweight shell on your own by
simply doing the following:

$ $SHELL
$ GUIX_PROFILE=/path/to/profile
$ source $GUIX_PROFILE/etc/profile

If you want mutable environments, that's the easiest and imho best way
of achieving such a thing.  Guix is functional by design and we should
not compromise on that.

As far as using $GUIX_PROFILE together with `guix shell' is concerned,
if anything is even holding it back, it's that we don't respect
GUIX_PROFILE in the Scheme code that adds those variables.  Which to be
fair might be for the best, as GUIX_PROFILE is not guaranteed to
correspond to this invocation of `guix shell' when people are careless.
That's not to say that support for this couldn't be added, but at the
very least we'd have to be more careful about it.

Cheers