Commit graph

9 commits

Author SHA1 Message Date
Giacomo Leidi
877610c1ce
services: oci: Fix OCI backed Shepherd services HOME variable.
This patch allows containers run with podman to run each with their own
specific user.

* doc/guix.texi: Fix wrong type for oci-container-configuration's
shepherd-dependencies field.
* gnu/services/containers.scm (oci-container-shepherd-service): In case
a specific container is not run through the user provisioned by the
oci-service-type, its environment is different from the globally
provisioned one and must be recomputed.

Change-Id: I5d636ad0616ced0af124002de4403da3067334de
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-09-18 12:14:35 +02:00
Giacomo Leidi
60f4d72590
services: Add oci-service-type.
This patch implements a generalization of the
oci-container-service-type, which consequently is made deprecated.  The
oci-service-type, in addition to all the features from the
oci-container-service-type, can now provision OCI networks and volumes.
It only handles OCI objects creation, the user is supposed to handle
state once the objects are provsioned.

It currently supports two different OCI runtimes: Docker and rootless
Podman.  Both runtimes are tested to make sure provisioned containers
can connect to each other through provisioned networks and can
read/write data with provisioned volumes.

At last the Scheme API is thought to facilitate the implementation of a
Guix Home service in the future.

* gnu/build/oci-containers.scm: New file containg OCI runtime business
logic used in OCI backed Shepherd services.
oci-read-lines
(oci-system*,oci-object-exists?,oci-object-service-available?
oci-image-load,oci-log-verbose,oci-container-execlp,oci-object-create):
New procedures.
* gnu/local.mk: Add it.
* gnu/services/containers.scm (list-of-oci-containers?,
list-of-oci-networks?,list-of-oci-volumes?,%oci-supported-runtimes,
oci-runtime?,oci-runtime-system-environment,oci-runtime-system-extra-arguments,
oci-runtime-system-requirement,oci-runtime-cli,oci-runtime-system-cli,
oci-runtime-home-cli,oci-runtime-name,oci-runtime-group,
oci-container-shepherd-name,oci-networks-shepherd-name,
oci-networks-home-shepherd-name,oci-volumes-shepherd-name,
oci-volumes-home-shepherd-name,oci-container-configuration->options,
oci-network-configuration->options,oci-volume-configuration->options,
oci-container-shepherd-service,oci-objects-merge-lst,oci-extension-merge,
oci-service-accounts,oci-service-profile,oci-service-subids,
oci-configuration->shepherd-services,oci-configuration-extend): New
procedures.
(image-reference): Implement unambiguous naming convention, that paired
with the new implementation for listing caches images with docker ls or
podman ls, allows for more efficient image caching.
(oci-container-configuration)[user,group]: Change default-type to
maybe-string, since by default containers will run under the user and
group declared in oci-configuration records. When unset the
oci-service-type will derive their value from the OCI runtime state.
[runtime,host-environment,environment,shepherd-actions,ports,extra-arguments]:
define a predicate and use it as a type in the configuration.  This
way errors are reported with source location information.
(lower-manifest): Defer to caller the logic of setting up an image tag.
(lower-oci-image): Rename to load-oci-image-state.
(oci-runtime-state): Intermediate representation of the OCI runtime
details. It is supposed to be an internal API.
(oci-state): Intermediate representation of the OCI provisioning state,
such as containers and networks. It is supposed to be an internal API.
(oci-container-invocation): Intermediate representation of the OCI
runtime run command to start a container. It is supposed to be an
internal API.
(%oci-image-loader): Rename to oci-image-loader and use
oci-runtime-state and (gnu build oci-containers).
(oci-container-shepherd-service): Use oci-state and oci-runtime-state,
add command-line action.
(oci-network-configuration,oci-volume-configuration,oci-configuration,
oci-extension): New record types.
(oci-service-type): New service-type.
* doc/guix.texi: Document it.
* gnu/tests/containers.scm: Test it.
* gnu/services/docker.scm: Deprecate the oci-container-service-type.

Change-Id: I656b3db85832e42d53072fcbfb91d1226f39ef38
Modified-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
2025-08-25 13:04:36 +09:00
Giacomo Leidi
30259d52e1
services: oci-container-configuration: Move to (gnu services containers).
This patch moves the oci-container-configuration and related
configuration records to (gnu services containers).
Public symbols are still exported for backwards
compatibility but since the oci-container-service-type will be
deprecated in favor of the more general oci-service-type, everything is
moved outside of the docker related module.

* gnu/services/docker.scm: Move everything related to oci-container-configuration
to...
* gnu/services/containers.scm: ...here.scm.

Change-Id: Iae599dd5cc7442eb632f0c1b3b12f6b928397ae7
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2025-05-15 11:09:11 +09:00
Giacomo Leidi
92058c15c8
services: rootless-podman: Use login shell.
This commit allows for having PATH set when changing the owner of
/sys/fs/group.

* gnu/services/containers.scm (crgroups-fs-owner): Use login shell.

Change-Id: I9510c637a5332325e05ca5ebc9dfd4de32685c50
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2025-05-15 11:09:11 +09:00
Ludovic Courtès
bd7b9e6a60
services: Add missing Shepherd dependency on ‘user-processes’.
Fixes <https://issues.guix.gnu.org/76368>.

* gnu/services/auditd.scm (auditd-shepherd-service):
* gnu/services/base.scm (rngd-service-type):
(gpm-shepherd-service):
* gnu/services/ci.scm (laminar-shepherd-service):
* gnu/services/containers.scm (rootless-podman-cgroups-fs-owner-service):
(rootless-podman-cgroups-limits-service):
* gnu/services/cups.scm (cups-shepherd-service):
* gnu/services/databases.scm (postgresql-role-shepherd-service):
* gnu/services/desktop.scm (upower-shepherd-service):
(bluetooth-shepherd-service):
(elogind-shepherd-service):
(inputattach-shepherd-service):
(seatd-shepherd-service):
* gnu/services/dns.scm (knot-resolver-shepherd-services):
(dnsmasq-shepherd-service):
* gnu/services/docker.scm (containerd-shepherd-service):
(docker-shepherd-service):
* gnu/services/file-sharing.scm (transmission-daemon-shepherd-service):
* gnu/services/games.scm (joycond-shepherd-service):
(wesnothd-shepherd-service):
* gnu/services/guix.scm (guix-build-coordinator-shepherd-services):
(guix-data-service-shepherd-services):
(nar-herder-shepherd-services):
(bffe-shepherd-services):
* gnu/services/ldap.scm (directory-server-shepherd-service):
* gnu/services/linux.scm (cachefilesd-shepherd-service):
(rasdaemon-shepherd-service):
* gnu/services/mail.scm (dovecot-shepherd-service):
(imap4d-shepherd-service):
(radicale-shepherd-service):
(rspamd-configuration):
* gnu/services/monitoring.scm (prometheus-node-exporter-shepherd-service):
(vnstat-shepherd-service):
* gnu/services/networking.scm (opendht-shepherd-service):
(openvswitch-shepherd-service):
(pagekite-shepherd-service):
(ipfs-shepherd-service):
* gnu/services/nfs.scm (rpcbind-service-type):
(gss-service-type):
(idmap-service-type):
* gnu/services/pm.scm (thermald-shepherd-service):
* gnu/services/rsync.scm (rsync-shepherd-service):
* gnu/services/samba.scm (samba-samba-shepherd-service):
(samba-nmbd-shepherd-service):
(samba-smbd-shepherd-service):
(samba-winbindd-shepherd-service):
(wsdd-shepherd-service):
* gnu/services/security-token.scm (pcscd-shepherd-service):
* gnu/services/sound.scm (speakersafetyd-shepherd-service):
* gnu/services/spice.scm (spice-vdagent-shepherd-service):
* gnu/services/ssh.scm (lsh-shepherd-service):
(openssh-shepherd-service):
(dropbear-shepherd-service):
(autossh-shepherd-service):
* gnu/services/telephony.scm (jami-shepherd-services):
(mumble-server-shepherd-service):
* gnu/services/version-control.scm (git-daemon-shepherd-service):
* gnu/services/virtualization.scm (virtlogd-shepherd-service):
* gnu/services/vnc.scm (xvnc-shepherd-service):
* gnu/services/vpn.scm (openvpn-shepherd-service):
(strongswan-shepherd-service):
* gnu/services/web.scm (httpd-shepherd-services):
(fcgiwrap-shepherd-service):
(php-fpm-shepherd-service):
(hpcguix-web-shepherd-service):
(tailon-shepherd-service):
(varnish-shepherd-service):
(whoogle-shepherd-service):
(mumi-shepherd-services):
(gmnisrv-shepherd-service):
(agate-shepherd-service): Add ‘user-processes’ requirement.
* doc/guix.texi (Mail Services): Update accordingly.

Reported-by: Dariqq <dariqq@posteo.net>
Change-Id: I947bd2afc83b786cb17c555cfe73ab586b806618
2025-02-23 22:53:06 +01:00
Giacomo Leidi
24a12aeb91
services: rootless-podman: Enable I/O delegation.
Based on
https://rootlesscontaine.rs/getting-started/common/cgroup2/#enabling-cpu-cpuset-and-io-delegation
, this patch enables I/O delegation for cgroups v2 enabled users.

* gnu/services/containers.scm (cgroups-limits-entrypoint): Enable I/O
controller delegation.
* gnu/tests/containers.scm: Test it.

Change-Id: I7caba33695f11830bea477c4ab3afb89cfaa2fa5
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-01-11 23:36:58 +01:00
Tomas Volf
cc58b52e15
services: rootless-podman-service-type: Allow not installing podman.
Sometimes you would want to skip on actually installing the podman package in
order to save disk space and bandwidth.  Even without installing it globally,
podman can still be fetched via guix shell when required.

* gnu/services/containers.scm (package-or-#f?): New procedure.
(rootless-podman-configuration)<podman>: Change type to package-or-#f.
(rootless-podman-service-profile): Produce empty list if not podman package.
* doc/guix.texi (Miscellaneous Services): Document the change.

Change-Id: If533d913ea190558ce7e206d98ada4d805270594
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-01-06 16:05:04 +01:00
Giacomo Leidi
a75b2d614a
services: rootless-podman: Fix PATH lookup for Shepherd services.
One-shot Shepherd services required to correctly setup Podman in the
Guix System, are failing to find executables upon boot.  This patch
changes the executable references to absolute paths to avoid PATH
lookup.

* gnu/services/containers.scm (cgroups-fs-owner-entrypoint): Hardcode
bash path;
(rootless-podman-cgroups-fs-owner-service): Ditto;
(rootless-podman-fs-entrypoint): Hardcode mount path.

Change-Id: Id6a27cadf51326ce57af93f57809b77e28dbeaef
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-25 23:51:10 +01:00
Giacomo Leidi
2767b4ef03
services: Add rootless-podman-service-type.
* gnu/services/containers.scm: New file;
(rootless-podman-configuration): new variable;
(rootless-podman-service-subids): new variable;
(rootless-podman-service-accounts): new variable;
(rootless-podman-service-profile): new variable;
(rootless-podman-shepherd-services): new variable;
(rootless-podman-service-etc): new variable;
(rootless-podman-service-type): new variable.
* gnu/local.mk: Test it.
* gnu/local.mk: Add them.
* doc/guix.texi (Miscellaneous Services): Document it.

Change-Id: I041496474c1027da353bd6852f2554a065914d7a
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-18 18:32:41 +01:00