From 720399b00d659d0c445056e730bd0ba2c9cb4b63 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Tue, 28 Jul 2026 18:17:43 +1000 Subject: [PATCH] fix(docker): declaratively apply groupmod --non-unique for IPA GID conflict NixOS's group activation uses plain groupmod, which silently skips the GID change when SSSD exposes the same GID (50010) via the IPA docker-access group through NSS. Add an activation script that runs after the normal 'groups' step and applies groupmod --non-unique so the local docker group can share GID 50010 with the SSSD-provided IPA group. If the GID actually changes on a live system the script also restarts docker.socket + docker.service so the socket is recreated with the new GID. Co-Authored-By: Claude Sonnet 4.6 --- modules/docker/enable-service.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/docker/enable-service.nix b/modules/docker/enable-service.nix index e52f579..b6da8d8 100644 --- a/modules/docker/enable-service.nix +++ b/modules/docker/enable-service.nix @@ -1,5 +1,8 @@ { lib, pkgs, vars, ... }: +let + gid = toString vars.dockerAccessGid; +in { virtualisation.docker = { enable = true; @@ -16,4 +19,27 @@ docker-compose 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 + ''; + }; }