at 18.09-beta 211 lines 7.4 kB view raw
1{ stdenv, lib, fetchFromGitHub, makeWrapper, removeReferencesTo, pkgconfig 2, go-md2man, go, containerd, runc, docker-proxy, tini, libtool 3, sqlite, iproute, lvm2, systemd 4, btrfs-progs, iptables, e2fsprogs, xz, utillinux, xfsprogs 5, procps, libseccomp 6}: 7 8with lib; 9 10rec { 11 dockerGen = { 12 version, rev, sha256 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 { 21 owner = "docker"; 22 repo = "runc"; 23 rev = runcRev; 24 sha256 = runcSha256; 25 }; 26 # docker/runc already include these patches / are not applicable 27 patches = []; 28 }); 29 30 docker-containerd = (containerd.override { inherit go; }).overrideAttrs (oldAttrs: rec { 31 name = "docker-containerd"; 32 src = fetchFromGitHub { 33 owner = "docker"; 34 repo = "containerd"; 35 rev = containerdRev; 36 sha256 = containerdSha256; 37 }; 38 39 hardeningDisable = [ "fortify" ]; 40 41 buildInputs = [ removeReferencesTo go btrfs-progs ]; 42 }); 43 44 docker-tini = tini.overrideAttrs (oldAttrs: rec { 45 name = "docker-init"; 46 src = fetchFromGitHub { 47 owner = "krallin"; 48 repo = "tini"; 49 rev = tiniRev; 50 sha256 = tiniSha256; 51 }; 52 53 # Do not remove static from make files as we want a static binary 54 patchPhase = '' 55 ''; 56 57 NIX_CFLAGS_COMPILE = [ 58 "-DMINIMAL=ON" 59 ]; 60 }); 61 in 62 stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec { 63 64 inherit docker-runc docker-containerd docker-proxy docker-tini; 65 66 DOCKER_BUILDTAGS = [] 67 ++ optional (systemd != null) [ "journald" ] 68 ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs" 69 ++ optional (lvm2 == null) "exclude_graphdriver_devicemapper" 70 ++ optional (libseccomp != null) "seccomp"; 71 72 }) // rec { 73 inherit version rev; 74 75 name = "docker-${version}"; 76 77 src = fetchFromGitHub { 78 owner = "docker"; 79 repo = "docker-ce"; 80 rev = "v${version}"; 81 sha256 = sha256; 82 }; 83 84 # Optimizations break compilation of libseccomp c bindings 85 hardeningDisable = [ "fortify" ]; 86 87 nativeBuildInputs = [ pkgconfig ]; 88 buildInputs = [ 89 makeWrapper removeReferencesTo go-md2man go libtool 90 ] ++ optionals (stdenv.isLinux) [ 91 sqlite lvm2 btrfs-progs systemd libseccomp 92 ]; 93 94 dontStrip = true; 95 96 buildPhase = (optionalString (stdenv.isLinux) '' 97 # build engine 98 cd ./components/engine 99 export AUTO_GOPATH=1 100 export DOCKER_GITCOMMIT="${rev}" 101 export VERSION="${version}" 102 ./hack/make.sh dynbinary 103 cd - 104 '') + '' 105 # build cli 106 cd ./components/cli 107 # Mimic AUTO_GOPATH 108 mkdir -p .gopath/src/github.com/docker/ 109 ln -sf $PWD .gopath/src/github.com/docker/cli 110 export GOPATH="$PWD/.gopath:$GOPATH" 111 export GITCOMMIT="${rev}" 112 export VERSION="${version}" 113 source ./scripts/build/.variables 114 export CGO_ENABLED=1 115 go build -tags pkcs11 --ldflags "$LDFLAGS" github.com/docker/cli/cmd/docker 116 cd - 117 ''; 118 119 # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd 120 patchPhase = '' 121 substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" 122 '' + optionalString (stdenv.isLinux) '' 123 patchShebangs . 124 substituteInPlace ./components/engine/hack/make.sh --replace libsystemd-journal libsystemd 125 substituteInPlace ./components/engine/daemon/logger/journald/read.go --replace libsystemd-journal libsystemd 126 ''; 127 128 outputs = ["out" "man"]; 129 130 extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]); 131 132 installPhase = optionalString (stdenv.isLinux) '' 133 install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd $out/libexec/docker/dockerd 134 135 makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \ 136 --prefix PATH : "$out/libexec/docker:$extraPath" 137 138 # docker uses containerd now 139 ln -s ${docker-containerd}/bin/containerd $out/libexec/docker/docker-containerd 140 ln -s ${docker-containerd}/bin/containerd-shim $out/libexec/docker/docker-containerd-shim 141 ln -s ${docker-runc}/bin/runc $out/libexec/docker/docker-runc 142 ln -s ${docker-proxy}/bin/docker-proxy $out/libexec/docker/docker-proxy 143 ln -s ${docker-tini}/bin/tini-static $out/libexec/docker/docker-init 144 145 # systemd 146 install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service 147 '' + '' 148 install -Dm755 ./components/cli/docker $out/libexec/docker/docker 149 150 makeWrapper $out/libexec/docker/docker $out/bin/docker \ 151 --prefix PATH : "$out/libexec/docker:$extraPath" 152 153 # completion (cli) 154 install -Dm644 ./components/cli/contrib/completion/bash/docker $out/share/bash-completion/completions/docker 155 install -Dm644 ./components/cli/contrib/completion/fish/docker.fish $out/share/fish/vendor_completions.d/docker.fish 156 install -Dm644 ./components/cli/contrib/completion/zsh/_docker $out/share/zsh/site-functions/_docker 157 158 # Include contributed man pages (cli) 159 # Generate man pages from cobra commands 160 echo "Generate man pages from cobra" 161 cd ./components/cli 162 mkdir -p ./man/man1 163 go build -o ./gen-manpages github.com/docker/cli/man 164 ./gen-manpages --root . --target ./man/man1 165 166 # Generate legacy pages from markdown 167 echo "Generate legacy manpages" 168 ./man/md2man-all.sh -q 169 170 manRoot="$man/share/man" 171 mkdir -p "$manRoot" 172 for manDir in ./man/man?; do 173 manBase="$(basename "$manDir")" # "man1" 174 for manFile in "$manDir"/*; do 175 manName="$(basename "$manFile")" # "docker-build.1" 176 mkdir -p "$manRoot/$manBase" 177 gzip -c "$manFile" > "$manRoot/$manBase/$manName.gz" 178 done 179 done 180 ''; 181 182 preFixup = '' 183 find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} '{}' + 184 '' + optionalString (stdenv.isLinux) '' 185 find $out -type f -exec remove-references-to -t ${stdenv.glibc.dev} '{}' + 186 ''; 187 188 meta = { 189 homepage = https://www.docker.com/; 190 description = "An open source project to pack, ship and run any application as a lightweight container"; 191 license = licenses.asl20; 192 maintainers = with maintainers; [ nequissimus offline tailhook vdemeester periklis ]; 193 platforms = with platforms; linux ++ darwin; 194 }; 195 }); 196 197 # Get revisions from 198 # https://github.com/docker/docker-ce/tree/v${version}/components/engine/hack/dockerfile/install/* 199 200 docker_18_06 = dockerGen rec { 201 version = "18.06.1-ce"; 202 rev = "e68fc7a215d7133c34aa18e3b72b4a21fd0c6136"; # git commit 203 sha256 = "1bqd6pv5hga4j1s8jm8q5qdnfbjf8lw1ghdk0bw9hhqkn7rcnrv4"; 204 runcRev = "69663f0bd4b60df09991c08812a60108003fa340"; 205 runcSha256 = "1l37r97l3ra4ph069w190d05r0a43s76nn9jvvlkbwrip1cp6gyq"; 206 containerdRev = "468a545b9edcd5932818eb9de8e72413e616e86e"; 207 containerdSha256 = "1rp015cm5fw9kfarcmfhfkr1sh0iz7kvqls6f8nfhwrrz5armd5v"; 208 tiniRev = "fec3683b971d9c3ef73f284f176672c44b448662"; 209 tiniSha256 = "1h20i3wwlbd8x4jr2gz68hgklh0lb0jj7y5xk1wvr8y58fip1rdn"; 210 }; 211}