help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Blog/Cookbook?] On multiple Guix profiles and manifests


From: Chris Marusich
Subject: Re: [Blog/Cookbook?] On multiple Guix profiles and manifests
Date: Sun, 13 Oct 2019 21:38:20 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Pierre Neidhardt <address@hidden> writes:

> While the documentation refers to profiles and manifests, it does not tell 
> much
> of the use cases and the practical benefits.

I just wanted to chime in and say I think a post about this, or a
cookbook section on it, would be great.  I'm sure there are many people
who love declarative manifests and isolated profiles, but they just
don't know it yet.  ;-) It would be great to convince them through clear
examples.

> - When a profile is off, it's easy to enable it for an individual shell 
> without
>   "polluting" the rest of the user session:
>
>   #+begin_src sh
>   GUIX_PROFILE="$profile" ; . "$profile"/etc/profile 
>   #+end_src

This is simple, for sure.  However, I wonder why nobody has implemented
"guix environment --profile=/path/to/my/profile".  I imagine it to
behave just like the "env" command, but it sets the environment
variables for the profile before doing so.  It would be trivial to
define a shell function like "guix-profile-env" that does this:

guix-profile-env()
{
    if [ -z "$1" ]; then
        echo "usage: guix-profile-env PROFILE [CMD [ARG ...]]" 2>&1
        return 2
    fi
    local sh
    sh="${SHELL:-/bin/sh}"
    if [ -z "$2" ]; then
        "$sh" \
        -c \
        'GUIX_PROFILE="$0" && . "$0"/etc/profile && exec "$1"' \
        "$1" \
        "$sh"
    else
        "$sh" \
        -c \
        'GUIX_PROFILE="$0" && . "$0"/etc/profile && exec "$@"' \
        "$@"
    fi
}

Surely it would be fairly simple to do the same in Scheme and expose it
through a friendly CLI interface.  This function just adds to the
environment, but it would be easy to make it "pure" by adding "env -i"
before "$sh" above.

Anyway, I went off on a tangent.  I think your post is a great idea!

-- 
Chris

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]