docker: avoid setting empty path segments into PATH

Fixes #530304
This commit is contained in:
Thomas Gerbet
2026-07-25 12:09:00 +02:00
parent 695a57795e
commit c57addab0d
@@ -143,6 +143,27 @@ let
hash = mobyHash;
};
extraMobyPath = lib.optionals stdenv.hostPlatform.isLinux (
lib.makeBinPath [
iproute2
iptables
e2fsprogs
xz
xfsprogs
procps
util-linuxMinimal
gitMinimal
]
);
extraMobyUserPath = lib.optionals (stdenv.hostPlatform.isLinux && !clientOnly) (
lib.makeBinPath [
rootlesskit
slirp4netns
fuse-overlayfs
]
);
moby = buildGoModule (
lib.optionalAttrs stdenv.hostPlatform.isLinux {
pname = "moby";
@@ -170,27 +191,6 @@ let
++ lib.optionals withSystemd [ systemd ]
++ lib.optionals withSeccomp [ libseccomp ];
extraPath = lib.optionals stdenv.hostPlatform.isLinux (
lib.makeBinPath [
iproute2
iptables
e2fsprogs
xz
xfsprogs
procps
util-linuxMinimal
gitMinimal
]
);
extraUserPath = lib.optionals (stdenv.hostPlatform.isLinux && !clientOnly) (
lib.makeBinPath [
rootlesskit
slirp4netns
fuse-overlayfs
]
);
postPatch = ''
patchShebangs hack/make.sh hack/make/
''
@@ -218,7 +218,9 @@ let
install -Dm755 ./bundles/dynbinary-daemon/docker-proxy $out/libexec/docker/docker-proxy
makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \
--prefix PATH : "$out/libexec/docker:$extraPath"
--prefix PATH : "$out/libexec/docker${
lib.optionalString (extraMobyPath != "") ":${extraMobyPath}"
}"
ln -s ${docker-containerd}/bin/containerd $out/libexec/docker/containerd
ln -s ${docker-containerd}/bin/containerd-shim${lib.optionalString (lib.versionAtLeast version "29.0.0") "-runc-v2"} $out/libexec/docker/containerd-shim${lib.optionalString (lib.versionAtLeast version "29.0.0") "-runc-v2"}
@@ -233,7 +235,9 @@ let
# rootless Docker
install -Dm755 ./contrib/dockerd-rootless.sh $out/libexec/docker/dockerd-rootless.sh
makeWrapper $out/libexec/docker/dockerd-rootless.sh $out/bin/dockerd-rootless \
--prefix PATH : "$out/libexec/docker:$extraPath:$extraUserPath"
--prefix PATH : "$out/libexec/docker${
lib.optionalString (extraMobyPath != "") ":${extraMobyPath}"
}${lib.optionalString (extraMobyUserPath != "") ":${extraMobyUserPath}"}"
runHook postInstall
'';
@@ -335,7 +339,7 @@ let
install -Dm755 ./build/docker $out/libexec/docker/docker
makeWrapper $out/libexec/docker/docker $out/bin/docker \
--prefix PATH : "$out/libexec/docker:$extraPath" \
--prefix PATH : "$out/libexec/docker" \
--prefix DOCKER_CLI_PLUGIN_DIRS : "${dockerCliPluginsDirs}"
''
+ lib.optionalString (!clientOnly) ''