unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: zimoun <zimon.toutoune@gmail.com>
To: Sarah Morgensen <iskarian@mgsn.dev>, Ryan Prior <rprior@protonmail.com>
Cc: guix-devel@gnu.org
Subject: Re: Named environments
Date: Mon, 13 Sep 2021 10:08:14 +0200	[thread overview]
Message-ID: <8635q8x5ht.fsf@gmail.com> (raw)
In-Reply-To: <86zgshlhbt.fsf@mgsn.dev>

Hi,

On Sun, 12 Sep 2021 at 12:33, Sarah Morgensen <iskarian@mgsn.dev> wrote:
> Ryan Prior <rprior@protonmail.com> writes:

>> I've been thinking lately it would be convenient to create certain uniquely
>> named execution environments on my machine. For example, I might have one
>> set up with dependencies for my Python webapp & environment variables set to
>> autoconnect to a Postgres server. I might have another that's got test
>> dependencies and is containerized, such that it can only access the network
>> & not the rest of my filesystem. Suppose I name these two "webapp" and
>> "test" respectively.
>>
>> I picture running eg `guix env @webapp -- uvicorn main:app` to start my
>> server, then `guix env @test -- pytest` to run my tests.
>>
>> I might write a wrapper in some scripting language that sets up this kind of
>> system. Would anybody else be interested in using such a thing? Would it
>> make sense to integrate this capability into Guix itself?
>
> I like this idea!  (And adding a built-in alias from "environment" to "env"
> might be worth it, too.)
>
> I actually use an ad-hoc version of this in my ~/.bashrc, using aliases. For
> example,
>
>   alias geg='guix environment guix --pure --ad-hoc nano git git:send-email less help2man strace nss-certs'
>
> This also lets me add on any ad-hoc packages at the end, like
>
>   geg dejagnu expect

You might be interested by GUIX_EXTENSIONS_PATH which is somehow
documented by this thread: :-)

<https://yhetil.org/guix/86k0sekkj8.fsf@gmail.com/>

It is a not-enough known feature but really handy to:

 1) define your own flavour, e.g., “guix env --options you --like“
 2) experiment for a new subcommand

Once a subcommand is in Guix, it is really hard to make a CLI change
so it seems better to experiment before, IMHO. :-)

For an instance of this last claim: <http://issues.guix.gnu.org/38529>.

> But also imagine portable environments (used, for example, for project dev
> environments, checked in with the source):
>
> --8<---------------cut here---------------start------------->8---
> $ guix env --export @myapp-test --pure -C -f guix.scm --ad-hoc strace coreutils
>
> (environment "@myapp-test"
>  (load '("guix.scm"))
>  (ad-hoc-packages '("strace" "coreutils" "findutils"))
>  (flags '(pure container)))
> --8<---------------cut here---------------end--------------->8---

This kind of ideas is exposed here:

<https://yhetil.org/guix/877dvn10ro.fsf@dustycloud.org/>

or here and there:

<https://lists.gnu.org/archive/html/guix-devel/2016-07/msg00120.html>
<https://lists.gnu.org/archive/html/help-guix/2018-01/msg00056.html>

Thanks for the revival. :-)


> Of course, this isn't entirely reproducible, as packages could change as you
> update your Guix, even if you give a version spec (the same issue that exists
> for manifests).  So, we could pin the channel used to make the environment:
>
> --8<---------------cut here---------------start------------->8---
> $ guix env --export @myapp-test --pin-channels ...
>
> (environment "@myapp-test"
>  (channels (list (channel (name 'guix)
>                           (url ...)
>                           (commit ...)))
>  (load '("guix.scm"))
>  (ad-hoc-packages '("strace" "coreutils" "findutils"))
>  (flags '(pure container))))
> --8<---------------cut here---------------end--------------->8---
>
> which, when evaluated, would internally do what `guix time-machine --channels
> file' does.

I think the correct workflow is:

  $ guix describe -f channels > channels.scm
  $ guix time-machine -C channels.scm -- subcommand --options


All the best,
simon


  reply	other threads:[~2021-09-13  8:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 23:06 Named environments Ryan Prior
2021-09-11  8:59 ` Domagoj Stolfa
2021-09-12 19:33 ` Sarah Morgensen
2021-09-13  8:08   ` zimoun [this message]
2021-10-06 13:29   ` Ludovic Courtès
2021-09-13 15:48 ` pinoaffe
2021-09-14  2:32   ` Ryan Prior
2021-09-14  6:27     ` Lars-Dominik Braun
2021-09-14  9:58       ` Pjotr Prins
2021-09-14  6:30     ` zimoun

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=8635q8x5ht.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=iskarian@mgsn.dev \
    --cc=rprior@protonmail.com \
    /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 public inbox

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

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).