docker-cli: enable darwin support

+46 -33
+46 -33
pkgs/applications/virtualization/docker/default.nix
··· 13 , runcRev, runcSha256 14 , containerdRev, containerdSha256 15 , tiniRev, tiniSha256 16 - } : stdenv.mkDerivation rec { 17 - inherit version rev; 18 - 19 - name = "docker-${version}"; 20 - 21 - src = fetchFromGitHub { 22 - owner = "docker"; 23 - repo = "docker-ce"; 24 - rev = "v${version}"; 25 - sha256 = sha256; 26 - }; 27 - 28 docker-runc = runc.overrideAttrs (oldAttrs: rec { 29 name = "docker-runc"; 30 src = fetchFromGitHub { ··· 36 # docker/runc already include these patches / are not applicable 37 patches = []; 38 }); 39 docker-containerd = containerd.overrideAttrs (oldAttrs: rec { 40 name = "docker-containerd"; 41 src = fetchFromGitHub { ··· 51 mv $(pwd)/vendor/{github.com,golang.org,google.golang.org} $(pwd)/vendor/src/ 52 '' + oldAttrs.preBuild; 53 }); 54 docker-tini = tini.overrideAttrs (oldAttrs: rec { 55 name = "docker-init"; 56 src = fetchFromGitHub { ··· 68 "-DMINIMAL=ON" 69 ]; 70 }); 71 72 # Optimizations break compilation of libseccomp c bindings 73 hardeningDisable = [ "fortify" ]; 74 75 nativeBuildInputs = [ pkgconfig ]; 76 buildInputs = [ 77 - makeWrapper removeReferencesTo go-md2man go 78 sqlite devicemapper btrfs-progs systemd libtool libseccomp 79 ]; 80 81 dontStrip = true; 82 83 - DOCKER_BUILDTAGS = [] 84 - ++ optional (systemd != null) [ "journald" ] 85 - ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs" 86 - ++ optional (devicemapper == null) "exclude_graphdriver_devicemapper" 87 - ++ optional (libseccomp != null) "seccomp"; 88 - 89 - buildPhase = '' 90 # build engine 91 cd ./components/engine 92 export AUTO_GOPATH=1 93 export DOCKER_GITCOMMIT="${rev}" 94 ./hack/make.sh dynbinary 95 cd - 96 - 97 # build cli 98 cd ./components/cli 99 # Mimic AUTO_GOPATH ··· 110 111 # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd 112 patchPhase = '' 113 patchShebangs . 114 substituteInPlace ./components/engine/hack/make.sh --replace libsystemd-journal libsystemd 115 substituteInPlace ./components/engine/daemon/logger/journald/read.go --replace libsystemd-journal libsystemd 116 - substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" 117 - ''; 118 119 outputs = ["out" "man"]; 120 121 - extraPath = makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]; 122 123 - installPhase = '' 124 - install -Dm755 ./components/cli/docker $out/libexec/docker/docker 125 - 126 if [ -d "./components/engine/bundles/${version}" ]; then 127 install -Dm755 ./components/engine/bundles/${version}/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd 128 else 129 install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd 130 fi 131 132 - makeWrapper $out/libexec/docker/docker $out/bin/docker \ 133 - --prefix PATH : "$out/libexec/docker:$extraPath" 134 makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \ 135 --prefix PATH : "$out/libexec/docker:$extraPath" 136 ··· 143 144 # systemd 145 install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service 146 147 # completion (cli) 148 install -Dm644 ./components/cli/contrib/completion/bash/docker $out/share/bash-completion/completions/docker ··· 174 ''; 175 176 preFixup = '' 177 - find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} -t ${stdenv.glibc.dev} '{}' + 178 ''; 179 180 meta = { 181 homepage = https://www.docker.com/; 182 description = "An open source project to pack, ship and run any application as a lightweight container"; 183 license = licenses.asl20; 184 - maintainers = with maintainers; [ nequissimus offline tailhook vdemeester ]; 185 - platforms = platforms.linux; 186 }; 187 - }; 188 189 # Get revisions from 190 # https://github.com/docker/docker-ce/blob/v${version}/components/engine/hack/dockerfile/binaries-commits
··· 13 , runcRev, runcSha256 14 , containerdRev, containerdSha256 15 , tiniRev, tiniSha256 16 + } : 17 + let 18 docker-runc = runc.overrideAttrs (oldAttrs: rec { 19 name = "docker-runc"; 20 src = fetchFromGitHub { ··· 26 # docker/runc already include these patches / are not applicable 27 patches = []; 28 }); 29 + 30 docker-containerd = containerd.overrideAttrs (oldAttrs: rec { 31 name = "docker-containerd"; 32 src = fetchFromGitHub { ··· 42 mv $(pwd)/vendor/{github.com,golang.org,google.golang.org} $(pwd)/vendor/src/ 43 '' + oldAttrs.preBuild; 44 }); 45 + 46 docker-tini = tini.overrideAttrs (oldAttrs: rec { 47 name = "docker-init"; 48 src = fetchFromGitHub { ··· 60 "-DMINIMAL=ON" 61 ]; 62 }); 63 + in 64 + stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec { 65 + 66 + inherit docker-runc docker-containerd docker-tini; 67 + 68 + DOCKER_BUILDTAGS = [] 69 + ++ optional (systemd != null) [ "journald" ] 70 + ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs" 71 + ++ optional (devicemapper == null) "exclude_graphdriver_devicemapper" 72 + ++ optional (libseccomp != null) "seccomp"; 73 + 74 + }) // rec { 75 + inherit version rev; 76 + 77 + name = "docker-${version}"; 78 + 79 + src = fetchFromGitHub { 80 + owner = "docker"; 81 + repo = "docker-ce"; 82 + rev = "v${version}"; 83 + sha256 = sha256; 84 + }; 85 86 # Optimizations break compilation of libseccomp c bindings 87 hardeningDisable = [ "fortify" ]; 88 89 nativeBuildInputs = [ pkgconfig ]; 90 buildInputs = [ 91 + makeWrapper removeReferencesTo go-md2man go libtool 92 + ] ++ optionals (stdenv.isLinux) [ 93 sqlite devicemapper btrfs-progs systemd libtool libseccomp 94 ]; 95 96 dontStrip = true; 97 98 + buildPhase = (optionalString (stdenv.isLinux) '' 99 # build engine 100 cd ./components/engine 101 export AUTO_GOPATH=1 102 export DOCKER_GITCOMMIT="${rev}" 103 ./hack/make.sh dynbinary 104 cd - 105 + '') + '' 106 # build cli 107 cd ./components/cli 108 # Mimic AUTO_GOPATH ··· 119 120 # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd 121 patchPhase = '' 122 + substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" 123 + '' + optionalString (stdenv.isLinux) '' 124 patchShebangs . 125 substituteInPlace ./components/engine/hack/make.sh --replace libsystemd-journal libsystemd 126 substituteInPlace ./components/engine/daemon/logger/journald/read.go --replace libsystemd-journal libsystemd 127 + ''; 128 129 outputs = ["out" "man"]; 130 131 + extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]); 132 133 + installPhase = optionalString (stdenv.isLinux) '' 134 if [ -d "./components/engine/bundles/${version}" ]; then 135 install -Dm755 ./components/engine/bundles/${version}/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd 136 else 137 install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd 138 fi 139 140 makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \ 141 --prefix PATH : "$out/libexec/docker:$extraPath" 142 ··· 149 150 # systemd 151 install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service 152 + '' + '' 153 + install -Dm755 ./components/cli/docker $out/libexec/docker/docker 154 + 155 + makeWrapper $out/libexec/docker/docker $out/bin/docker \ 156 + --prefix PATH : "$out/libexec/docker:$extraPath" 157 158 # completion (cli) 159 install -Dm644 ./components/cli/contrib/completion/bash/docker $out/share/bash-completion/completions/docker ··· 185 ''; 186 187 preFixup = '' 188 + find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} '{}' + 189 + '' + optionalString (stdenv.isLinux) '' 190 + find $out -type f -exec remove-references-to -t ${stdenv.glibc.dev} '{}' + 191 ''; 192 193 meta = { 194 homepage = https://www.docker.com/; 195 description = "An open source project to pack, ship and run any application as a lightweight container"; 196 license = licenses.asl20; 197 + maintainers = with maintainers; [ nequissimus offline tailhook vdemeester periklis ]; 198 + platforms = with platforms; [ linux darwin ]; 199 }; 200 + }); 201 202 # Get revisions from 203 # https://github.com/docker/docker-ce/blob/v${version}/components/engine/hack/dockerfile/binaries-commits