docker-cli: enable darwin support

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