docker: fix systemd unit files (#120019)

* docker: fix systemd unit files

Add missing docker.socket file and patch ExecStart in docker.service
so these units are useful on non-nixos systems using systemd.
(issue #70407)

* moved systemd units under: optionalString (stdenv.isLinux)
This commit is contained in:
gfrascadorio 2021-04-25 20:43:09 -04:00 committed by GitHub
parent 1f0fb586c3
commit a54bc9b671
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,6 +105,8 @@ rec {
# systemd
install -Dm644 ./contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service
substituteInPlace $out/etc/systemd/system/docker.service --replace /usr/bin/dockerd $out/bin/dockerd
install -Dm644 ./contrib/init/systemd/docker.socket $out/etc/systemd/system/docker.socket
'';
DOCKER_BUILDTAGS = []
@ -178,6 +180,11 @@ rec {
'' + optionalString (stdenv.isLinux) ''
# symlink docker daemon to docker cli derivation
ln -s ${moby}/bin/dockerd $out/bin/dockerd
# systemd
mkdir -p $out/etc/systemd/system
ln -s ${moby}/etc/systemd/system/docker.service $out/etc/systemd/system/docker.service
ln -s ${moby}/etc/systemd/system/docker.socket $out/etc/systemd/system/docker.socket
'' + ''
# completion (cli)
installShellCompletion --bash ./contrib/completion/bash/docker