diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index 48bb512e1341..467b966f3ab0 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -13,18 +13,8 @@ rec { , runcRev, runcSha256 , containerdRev, containerdSha256 , tiniRev, tiniSha256 - } : stdenv.mkDerivation rec { - inherit version rev; - - name = "docker-${version}"; - - src = fetchFromGitHub { - owner = "docker"; - repo = "docker-ce"; - rev = "v${version}"; - sha256 = sha256; - }; - + } : + let docker-runc = runc.overrideAttrs (oldAttrs: rec { name = "docker-runc"; src = fetchFromGitHub { @@ -36,6 +26,7 @@ rec { # docker/runc already include these patches / are not applicable patches = []; }); + docker-containerd = containerd.overrideAttrs (oldAttrs: rec { name = "docker-containerd"; src = fetchFromGitHub { @@ -51,6 +42,7 @@ rec { mv $(pwd)/vendor/{github.com,golang.org,google.golang.org} $(pwd)/vendor/src/ '' + oldAttrs.preBuild; }); + docker-tini = tini.overrideAttrs (oldAttrs: rec { name = "docker-init"; src = fetchFromGitHub { @@ -68,17 +60,10 @@ rec { "-DMINIMAL=ON" ]; }); + in + stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec { - # Optimizations break compilation of libseccomp c bindings - hardeningDisable = [ "fortify" ]; - - nativeBuildInputs = [ pkgconfig ]; - buildInputs = [ - makeWrapper removeReferencesTo go-md2man go - sqlite devicemapper btrfs-progs systemd libtool libseccomp - ]; - - dontStrip = true; + inherit docker-runc docker-containerd docker-tini; DOCKER_BUILDTAGS = [] ++ optional (systemd != null) [ "journald" ] @@ -86,14 +71,38 @@ rec { ++ optional (devicemapper == null) "exclude_graphdriver_devicemapper" ++ optional (libseccomp != null) "seccomp"; - buildPhase = '' + }) // rec { + inherit version rev; + + name = "docker-${version}"; + + src = fetchFromGitHub { + owner = "docker"; + repo = "docker-ce"; + rev = "v${version}"; + sha256 = sha256; + }; + + # Optimizations break compilation of libseccomp c bindings + hardeningDisable = [ "fortify" ]; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ + makeWrapper removeReferencesTo go-md2man go libtool + ] ++ optionals (stdenv.isLinux) [ + sqlite devicemapper btrfs-progs systemd libtool libseccomp + ]; + + dontStrip = true; + + buildPhase = (optionalString (stdenv.isLinux) '' # build engine cd ./components/engine export AUTO_GOPATH=1 export DOCKER_GITCOMMIT="${rev}" ./hack/make.sh dynbinary cd - - + '') + '' # build cli cd ./components/cli # Mimic AUTO_GOPATH @@ -110,27 +119,24 @@ rec { # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd patchPhase = '' + substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" + '' + optionalString (stdenv.isLinux) '' patchShebangs . substituteInPlace ./components/engine/hack/make.sh --replace libsystemd-journal libsystemd substituteInPlace ./components/engine/daemon/logger/journald/read.go --replace libsystemd-journal libsystemd - substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" - ''; + ''; outputs = ["out" "man"]; - extraPath = makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]; - - installPhase = '' - install -Dm755 ./components/cli/docker $out/libexec/docker/docker + extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]); + installPhase = optionalString (stdenv.isLinux) '' if [ -d "./components/engine/bundles/${version}" ]; then install -Dm755 ./components/engine/bundles/${version}/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd else install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd fi - makeWrapper $out/libexec/docker/docker $out/bin/docker \ - --prefix PATH : "$out/libexec/docker:$extraPath" makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \ --prefix PATH : "$out/libexec/docker:$extraPath" @@ -143,6 +149,11 @@ rec { # systemd install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service + '' + '' + install -Dm755 ./components/cli/docker $out/libexec/docker/docker + + makeWrapper $out/libexec/docker/docker $out/bin/docker \ + --prefix PATH : "$out/libexec/docker:$extraPath" # completion (cli) install -Dm644 ./components/cli/contrib/completion/bash/docker $out/share/bash-completion/completions/docker @@ -174,17 +185,19 @@ rec { ''; preFixup = '' - find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} -t ${stdenv.glibc.dev} '{}' + + find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} '{}' + + '' + optionalString (stdenv.isLinux) '' + find $out -type f -exec remove-references-to -t ${stdenv.glibc.dev} '{}' + ''; meta = { homepage = https://www.docker.com/; description = "An open source project to pack, ship and run any application as a lightweight container"; license = licenses.asl20; - maintainers = with maintainers; [ nequissimus offline tailhook vdemeester ]; - platforms = platforms.linux; + maintainers = with maintainers; [ nequissimus offline tailhook vdemeester periklis ]; + platforms = with platforms; [ linux darwin ]; }; - }; + }); # Get revisions from # https://github.com/docker/docker-ce/blob/v${version}/components/engine/hack/dockerfile/binaries-commits