mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-13 12:13:36 +01:00
chore(desktop): make podman rootless-only
Disable the rootful system podman.socket on desktop hosts and drop the module's autoPrune, which prunes the rootful store and pulls in the rootful API service. Add a weekly per-user timer that prunes the rootless store instead.
This commit is contained in:
1 parent
ef61c458e6
commit
6a026ecf9f
1 file changed
+31
-7
@@ -1,4 +1,8 @@
|
||||
{ ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
###################################################################################
|
||||
#
|
||||
@@ -13,12 +17,9 @@
|
||||
dockerCompat = true;
|
||||
# Required for containers under podman-compose to be able to talk to each other.
|
||||
defaultNetwork.settings.dns_enabled = true;
|
||||
# Periodically prune Podman resources
|
||||
autoPrune = {
|
||||
enable = true;
|
||||
dates = "weekly";
|
||||
flags = [ "--all" ];
|
||||
};
|
||||
# No `autoPrune`: it prunes the *rootful* store and depends on the rootful
|
||||
# API service, neither of which a rootless-only desktop uses. Prune the
|
||||
# rootless store with the user timer below instead.
|
||||
};
|
||||
|
||||
# Bound container log growth. Podman uses journald when the journal is
|
||||
@@ -26,4 +27,27 @@
|
||||
# (k8s-file / json-file), which otherwise grows without limit.
|
||||
containers.containersConf.settings.containers.log_size_max = 10 * 1024 * 1024;
|
||||
};
|
||||
|
||||
# Desktop hosts use rootless podman only: the user is not in the `podman`
|
||||
# group, so the rootful system socket is unreachable and nothing here uses the
|
||||
# Docker/podman API. Disable it anyway so it cannot be reached by accident.
|
||||
# The per-user rootless socket (systemd.user.sockets.podman) is unaffected.
|
||||
systemd.sockets.podman.enable = false;
|
||||
|
||||
# Prune the rootless store (the module's autoPrune only covered the rootful
|
||||
# one). Runs in the user's session, so it fires while the desktop is logged in.
|
||||
systemd.user.services.podman-prune = {
|
||||
description = "Prune rootless podman resources";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${lib.getExe config.virtualisation.podman.package} system prune -f --all";
|
||||
};
|
||||
};
|
||||
systemd.user.timers.podman-prune = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "weekly";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user