all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Improving the speed of guix time-machine for development environments
@ 2024-05-27  2:00 Richard Sent
  2024-05-31  9:58 ` jbranso
  2024-06-01 13:18 ` Ludovic Courtès
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Sent @ 2024-05-27  2:00 UTC (permalink / raw)
  To: guix-devel; +Cc: richard

Hi Guix!

> I think channels listed in channels.scm files should optionally support
> using whatever channel version is already in the user's profile, if
> present. This would significantly speed up entering development
> environments composed of Guix channels.

> Unfortunately, *I may be delayed every time I enter the development
> environment by several minutes while Guix computes a new derivation
> due to an update in %default-channels*.

I wound up implementing a proof of concept for this idea here:

https://www.freakingpenguin.com/blog/guix-tricks-self-referential-channelsscm-files.html

--8<---------------cut here---------------start------------->8---
(define (soft-pin-channel input-channel)
  "Given @var{channel}, return a new version of channel that uses the
current profile's commit of said channel. If the channel is not present,
commit is #f."
  (define (desired-channel? channel)
    (equal? (channel-name input-channel)
            (channel-name channel)))

  (define (profile-commit input-channel)
    (call/ec
     (lambda (return)
       (map (lambda (x)
              (when (desired-channel? x)
                (return (channel-commit x))))
            (current-channels))
       #f)))

  (channel
   (inherit input-channel)
   (commit (profile-commit input-channel))))
--8<---------------cut here---------------end--------------->8---

If people think this is useful, I'm happy to flesh out the idea more and
submit a proper patch. In my experience this does improve the
development experience when setting up developer tools that rely on
custom channels. At least when there's a new Guix commit, I don't have
to wait several minutes for a new Guix channel collection to build, but
without pinning it to a specific commit.

At present I can think of soft-pinning a list of channels by name being
useful. I can also see an option to only fetch dependencies of a
channel, not the channel itself, being useful. I would definitely
appreciate feedback or use cases! :)

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Improving the speed of guix time-machine for development environments
@ 2024-03-28  3:52 Richard Sent
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Sent @ 2024-03-28  3:52 UTC (permalink / raw)
  To: guix-devel

Hi Guix,

To my knowledge what I'm asking for can't currently be done, but if it
can feel free to disregard.

I think channels listed in channels.scm files should optionally support
using whatever channel version is already in the user's profile, if
present. This would significantly speed up entering development
environments composed of Guix channels. Consider the following
situation:

1. Repository A contains some code, an unmerged Guix package, and a
.guix-channel file.

2. Repository B declares an unmerged Guix package that depends on A's
package

3. Repository B doesn't want to duplicate the package definition in A,
so it adds a channel dependency in B's .guix-channel

4. Repository B wants to make it easy to enter a development environment
that includes repository A's channel, so it tracks a channels.scm file
with the following content:

--8<---------------cut here---------------start------------->8---
(append (list (channel
               (name 'B)
               (url (string-append "file://" (getcwd)))))
        %default-channels)
--8<---------------cut here---------------end--------------->8---

Now in order to build B, I need to enter a Guix development environment
that includes A's channel. The only option I know for that is
time-machine, e.g. "guix time-machine -C channels.scm -- build -f
guix.scm".

Unfortunately, *I may be delayed every time I enter the development
environment by several minutes while Guix computes a new derivation due
to an update in %default-channels*.

time-machine will update ALL channels in channels.scm to the master
branch (by default) every time I try to enter a development environment
(e.g. "guix time-machine -C channels.scm -- shell -CDf guix.scm").

I don't think pinning Guix to a specific commit in channels.scm is the
right solution.

1. That increases the maintenance burden (If A updates to use newer Guix
code, now all dependents of A need to be manually updated to use newer
Guix commits).

2. It makes it easy to mask breakages for an extended period.

3. It implies that B doesn't work on newer versions.

4. Any developer working on the repo will pull an unneeded copy of the channel.

I think this is a side effect of time-machine serving dual purposes.
One is providing a reproducible environment for result replication, the
other is providing a development environment for collections of channels.

My proposed solution is to add a (prefer-local?) field to (channel ...).
When set, time-machine would first see if there is a channel with the
same name in the user's profile. If so, it will include that channel in
the time-machine environment instead of fetching it. If not, it behaves
as normal and fetches the channel from url.

As a workaround, it *may* be possible to achieve this via a command like
~guix time-machine -C channels.scm --commit $(guix describe |
<some_crazy_awk_or_grep_chain)~, but I don't feel that this is a valid
solution. From what I understand --commit only works on the 'guix
channel, but I suspect this proposal could prove useful for other major
channels as well. It's also very inelegant :)

As a side effect, `guix pull -C` would support only upgrading certain
channels while "soft-pinning" others. Maybe that's good?

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-06-06 15:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27  2:00 Improving the speed of guix time-machine for development environments Richard Sent
2024-05-31  9:58 ` jbranso
2024-06-01 13:18 ` Ludovic Courtès
2024-06-01 14:40   ` Richard Sent
2024-06-02 20:53     ` Ludovic Courtès
2024-06-02 21:40       ` Richard Sent
2024-06-06 15:11         ` Ludovic Courtès
  -- strict thread matches above, loose matches on Subject: below --
2024-03-28  3:52 Richard Sent

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.