[PATCH] home: 'home-environment-with-provenance' uses the HE location info.

  • Done
  • quality assurance status badge
Details
3 participants
  • Andrew Tropin
  • Ludovic Courtès
  • Sergey Trofimov
Owner
unassigned
Submitted by
Sergey Trofimov
Severity
normal
S
S
Sergey Trofimov wrote on 19 Mar 2023 16:45
(address . guix-patches@gnu.org)(name . Sergey Trofimov)(address . sarg@sarg.org.ru)
20230319154537.30463-1-sarg@sarg.org.ru
* gnu/home.scm (home-environment-with-provenance): Make `config-file`
optional, with the default taken from the HE location info.
---
gnu/home.scm | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

Toggle diff (29 lines)
diff --git a/gnu/home.scm b/gnu/home.scm
index 6d3f705758..2fefe7ba53 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -103,7 +103,21 @@ (define* (home-environment-derivation he)
#:target-type home-service-type)))
(service-value home)))
-(define* (home-environment-with-provenance he config-file)
+
+(define (home-environment-configuration-file he)
+ "Return the configuration file of HE, based on its 'location' field, or #f
+if it could not be determined."
+ (let ((file (and=> (home-environment-location he)
+ location-file)))
+ (and file
+ (or (and (string-prefix? "/" file) file)
+ (search-path %load-path file)))))
+
+(define* (home-environment-with-provenance he
+ #:optional
+ (config-file
+ (home-environment-configuration-file
+ he)))
"Return a variant of HE that stores its own provenance information,
including CONFIG-FILE, if available. This is achieved by adding an instance
of HOME-PROVENANCE-SERVICE-TYPE to its services."
--
2.39.2
A
A
Andrew Tropin wrote on 20 Mar 2023 07:52
87pm9352yg.fsf@trop.in
On 2023-03-19 16:45, Sergey Trofimov wrote:

Toggle quote (34 lines)
> * gnu/home.scm (home-environment-with-provenance): Make `config-file`
> optional, with the default taken from the HE location info.
> ---
> gnu/home.scm | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/home.scm b/gnu/home.scm
> index 6d3f705758..2fefe7ba53 100644
> --- a/gnu/home.scm
> +++ b/gnu/home.scm
> @@ -103,7 +103,21 @@ (define* (home-environment-derivation he)
> #:target-type home-service-type)))
> (service-value home)))
>
> -(define* (home-environment-with-provenance he config-file)
> +
> +(define (home-environment-configuration-file he)
> + "Return the configuration file of HE, based on its 'location' field, or #f
> +if it could not be determined."
> + (let ((file (and=> (home-environment-location he)
> + location-file)))
> + (and file
> + (or (and (string-prefix? "/" file) file)
> + (search-path %load-path file)))))
> +
> +(define* (home-environment-with-provenance he
> + #:optional
> + (config-file
> + (home-environment-configuration-file
> + he)))
> "Return a variant of HE that stores its own provenance information,
> including CONFIG-FILE, if available. This is achieved by adding an instance
> of HOME-PROVENANCE-SERVICE-TYPE to its services."

Thank you for the patch, applied and pushed as
1f36534c7e8f2325bff4df5d37ecc811dc63fc38.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQYAscACgkQIgjSCVjB
3rBeAQ/9HAhyXU27Ke0ZuXHkmT0YZt7md6puchXG1aS1Nif14cb6EyTnz4RZHU2O
hyL3pDDGMbVB33SyRO37I/s3CCoE0XXFk5MIjxKJX7BRwc7/NicfaIABqnmCzIMD
mV2R4o21prT6G5hPUWeE/0fcxgQ5olu2C5bidvyEuoxjieBcxMPB6de+TQUpodzd
gWE7aKqylUjsgmwOSylKLc1Ary660oHaD7u5JsqMJriGmzkQxMVptknlb9cq4gZV
Gnsu09UsJo5Mc+Fo5/lcinz+eq61HgzqC5ZxPDHNpEMFrUZhtjMzE7+/tSHcHJHl
1fXyIZhwfTVEvppvxaxZrhCAh9TSHxF+VIJAkRI2yIjSR1L+GDfYWWPUE3wFsmN2
qF/1Aa5QDfHmPXCicQ7c9jo3eurvHiT/FYO8t8D3KdUXuXXcYdc4U3MbniwuPwLR
NrOFXJofxzAeD1gI8OdeO8wZJRkiCbOdLg4ptaBCz3AQXjXIg2hJ3bUCfzVaGoWM
beWIio5tBErNLhCVRgSOdl/riG3+tSPiPJCGAHP0bnaVXY7QrDavtbWitWBfwAkm
d5rwlOSC3cw/IVf73BMfYheCn4Ou9gsMf86AG/aXRejkbiBRQpcfYYa24wxAUq06
qrA0/dm7hFhuoCkyKFVQYsxHXWR0heZtfx0K1Wo9ipxNfjENmno=
=ozmU
-----END PGP SIGNATURE-----

Closed
L
L
Ludovic Courtès wrote on 20 Mar 2023 18:33
Re: bug#62274: [PATCH] home: 'home-environment-with-provenance' uses the HE location info.
(name . Sergey Trofimov)(address . sarg@sarg.org.ru)
87bkknl443.fsf@gnu.org
Hi Sergey and all,

Sergey Trofimov <sarg@sarg.org.ru> skribis:

Toggle quote (3 lines)
> * gnu/home.scm (home-environment-with-provenance): Make `config-file`
> optional, with the default taken from the HE location info.

[...]

Toggle quote (6 lines)
> +(define* (home-environment-with-provenance he
> + #:optional
> + (config-file
> + (home-environment-configuration-file
> + he)))

AFAICS, there’s only one call site for
‘home-environment-with-provenance’, and it passes two arguments. Thus,
the default value added by this patch will never be used.

Am I missing something?

Thanks,
Ludo’.
S
S
Sergey Trofimov wrote on 20 Mar 2023 20:03
(name . Ludovic Courtès)(address . ludo@gnu.org)
871qljs0ju.fsf@sarg.org.ru
Hi Ludovic,

Toggle quote (24 lines)
> Hi Sergey and all,
>
> Sergey Trofimov <sarg@sarg.org.ru> skribis:
>
>> * gnu/home.scm (home-environment-with-provenance): Make
>> `config-file`
>> optional, with the default taken from the HE location info.
>
> [...]
>
>> +(define* (home-environment-with-provenance he
>> + #:optional
>> + (config-file
>> +
>> (home-environment-configuration-file
>> + he)))
>
> AFAICS, there’s only one call site for
> ‘home-environment-with-provenance’, and it passes two arguments.
> Thus,
> the default value added by this patch will never be used.
>
> Am I missing something?

You're right, the new signature is not used anywhere yet. Though
I'm working on a patch to embed home profiles in disk images
produced with `guix system image`. That's where this method comes
handy, see example usage:

(image
(inherit efi-disk-image)
(operating-system (operating-system-with-provenance (load
"./system.scm")))
(inputs
`(("guix-home"
,(home-environment-with-provenance (load "./home.scm")))))
(partition-table-type 'gpt)
(volatile-root? #false))
L
L
Ludovic Courtès wrote on 21 Mar 2023 10:44
(name . Sergey Trofimov)(address . sarg@sarg.org.ru)
87lejqsakw.fsf@gnu.org
Hi,

Sergey Trofimov <sarg@sarg.org.ru> skribis:

Toggle quote (5 lines)
> You're right, the new signature is not used anywhere yet. Though I'm
> working on a patch to embed home profiles in disk images produced with
> `guix system image`. That's where this method comes handy, see example
> usage:

OK, interesting!

(In general I think it’s best to submit the new interface and its user
together, so reviewers get an overview of where this is going.)

Thanks,
Ludo’.
A
A
Andrew Tropin wrote on 21 Mar 2023 11:56
87edpiz831.fsf@trop.in
On 2023-03-20 20:03, Sergey Trofimov wrote:

Toggle quote (41 lines)
> Hi Ludovic,
>
>> Hi Sergey and all,
>>
>> Sergey Trofimov <sarg@sarg.org.ru> skribis:
>>
>>> * gnu/home.scm (home-environment-with-provenance): Make
>>> `config-file`
>>> optional, with the default taken from the HE location info.
>>
>> [...]
>>
>>> +(define* (home-environment-with-provenance he
>>> + #:optional
>>> + (config-file
>>> +
>>> (home-environment-configuration-file
>>> + he)))
>>
>> AFAICS, there’s only one call site for
>> ‘home-environment-with-provenance’, and it passes two arguments.
>> Thus,
>> the default value added by this patch will never be used.
>>
>> Am I missing something?
>
> You're right, the new signature is not used anywhere yet. Though
> I'm working on a patch to embed home profiles in disk images
> produced with `guix system image`. That's where this method comes
> handy, see example usage:
>
> (image
> (inherit efi-disk-image)
> (operating-system (operating-system-with-provenance (load
> "./system.scm")))
> (inputs
> `(("guix-home"
> ,(home-environment-with-provenance (load "./home.scm")))))
> (partition-table-type 'gpt)
> (volatile-root? #false))

Also, take a look at this thread:

and this prototype:

It can be related to what you want to achieve, whithout modifying
image-related code.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQZjVIACgkQIgjSCVjB
3rCtmA//dp9t4evjVe5y/q7dRtDQVzp4fdlkdnYRl6yHvTnROtgAi8gywOj11PYF
5gaSowjFy21Jv2N+vBINAW0IRQNTC01Z07l/GN9AGcfMDEfqsEZaIw75oHtgaNLE
kRB4JvK8+Fi7CAxTFO5yWXHvSO8kiWKDuoD3ivVQitguAR1l0tWlKXMV1lS5ezPW
SlkwQNBU8V70wLxBNhyyOgWelextgEm+TF7fd67ua6SvP8SIaXLF4csLil5ra5bC
TjSKPiOR0ovPiBu6tW9BCRPIlWJK4aWaZAKh1KilTuNndxJ/LESoq4zFGEhGFQBE
0HAfjfPmhrh+t0AW+DJJSrIzMgyooH5z0wSIk1puwsBGXciKOiz/m1meIO+E8LiY
i0RVn0AOvqd1SN00NeQJ6pIRpXXTgxMBT/H+TTQgplZD2TLPn1bkWw0yw6zGUv5v
9QSym/gyurhab4KJfwapK9+2At/lku6Xlbnv9z2Z5KCUJ9cTbe7gbo+p4K5r1UAY
YQHsJDTIhLcePwZ4YDFEZQfIFqAv5FV+kUoNK6rW/TmaPs8af97+NOGzUFpE4RKL
I4fEhHcTGbsdS1Mu0Qu+Ff4StwL0O7l7/fzIINpCWefHNNbU+bEowxWqcGiNwNAt
bys2qYHTaKsj/kag9nfceFEewmoz8BC8vSX/DadB9LR//E40nu0=
=MbmM
-----END PGP SIGNATURE-----

S
S
Sergey Trofimov wrote on 21 Mar 2023 13:22
(name . Andrew Tropin)(address . andrew@trop.in)
871qliffrs.fsf@sarg.org.ru
Hi Andrew,

Andrew Tropin <andrew@trop.in> writes:

Toggle quote (22 lines)
> [[PGP Signed Part:Undecided]]
> On 2023-03-20 20:03, Sergey Trofimov wrote:
>
>>
>> You're right, the new signature is not used anywhere yet.
>> Though
>> I'm working on a patch to embed home profiles in disk images
>> produced with `guix system image`. That's where this method
>> comes
>> handy, see example usage:
>>
>
> Also, take a look at this thread:
> https://yhetil.org/63960cf762aec1ed2c4182f49cac66bc37fce2aa.camel@rdmp.org
>
> and this prototype:
> https://git.sr.ht/~abcdw/rde/tree/044de83e980b7038b87d27a090aef24229df85eb/src/gnu/services/home.scm#L1
>
> It can be related to what you want to achieve, whithout
> modifying
> image-related code.

Brilliant! That's it. It didn't come to me that `home-environment`
could be a dependency of `operating-system` and not of the image
itself. And you also made the service to activate it, so no manual
step is required. That's exactly what I have envisioned. What
prevents you to mainline it? It seems you have already
battle-tested it.

The only concern is that I'd rather include
`guix-home-service-type` only in the first generation of the
system. I think that this tie between user envs and the operating
system makes sense only on the first boot. Later on the users
should be responsible (and able to) to maintain their environments
independently.
A
A
Andrew Tropin wrote on 21 Mar 2023 14:38
(name . Sergey Trofimov)(address . sarg@sarg.org.ru)
871qliz0k8.fsf@trop.in
On 2023-03-21 13:22, Sergey Trofimov wrote:

Toggle quote (40 lines)
> Hi Andrew,
>
> Andrew Tropin <andrew@trop.in> writes:
>
>> [[PGP Signed Part:Undecided]]
>> On 2023-03-20 20:03, Sergey Trofimov wrote:
>>
>>>
>>> You're right, the new signature is not used anywhere yet.
>>> Though
>>> I'm working on a patch to embed home profiles in disk images
>>> produced with `guix system image`. That's where this method
>>> comes
>>> handy, see example usage:
>>>
>>
>> Also, take a look at this thread:
>> https://yhetil.org/63960cf762aec1ed2c4182f49cac66bc37fce2aa.camel@rdmp.org
>>
>> and this prototype:
>> https://git.sr.ht/~abcdw/rde/tree/044de83e980b7038b87d27a090aef24229df85eb/src/gnu/services/home.scm#L1
>>
>> It can be related to what you want to achieve, whithout
>> modifying
>> image-related code.
>
> Brilliant! That's it. It didn't come to me that `home-environment`
> could be a dependency of `operating-system` and not of the image
> itself. And you also made the service to activate it, so no manual
> step is required. That's exactly what I have envisioned. What
> prevents you to mainline it? It seems you have already
> battle-tested it.
>
> The only concern is that I'd rather include
> `guix-home-service-type` only in the first generation of the
> system. I think that this tie between user envs and the operating
> system makes sense only on the first boot. Later on the users
> should be responsible (and able to) to maintain their environments
> independently.

There are a few issues I've not addressed yet:

1. User can login before activation finished. (Discussed in the
mentioned thread above).

2. Do we need to activate it on every system reconfigure? (Actually, I
used it mostly for creating rde live cd and vm images, so didn't test
much with system reconfigure or guix deploy. Also, I guess it would be
cool to add a one-shot? flag to the service for skeleton like
functionality/initial provisioning).

3. Probably something else I already forgot.

I still don't have enough spare time to clean it up, test and upstream,
but if you would like to finish this thing up, I would be very happy to
help!

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQZs2cACgkQIgjSCVjB
3rCB8w/9HMzKMMSXpgKSpmc+dfgLhtLFPv6LHdN2XqMiWMtvVLqBBUSSys6ODkRf
5Y9mWcSD3pDN8KnjTCCzXpydTalud0U1qk/oGLnvHCB54gvj3TreiSk5gwtbKZ/t
Jagc9IWESpb5cuYmRYiBzKFAwb1FPe0zDKO/Ut/Ej9eU/UzR2ygyjhDSmud7eQgZ
TvrDr6Daz2q7yGccsu/wZ+tZzOzIQXiZu4FV+N3KmF5jFCtvFFbu+5Jag8bBlH6A
vTlBvG5snOq/C2Op6/e+BJaYm6n4nTzaKJWUYajpmliY9IotdgXYO+ORt5i44fSh
acYeRvv2me+aJ2Vk8qlbEOoVOAfXMJXci6kobpEklR1W/sYVnMSwJC6knGfUxZ3p
1Jtb/TPiuU0yUJOg1OK5vFjODbcvPCLF8HILv3iVBAZ3qyoZJ2Xfi5ubgpI9HoFh
4tAK+obV31jng2GVtjyi4xDDDrDnHhT8hYIygrN5cUJ1LQ5bYrLqomZkj9t9iwjc
XY7FMu85/PINFj85dAEUfFrIhqCDpO2b6644BnDJxnHIxAtrU5XCta5s5QisTSA+
n/UAdTh4iYy/Dzk8GwRcNArhn+mr99G0s+yPALfSk9ry7laHI/W1ItLpQGNxDK6m
tsrFuLvtEyba3r/QfPKwKe6WL62OjH9/EPgmRVASWwWKhDr1jZ8=
=acDn
-----END PGP SIGNATURE-----

S
S
Sergey Trofimov wrote on 21 Mar 2023 19:18
(name . Andrew Tropin)(address . andrew@trop.in)(address . 62274@debbugs.gnu.org)
87r0thexcn.fsf@sarg.org.ru
Andrew Tropin <andrew@trop.in> writes:

Toggle quote (17 lines)
> [[PGP Signed Part:Undecided]]
> On 2023-03-21 13:22, Sergey Trofimov wrote:
>>
>> The only concern is that I'd rather include
>> `guix-home-service-type` only in the first generation of the
>> system. I think that this tie between user envs and the
>> operating
>> system makes sense only on the first boot. Later on the users
>> should be responsible (and able to) to maintain their
>> environments
>> independently.
>
> There are a few issues I've not addressed yet:
>
> 1. User can login before activation finished. (Discussed in the
> mentioned thread above).

Yeah, I've just tried to bake a disk-image and also was able to
log in faster than the activation service finishes. Not a big deal
though, I can live with that.

Toggle quote (11 lines)
>
> 2. Do we need to activate it on every system reconfigure?
> (Actually, I
> used it mostly for creating rde live cd and vm images, so didn't
> test
> much with system reconfigure or guix deploy. Also, I guess it
> would be
> cool to add a one-shot? flag to the service for skeleton like
> functionality/initial provisioning).
>

I think this activation should run only once.

Toggle quote (3 lines)
>
> 3. Probably something else I already forgot.

It seems that ~/.config/guix/current is not created and
/var/guix/profiles/per-user/<user> as well.

Toggle quote (7 lines)
>
> I still don't have enough spare time to clean it up, test and
> upstream,
> but if you would like to finish this thing up, I would be very
> happy to
> help!

Actually, my use case is already solved by your code and I can
build backup images of my OS.
Now I just have to figure out how to restore from backups offline.
?