From: Gary Johnson <lambdatronic@disroot.org>
To: "Marek Paśnikowski" <marekpasnikowski@protonmail.com>
Cc: help-guix@gnu.org
Subject: Re: How to declare symlinks in the configuration?
Date: Tue, 23 May 2023 10:40:44 -0400 [thread overview]
Message-ID: <87wn0zxerk.fsf@disroot.org> (raw)
In-Reply-To: <5dVQf1-KvHUWuYLP15clr9s1BSmqmLZX0sPseYqnbYUdgw-Wid7MbFKaMY2pE0KRWbgdb-i-JUCWxTFUPwyJVL2cqoQ36xBh2PQn1EuQ2j8=@protonmail.com>
Marek Paśnikowski <marekpasnikowski@protonmail.com> writes:
> Thank you Gary.
>
> This is the kind of answer I was hoping for. Could you also share with
> me the corresponding service-type for the system configuration?
Hi Marek,
In the system configuration, most of the files that you would edit by
hand on another distro (e.g., config files under /etc) are not managed
directly by a single service in Guix System. Instead, you typically add
services (e.g., `postgresql-service-type`, `cups-service-type`,
`strongswan-service-type`) to your `operating-system` definition and
declare their configurations within each service's scheme code.
For example, here is how you might edit the config files for a
Postgresql server:
```scheme
(use-modules
((gnu packages databases) #:select (postgresql))
((gnu packages geo) #:select (postgis))
((gnu services) #:select (service))
((gnu services databases) #:select (postgresql-service-type postgresql-configuration postgresql-config-file))
((gnu services desktop) #:select (%desktop-services))
((gnu system) #:select (operating-system))
((guix gexp) #:select (local-file)))
(operating-system
;; ...Eliding all the fields except `services`...
(services (cons (service postgresql-service-type
(postgresql-configuration
(postgresql postgresql)
(extension-packages (list postgis))
(config-file
(postgresql-config-file
(hba-file (local-file "etcfiles/pg_hba.conf"))
(extra-config '(("max_worker_processes" "12")
("max_parallel_workers" "40")
("max_parallel_maintenance_workers" "8")
("max_parallel_workers_per_gather" "4")
("parallel_leader_participation"
"on")))))))
%desktop-services)))
```
In this example, I showed two ways of specifying the contents of a
config file for this service:
1. Using `local-file` to pull in the contents of a text file somewhere
on disk. In this case, I keep my system-wide service config files
under a directory called "etcfiles" (in my home directory). For
config files referenced in my `guix home` configuration, I use a
directory called "dotfiles".
2. Including the contents of these files directly in the
`operating-system` declaration. In this case, you see me specifying
key-value pairs for the main Postgresql config file in a nested list
under the `extra-config` record parameter.
=======================================================================
Now...having provided the above explanation as the typical usage pattern
for configuring services on Guix System, I will add that there is an
escape hatch that you can use (as a last resort if there isn't an
existing service that controls the files you want to edit).
This is the service called `etc-service-type`. You can use it to declare
any arbitrary files that would like added immutably under the top level
"/etc" directory. You can use it like so:
```scheme
(use-modules
((gnu services) #:select (service etc-service-type))
((gnu services desktop) #:select (%desktop-services))
((gnu system) #:select (operating-system))
((guix gexp) #:select (local-file)))
(operating-system
;; ...Eliding all the fields except `services`...
(services (cons (service etc-service-type
`(("resolv.conf" ,(local-file "etcfiles/resolv.conf"))))
%desktop-services)))
```
Now you know, and knowing is half the battle. ;)
Have fun and happy hacking on Guix!
~Gary
--
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
Why is HTML email a security nightmare? See https://useplaintext.email/
Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
next prev parent reply other threads:[~2023-05-23 15:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 11:14 How to declare symlinks in the configuration? Marek Paśnikowski
2023-05-16 13:56 ` Felix Lechner via
2023-05-17 6:50 ` Marek Paśnikowski
2023-05-18 2:40 ` Gary Johnson
2023-05-18 3:43 ` Marek Paśnikowski
2023-05-18 3:45 ` Felix Lechner via
2023-05-23 14:40 ` Gary Johnson [this message]
2023-05-23 16:11 ` Felix Lechner via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wn0zxerk.fsf@disroot.org \
--to=lambdatronic@disroot.org \
--cc=help-guix@gnu.org \
--cc=marekpasnikowski@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.