all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Automated /etc/config.scm
@ 2024-05-26 13:58 Marek Paśnikowski
  2024-05-26 18:03 ` David Larsson
  2024-05-26 20:51 ` Richard Sent
  0 siblings, 2 replies; 6+ messages in thread
From: Marek Paśnikowski @ 2024-05-26 13:58 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 997 bytes --]

While pursuing a solution to another problem I saw some documentation which 
inspired me to question whether it is possible to have an operating-system 
configuration which injects itself into the /etc/config.scm file.

Currently the content of my /etc/config.scm file reflects the state of system 
upon installation, as I had always used my git repository to manage the system 
configuration files.

I have already built the infrastructure to host my configurations on my home 
server.  I would like now to ditch the configuration repositories' clones in 
the home directories on my computers and rely entirely on the combination of 
the system-wide channels (this I have implemented) and the /etc/config.scm 
file.

Is there a way to have 'guix pull' edit the /etc/config.scm file to mirror the 
designated system configuration file? I assume that any module imports are 
handled by an existing guix infrastructure, because I had no need to use the
-L switch during reconfigurations for a while.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Automated /etc/config.scm
  2024-05-26 13:58 Automated /etc/config.scm Marek Paśnikowski
@ 2024-05-26 18:03 ` David Larsson
  2024-05-26 18:41   ` Marek Paśnikowski
  2024-05-26 20:51 ` Richard Sent
  1 sibling, 1 reply; 6+ messages in thread
From: David Larsson @ 2024-05-26 18:03 UTC (permalink / raw)
  To: help-guix

Hi Marek,

I think its not possible to have guix pull edit /etc/config.scm without modifying how that command behaves in guix.

But it is possible to edit /etc/config.scm when running guix system reconfigure, by using a service as described here:
 https://lists.gnu.org/archive/html/help-guix/2017-08/msg00095.html

Though perhaps that's not exactly the answer you are looking for?

If you want to be able to push new configs to some channel git repo and have that reflected in a target host after a guix pull + reconfigure from the host, then I can suggest adding system configuration variables in the channel referring to the various systems you want to deploy. Then adding minimal config.scm files on the deploy targets. Those config.scm files can have '(use-module (mychannel my-systems))' or similar, and then just '%my-os-system1', etc on the final line.

I hope it helps, but not sure.

Regards,
David


On May 26, 2024 3:58:23 PM GMT+02:00, "Marek Paśnikowski" <marek@marekpasnikowski.pl> wrote:
>While pursuing a solution to another problem I saw some documentation which 
>inspired me to question whether it is possible to have an operating-system 
>configuration which injects itself into the /etc/config.scm file.
>
>Currently the content of my /etc/config.scm file reflects the state of system 
>upon installation, as I had always used my git repository to manage the system 
>configuration files.
>
>I have already built the infrastructure to host my configurations on my home 
>server.  I would like now to ditch the configuration repositories' clones in 
>the home directories on my computers and rely entirely on the combination of 
>the system-wide channels (this I have implemented) and the /etc/config.scm 
>file.
>
>Is there a way to have 'guix pull' edit the /etc/config.scm file to mirror the 
>designated system configuration file? I assume that any module imports are 
>handled by an existing guix infrastructure, because I had no need to use the
>-L switch during reconfigurations for a while.

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

* Re: Automated /etc/config.scm
  2024-05-26 18:03 ` David Larsson
@ 2024-05-26 18:41   ` Marek Paśnikowski
  0 siblings, 0 replies; 6+ messages in thread
From: Marek Paśnikowski @ 2024-05-26 18:41 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]

26.05.2024 20:03:24 CEST David Larsson:
> Hi Marek,
> 
> I think its not possible to have guix pull edit /etc/config.scm without
> modifying how that command behaves in guix.
> 
> But it is possible to edit /etc/config.scm when running guix system
> reconfigure, by using a service as described here:
> https://lists.gnu.org/archive/html/help-guix/2017-08/msg00095.html
> 
> Though perhaps that's not exactly the answer you are looking for?
> 
> If you want to be able to push new configs to some channel git repo and have
> that reflected in a target host after a guix pull + reconfigure from the
> host, then I can suggest adding system configuration variables in the
> channel referring to the various systems you want to deploy. Then adding
> minimal config.scm files on the deploy targets. Those config.scm files can
> have '(use-module (mychannel my-systems))' or similar, and then just
> '%my-os-system1', etc on the final line.
> 
> I hope it helps, but not sure.
> 
> Regards,
> David

I do not 'deploy' my systems.

After reading the linked discussion and combining it with what I know; I think 
the best approach would be to dig into wherever guix pull caches the channel 
modules and link the newest revision of the system-configuration.scm to a 
predictable file; which could then be combined with with the reconfigure 
command for a quick update alias. :/

On the upside, this is my opportunity to learn more about Guix.  While writing 
this response I digged around in $GUILE_LOAD_PATH and found a bunch of 
modules.  Sadly, none of those are mine, but maybe they are only exposed to 
the guix build users?

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Automated /etc/config.scm
  2024-05-26 13:58 Automated /etc/config.scm Marek Paśnikowski
  2024-05-26 18:03 ` David Larsson
@ 2024-05-26 20:51 ` Richard Sent
  2024-05-27  3:41   ` Marek Paśnikowski
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Sent @ 2024-05-26 20:51 UTC (permalink / raw)
  To: Marek Paśnikowski; +Cc: help-guix

Hi Marek!

> I have already built the infrastructure to host my configurations on my home 
> server.  I would like now to ditch the configuration repositories' clones in 
> the home directories on my computers and rely entirely on the combination of 
> the system-wide channels (this I have implemented) and the /etc/config.scm 
> file.
>
> Is there a way to have 'guix pull' edit the /etc/config.scm file to mirror the 
> designated system configuration file? I assume that any module imports are 
> handled by an existing guix infrastructure, because I had no need to use the
> -L switch during reconfigurations for a while.

The relevance of the below answer depends on if the contents of
/etc/config.scm are tracked in your custom channel. If not, I
misunderstood and feel free to disregard. :)

If your channel includes the configuration files for the target
machines and you are successfully adding those channels to the system,
you could take advantage of Guix's -e flag. e.g.

--8<---------------cut here---------------start------------->8---
$ guix system reconfigure -e '(@ (my-custom-channel machines this-machine) use-this-system)'
--8<---------------cut here---------------end--------------->8---

This would reconfigure your system using the version of
'my-custom-channel' as described by $ guix describe. So run guix pull,
then the above command, and you can skip needing to separately update
clone of your channel in your home directory.

You can even go one step further.

When combined with unattended-upgrade-service-type [1] and embeddeding a
"self-referential" channels.scm file in your configuration [2] (a
channels.scm file that contains it's own repository), your systems would
regularly reconfigure themselves using the newest versions of your
channel machine configuration files.

[1]: https://git.sr.ht/~freakingpenguin/rsent/tree/1b79ec8a91a9546d4cc158590b1d50145e5fe42a/item/rsent/machines/droplets/rampart.scm#L69
[2]: https://git.sr.ht/~freakingpenguin/rsent/tree/1b79ec8a91a9546d4cc158590b1d50145e5fe42a/item/rsent/configs/channel.scm#L13 

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


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

* Re: Automated /etc/config.scm
  2024-05-26 20:51 ` Richard Sent
@ 2024-05-27  3:41   ` Marek Paśnikowski
  2024-05-27 16:31     ` Richard Sent
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Paśnikowski @ 2024-05-27  3:41 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 2513 bytes --]

26.05.2024 22:51:33 CEST Richard Sent:
> Hi Marek!
> 
> > I have already built the infrastructure to host my configurations on my
> > home server.  I would like now to ditch the configuration repositories'
> > clones in the home directories on my computers and rely entirely on the
> > combination of the system-wide channels (this I have implemented) and the
> > /etc/config.scm file.
> > 
> > Is there a way to have 'guix pull' edit the /etc/config.scm file to mirror
> > the designated system configuration file? I assume that any module
> > imports are handled by an existing guix infrastructure, because I had no
> > need to use the -L switch during reconfigurations for a while.
>
> If your channel includes the configuration files for the target
> machines and you are successfully adding those channels to the system,
> you could take advantage of Guix's -e flag. e.g.
> 
> --8<---------------cut here---------------start------------->8---
> $ guix system reconfigure -e '(@ (my-custom-channel machines this-machine)
> use-this-system)'
> --8<---------------cut here---------------end--------------->8---

Yes! This is exactly what I hoped for! Thank you very much.  For anyone 
reading this in the future: the code is '(@ module-name procedure-name)'.
The operating-system record needs to be named with a define-public.

> When combined with unattended-upgrade-service-type [1] and embeddeding a
> "self-referential" channels.scm file in your configuration [2] (a
> channels.scm file that contains it's own repository), your systems would
> regularly reconfigure themselves using the newest versions of your
> channel machine configuration files.

Sounds lovely, but I would need to construct a continuous integration 
subsystem to be to able to use it.  I tend to experiment a lot while 
programming and I do not trust myself to just upgrade automatically to the 
newest revision of my code.  Most of my reconfigures fail, due to any number 
of reasons.

Now I really need to come up with a nice channel / distribution name.  The 
number of modules in my codebase is about to explode and I can already tell 
that renaming them after the fact would be… painful and tedious.

> [1]:
> https://git.sr.ht/~freakingpenguin/rsent/tree/
1b79ec8a91a9546d4cc158590b1d50145e5fe42a/item/rsent/machines/droplets/
rampart.scm#L69
> [2]:
> https://git.sr.ht/~freakingpenguin/rsent/tree/
1b79ec8a91a9546d4cc158590b1d50145e5fe42a/item/rsent/configs/channel.scm#L13


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Automated /etc/config.scm
  2024-05-27  3:41   ` Marek Paśnikowski
@ 2024-05-27 16:31     ` Richard Sent
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Sent @ 2024-05-27 16:31 UTC (permalink / raw)
  To: Marek Paśnikowski; +Cc: help-guix


> Sounds lovely, but I would need to construct a continuous integration 
> subsystem to be to able to use it.

Having a CI server on my LAN building my operating systems regularly is
very nice. It really speeds up system upgrades. Can recommmend, although
it is challenging!

> Now I really need to come up with a nice channel / distribution name.  The 
> number of modules in my codebase is about to explode and I can already tell 
> that renaming them after the fact would be… painful and tedious.

Yep, even if you try automation it definitely is painful to refactor! I
wish I was a bit more creative with my channel before going "well it's
my channel so....... my name is fine". :)

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


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

end of thread, other threads:[~2024-05-27 16:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-26 13:58 Automated /etc/config.scm Marek Paśnikowski
2024-05-26 18:03 ` David Larsson
2024-05-26 18:41   ` Marek Paśnikowski
2024-05-26 20:51 ` Richard Sent
2024-05-27  3:41   ` Marek Paśnikowski
2024-05-27 16:31     ` 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.