[bug#72928] time-machine: Print profile path if no command is given.

Message ID 9f9f76785a5f43b77eeff14d407c675876dffd61.1725198888.git.~@wolfsden.cz
State New
Headers
Series [bug#72928] time-machine: Print profile path if no command is given. |

Commit Message

Tomas Volf Sept. 1, 2024, 1:54 p.m. UTC
  Instead of warning, print the profile path of the cached-channel-instance.

* guix/scripts/time-machine.scm (guix-time-machine)[not command-line]: Print
the profile directory.

Change-Id: Id2c1ded514e6c5af45af9008ad1ef91beb509177
---
 guix/scripts/time-machine.scm | 38 +++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)


base-commit: ef525ba96f04c6b3a5e45ab5333c9f440df81e5f
  

Comments

Ludovic Courtès Sept. 9, 2024, 2:40 p.m. UTC | #1
Hi,

Tomas Volf <~@wolfsden.cz> skribis:

> Instead of warning, print the profile path of the cached-channel-instance.
>
> * guix/scripts/time-machine.scm (guix-time-machine)[not command-line]: Print
> the profile directory.
>
> Change-Id: Id2c1ded514e6c5af45af9008ad1ef91beb509177

[...]

> +         (if command-line
> +             (apply execl (cons* executable executable command-line))
> +             (format #t "~a\n" directory)))))))

Maybe print ‘executable’ rather than ‘directory’?

Also perhaps add a sentence or two in the manual?

At any rate, this sounds like a useful change to me.

Thanks,
Ludo’.
  
Tomas Volf Sept. 15, 2024, 8:38 p.m. UTC | #2
Hello,

Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> Tomas Volf <~@wolfsden.cz> skribis:
>
>> Instead of warning, print the profile path of the cached-channel-instance.
>>
>> * guix/scripts/time-machine.scm (guix-time-machine)[not command-line]: Print
>> the profile directory.
>>
>> Change-Id: Id2c1ded514e6c5af45af9008ad1ef91beb509177
>
> [...]
>
>> +         (if command-line
>> +             (apply execl (cons* executable executable command-line))
>> +             (format #t "~a\n" directory)))))))
>
> Maybe print ‘executable’ rather than ‘directory’?

Printing directory gives nice symmetry between

--8<---------------cut here---------------start------------->8---
$ $(guix build guix)/bin/guix describe
  guix 9a2ddcc
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a
--8<---------------cut here---------------end--------------->8---

and

--8<---------------cut here---------------start------------->8---
$ $(guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a)/bin/guix describe
  guix 9a2ddcc
    repository URL: https://git.savannah.gnu.org/git/guix.git
    commit: 9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a
--8<---------------cut here---------------end--------------->8---

And in some cases you need the store item (guix copy?), and in my
opinion it is easier to go from directory to binary than other way
around.

But just let me know which way I should do it.

>
> Also perhaps add a sentence or two in the manual?

Ah, yeah, definitely.  Once previous point is clarified, I will send v2.

Tomas
  
Ludovic Courtès Sept. 15, 2024, 9:29 p.m. UTC | #3
Hi,

Tomas Volf <~@wolfsden.cz> skribis:

>>> +         (if command-line
>>> +             (apply execl (cons* executable executable command-line))
>>> +             (format #t "~a\n" directory)))))))
>>
>> Maybe print ‘executable’ rather than ‘directory’?
>
> Printing directory gives nice symmetry between
>
> $ $(guix build guix)/bin/guix describe
>   guix 9a2ddcc
>     repository URL: https://git.savannah.gnu.org/git/guix.git
>     branch: master
>     commit: 9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a
>
>
> and
>
> $ $(guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a)/bin/guix describe
>   guix 9a2ddcc
>     repository URL: https://git.savannah.gnu.org/git/guix.git
>     commit: 9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a
>
> And in some cases you need the store item (guix copy?), and in my
> opinion it is easier to go from directory to binary than other way
> around.

Ah yes, good points, I agree.  Let’s do that.

> Ah, yeah, definitely.  Once previous point is clarified, I will send v2.

Green light as far as I’m concerned!

Thanks,
Ludo’.
  
Simon Tournier Sept. 20, 2024, 3:49 p.m. UTC | #4
Hi,

On dim., 15 sept. 2024 at 23:29, Ludovic Courtès <ludo@gnu.org> wrote:

>> Printing directory gives nice symmetry between
>>
>> $ $(guix build guix)/bin/guix describe

[...]

>> $ $(guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a)/bin/guix describe

[...]

>> And in some cases you need the store item (guix copy?), and in my
>> opinion it is easier to go from directory to binary than other way
>> around.

Well, I do not have a strong opinion.  And indeed the symmetry looks
nice.  However, just to be sure: what’s the use case?  Because


    $(guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a)/bin/guix describe

is equivalent to:

    guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a -- describe


Cheers,
simon
  
Tomas Volf Sept. 22, 2024, 2:09 p.m. UTC | #5
Hi,

Simon Tournier <zimon.toutoune@gmail.com> writes:

> Hi,
>
> On dim., 15 sept. 2024 at 23:29, Ludovic Courtès <ludo@gnu.org> wrote:
>
>>> Printing directory gives nice symmetry between
>>>
>>> $ $(guix build guix)/bin/guix describe
>
> [...]
>
>>> $ $(guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a)/bin/guix describe
>
> [...]
>
>>> And in some cases you need the store item (guix copy?), and in my
>>> opinion it is easier to go from directory to binary than other way
>>> around.
>
> Well, I do not have a strong opinion.  And indeed the symmetry looks
> nice.  However, just to be sure: what’s the use case?  Because
>
>
>     $(guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a)/bin/guix describe
>
> is equivalent to:
>
>     guix time-machine -q --commit=9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a -- describe

That is true.  While I think the symmetry is nice (and goes with
principle of least surprise), I am not interested in running guix this
way.

I am interested in getting the store item for the time-machined version
of guix.  Currently I have two uses in mind:

1. Using `guix copy' to avoid computing the guix derivation when I need
to test something on less powerful machines.  Guix does not built fast,
so this saves both time and electricity.

2. Having something to pass into guix field of guix-configuration.

Guix time-machine works great for both, since it is automatically built,
cached and automatically cleaned after some time.  Only pain point is
getting the profile store path out of it.  With the proposed change it
will be as simple as

--8<---------------cut here---------------start------------->8---
store_item=$(realpath $(guix time-machine -C channels.scm))
--8<---------------cut here---------------end--------------->8---

Does this sufficiently justify the existence of this functionality in
your eyes?

Have a nice day,
Tomas
  
Simon Tournier Sept. 26, 2024, 3:59 p.m. UTC | #6
Hi,

On Sun, 22 Sep 2024 at 16:09, Tomas Volf <~@wolfsden.cz> wrote:

> Does this sufficiently justify the existence of this functionality in
> your eyes?

Indeed it is boring to get the store path and this patch will simplify
my life. :-)

Cheers,
simon
  
Ludovic Courtès Oct. 4, 2024, 3:45 p.m. UTC | #7
Hey Tomas,

Tomas Volf <~@wolfsden.cz> skribis:

> Ah, yeah, definitely.  Once previous point is clarified, I will send v2.

Please feel free to send v2 anytime, now that there’s consensus.

Thanks,
Ludo’.
  

Patch

diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm
index d9ce85df84..8cad457ade 100644
--- a/guix/scripts/time-machine.scm
+++ b/guix/scripts/time-machine.scm
@@ -179,22 +179,22 @@  (define-command (guix-time-machine . args)
             (ref          (assoc-ref opts 'ref))
             (substitutes?  (assoc-ref opts 'substitutes?))
             (authenticate? (assoc-ref opts 'authenticate-channels?)))
-       (if command-line
-           (let* ((directory
-                   (with-store store
-                     (with-status-verbosity (assoc-ref opts 'verbosity)
-                       (with-build-handler (build-notifier #:use-substitutes?
-                                                           substitutes?
-                                                           #:verbosity
-                                                           (assoc-ref opts 'verbosity)
-                                                           #:dry-run? #f)
-                         (set-build-options-from-command-line store opts)
-                         (cached-channel-instance store channels
-                                                  #:authenticate? authenticate?
-                                                  #:reference-channels
-                                                  %reference-channels
-                                                  #:validate-channels
-                                                  validate-guix-channel)))))
-                  (executable (string-append directory "/bin/guix")))
-             (apply execl (cons* executable executable command-line)))
-           (warning (G_ "no command specified; nothing to do~%")))))))
+       (let* ((directory
+               (with-store store
+                 (with-status-verbosity (assoc-ref opts 'verbosity)
+                   (with-build-handler (build-notifier #:use-substitutes?
+                                                       substitutes?
+                                                       #:verbosity
+                                                       (assoc-ref opts 'verbosity)
+                                                       #:dry-run? #f)
+                     (set-build-options-from-command-line store opts)
+                     (cached-channel-instance store channels
+                                              #:authenticate? authenticate?
+                                              #:reference-channels
+                                              %reference-channels
+                                              #:validate-channels
+                                              validate-guix-channel)))))
+              (executable (string-append directory "/bin/guix")))
+         (if command-line
+             (apply execl (cons* executable executable command-line))
+             (format #t "~a\n" directory)))))))