fix(docker): declaratively apply groupmod --non-unique for IPA GID conflict #92

Merged
beatzaplenty merged 1 commits from worktree-parsed-mapping-raven into main 2026-07-28 08:19:53 +00:00
Showing only changes of commit 720399b00d - Show all commits
+26
View File
@@ -1,5 +1,8 @@
{ lib, pkgs, vars, ... }: { lib, pkgs, vars, ... }:
let
gid = toString vars.dockerAccessGid;
in
{ {
virtualisation.docker = { virtualisation.docker = {
enable = true; enable = true;
@@ -16,4 +19,27 @@
docker-compose docker-compose
docker-buildx docker-buildx
]; ];
# NixOS's group activation uses plain `groupmod` without --non-unique.
# When SSSD is active it exposes the IPA "docker-access" group at
# vars.dockerAccessGid via NSS, so groupmod sees that GID as already in
# use and silently skips the change (warning: "not applying GID change").
# This script runs after the normal "groups" step and applies the change
# with --non-unique (which lets the local docker group share the GID with
# the SSSD-provided IPA group). If the GID actually changed it also
# restarts docker.socket so the socket is recreated with the new GID.
system.activationScripts.docker-group-gid = {
deps = [ "groups" ];
text = ''
current=$(grep "^docker:" /etc/group | cut -d: -f3)
if [ "$current" != "${gid}" ]; then
${pkgs.shadow}/bin/groupmod --non-unique -g ${gid} docker
if ${pkgs.systemd}/bin/systemctl is-active --quiet docker.socket; then
${pkgs.systemd}/bin/systemctl stop docker.service docker.socket
rm -f /var/run/docker.sock
${pkgs.systemd}/bin/systemctl start docker.socket docker.service
fi
fi
'';
};
} }