[PATCH] time-machine: Print profile path if no command is given.

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Simon Tournier
  • Tomas Volf
Owner
unassigned
Submitted by
Tomas Volf
Severity
normal

Debbugs page

Tomas Volf wrote 6 months ago
(address . guix-patches@gnu.org)(name . Tomas Volf)(address . ~@wolfsden.cz)
9f9f76785a5f43b77eeff14d407c675876dffd61.1725198888.git.~@wolfsden.cz
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(-)

Toggle diff (50 lines)
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)))))))

base-commit: ef525ba96f04c6b3a5e45ab5333c9f440df81e5f
--
2.45.2
Ludovic Courtès wrote 6 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
87o74wc2l2.fsf@gnu.org
Hi,

Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (7 lines)
> 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

[...]

Toggle quote (4 lines)
> + (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 wrote 6 months ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
87r09khcuo.fsf@wolfsden.cz
Hello,

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

Toggle quote (19 lines)
> 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

Toggle snippet (7 lines)
$ $(guix build guix)/bin/guix describe
guix 9a2ddcc
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: 9a2ddcc8f5a6f64b475eeb13a3f1034aa6a4a49a

and

Toggle snippet (6 lines)
$ $(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.

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

Toggle quote (3 lines)
>
> Also perhaps add a sentence or two in the manual?

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

Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmbnRa8OHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wam2ew/7BJpO0256mkKBAi2HmrcIdr5Sv3pSuMrtrMDu
j1rhUBa5t+GrwNlD500ELq3G0EtWsn/3KDGeV7h9823Bzjl0I31ZDH9v7s8zHcbr
HUtvIenRw5gXu+S4h8G6dQif1VcarbgOPL+WJWNEjdlQUjatf9t2aLt+UtIJw0fT
Uo3Djly7MMXoT2vOhY//uocvgiv8r1cyG9dBxjAoSh3IhdKtWTNIby6bU07VDu6d
JFdzdifjn/bI0ikwWPuA6CwyAb8xw9m8nyZuy25X6QGyr7UIplsUukHyR6QEZ/bT
mqo6Eja89b7hfbhQU7a9znr1OWshe4hOulqHJOiD2+IYhRstHKti6Pfu4aujnciy
FO1T0vAF9/XKq52WgSXfV639b38bK9S5h6RN3G3oHmoRKsD+O8XJjYVIWwp/PbCY
bquM+aVuxW/D7PCt9s7EKuKlQNn2c23Qkd8Y1zyIxeDVYDCRVBonsevphbQBb4nT
z8BQzEPQ3eXXi4rQDvBWwPFT7pstdIHviyZrtmbsMeLlaCTG52nmRbH+7Z+7fHnr
SwuIJmncFE6kJ81Du0pmebNVMPHQBDFqSt2laCavRNXQGYWfqC870QIHKeD0rX2L
FnpVtP4bmi4u1K7WwsiL2G6nL7AY6JIibYe1zNtTGA16747SRDyL/B0cdSqfI0dY
VzMDr9k=
=syny
-----END PGP SIGNATURE-----

Ludovic Courtès wrote 6 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
87frq0d2s0.fsf@gnu.org
Hi,

Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (26 lines)
>>> + (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.

Toggle quote (2 lines)
> Ah, yeah, definitely. Once previous point is clarified, I will send v2.

Green light as far as I’m concerned!

Thanks,
Ludo’.
Simon Tournier wrote 6 months ago
877cb6tjex.fsf@gmail.com
Hi,

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

Toggle quote (4 lines)
>> Printing directory gives nice symmetry between
>>
>> $ $(guix build guix)/bin/guix describe

[...]

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

[...]

Toggle quote (4 lines)
>> 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 wrote 6 months ago
(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
87bk0fg4pb.fsf@wolfsden.cz
Hi,

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

Toggle quote (28 lines)
> 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

Toggle snippet (3 lines)
store_item=$(realpath $(guix time-machine -C channels.scm))

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

Have a nice day,
Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmbwJTAOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wanrvg/9GIcnqeMHUJoeyFFOKCe/dfzEOcgsiLHGDzfH
lYH+N3mNrcpV0pH3YMs1mxGgCFmeKj455pVTCZ0JfPtxSKsdycVpMnC7Fvka2Ieo
KX3ntPT942iTbl8HwMB/Iule7l+T08CnTWdbzQxmk9wMNNK/pLN6y59mduZreF4w
0Qha+dHSv8+IYc0Y3XA1uRSh/OHPCVkIKUpXnDx08ha//x0UAEKLyv/jM1JOxhzK
68p71oU7dESATVunpPrTaQRMyFDSRd1oVRO4lqx4wwamwmaeguz7B0qTniVp0aLW
1W79kFZXfbjH0eGcd1gOkZhYklLV2RDY/6LeJJ5FGK04fBidSuXo6IxxSu10PfHx
VQF7sVfZConEV/KNUr/M0V2bspjimrObU6JZHI7o4Iy1rC6PRjQ4k2+5pOjp64Ed
1wfGWqTCkXJQs/GYYlRhEfj5l4OFeTtABHMu8E4mqowU9zXrzkwFS2JR3mv4Step
HRZHJTBv7aZ4EIidAJF9rs4c6nQSbiLiH0Ekjxv0Qb2xjK9oEHDfwMqPB5NNnH/d
49ZMWmMIP1jl03v1vofcKM1uP77r1sTwC5IKjf17kCOym3vvzfeom8c9aAPI9Mxj
cCPabbA2bgRH+vZn+yfXVI5pD1mZaCzMzKjxCVgUoKh8V6LSRxvAAZD7tURNpzjF
oIebbDk=
=Fd/+
-----END PGP SIGNATURE-----

Simon Tournier wrote 5 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
87tte2jthy.fsf@gmail.com
Hi,

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

Toggle quote (3 lines)
> 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 wrote 5 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
87frpbrhws.fsf@gnu.org
Hey Tomas,

Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (2 lines)
> 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’.
Tomas Volf wrote 5 months ago
[PATCH v2] time-machine: Print profile path if no command is given.
(address . 72928@debbugs.gnu.org)(name . Tomas Volf)(address . ~@wolfsden.cz)
7f53e25ef8bb1415d73c577b8845195eb013f6c9.1728220987.git.~@wolfsden.cz
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.
(show-help): Adjust usage message.
* doc/guix.texi (Invoking guix time-machine): Document it.

Change-Id: Id2c1ded514e6c5af45af9008ad1ef91beb509177
---
Adjust usage message and document the new behavior.

doc/guix.texi | 5 ++++
guix/scripts/time-machine.scm | 44 ++++++++++++++++++-----------------
2 files changed, 28 insertions(+), 21 deletions(-)

Toggle diff (77 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 52e36e4354..72871316c8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4762,6 +4762,11 @@ Invoking guix time-machine
their dependencies, and these are controlled by the standard build
options (@pxref{Common Build Options}).

+If @command{guix time-machine} is executed without any command, it
+prints the path to the guix profile that would be used to execute the
+command. This is sometimes useful if you need to get store path for the
+profile, e.g. when you want to @command{guix copy} it.
+
@node Inferiors
@section Inferiors

diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm
index d9ce85df84..21145239d4 100644
--- a/guix/scripts/time-machine.scm
+++ b/guix/scripts/time-machine.scm
@@ -52,8 +52,10 @@ (define-module (guix scripts time-machine)
;;;

(define (show-help)
- (display (G_ "Usage: guix time-machine [OPTION] -- COMMAND ARGS...
-Execute COMMAND ARGS... in an older version of Guix.\n"))
+ (display (G_ "Usage: guix time-machine [OPTION] [-- COMMAND ARGS...]
+Execute COMMAND ARGS... in an older version of Guix.
+
+If COMMAND is not provided, print path to the time-machine profile.\n"))
(display (G_ "
-C, --channels=FILE deploy the channels defined in FILE"))
(display (G_ "
@@ -179,22 +181,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)))))))

base-commit: a873666d3bf716a5ae29275efaa000eaf6d1e2a8
--
2.46.0
Ludovic Courtès wrote 5 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
87cykcz16t.fsf@gnu.org
Tomas Volf <~@wolfsden.cz> writes:

Toggle quote (9 lines)
> 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.
> (show-help): Adjust usage message.
> * doc/guix.texi (Invoking guix time-machine): Document it.
>
> Change-Id: Id2c1ded514e6c5af45af9008ad1ef91beb509177

Applied, thanks!
Closed
Ludovic Courtès wrote 5 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
878qv0z11u.fsf@gnu.org
Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (9 lines)
> 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.
> (show-help): Adjust usage message.
> * doc/guix.texi (Invoking guix time-machine): Document it.
>
> Change-Id: Id2c1ded514e6c5af45af9008ad1ef91beb509177

Applied, thanks!

I took the liberty to make the cosmetic changes below to be consistent
with the style and terminology used throughout the manual.

Thanks!

Ludo’.
Toggle diff (17 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index e643aec19a..4aafcf9cc0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4763,9 +4763,9 @@ Invoking guix time-machine
options (@pxref{Common Build Options}).
If @command{guix time-machine} is executed without any command, it
-prints the path to the guix profile that would be used to execute the
-command. This is sometimes useful if you need to get store path for the
-profile, e.g. when you want to @command{guix copy} it.
+prints the file name of the profile that would be used to execute the
+command. This is sometimes useful if you need to get store file name of
+the profile---e.g., when you want to @command{guix copy} it.
@node Inferiors
@section Inferiors
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 72928@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 72928
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help