2017-03-11 14:08:04 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, makeWrapper, removeReferencesTo, pkgconfig
|
2017-07-10 08:56:51 +01:00
|
|
|
, go-md2man, go, containerd, runc, docker-proxy, tini, libtool
|
2016-09-10 11:45:01 +01:00
|
|
|
, sqlite, iproute, bridge-utils, devicemapper, systemd
|
|
|
|
, btrfs-progs, iptables, e2fsprogs, xz, utillinux, xfsprogs
|
2017-07-22 19:27:44 +01:00
|
|
|
, procps, libseccomp
|
2015-11-16 15:17:32 +00:00
|
|
|
}:
|
2014-01-24 13:39:43 +00:00
|
|
|
|
2016-09-10 11:45:01 +01:00
|
|
|
with lib;
|
2015-11-16 15:17:32 +00:00
|
|
|
|
2017-04-04 13:03:55 +01:00
|
|
|
rec {
|
|
|
|
dockerGen = {
|
|
|
|
version, rev, sha256
|
|
|
|
, runcRev, runcSha256
|
|
|
|
, containerdRev, containerdSha256
|
|
|
|
, tiniRev, tiniSha256
|
|
|
|
} : stdenv.mkDerivation rec {
|
|
|
|
inherit version rev;
|
2014-01-24 13:39:43 +00:00
|
|
|
|
2017-04-04 13:03:55 +01:00
|
|
|
name = "docker-${version}";
|
2014-01-24 13:39:43 +00:00
|
|
|
|
2017-01-17 14:49:32 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
2017-07-10 08:56:51 +01:00
|
|
|
repo = "docker-ce";
|
2017-04-04 13:03:55 +01:00
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = sha256;
|
2017-01-17 14:49:32 +00:00
|
|
|
};
|
|
|
|
|
2017-04-04 13:03:55 +01:00
|
|
|
docker-runc = runc.overrideAttrs (oldAttrs: rec {
|
|
|
|
name = "docker-runc";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
|
|
|
repo = "runc";
|
|
|
|
rev = runcRev;
|
|
|
|
sha256 = runcSha256;
|
|
|
|
};
|
|
|
|
# docker/runc already include these patches / are not applicable
|
|
|
|
patches = [];
|
|
|
|
});
|
|
|
|
docker-containerd = containerd.overrideAttrs (oldAttrs: rec {
|
|
|
|
name = "docker-containerd";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
|
|
|
repo = "containerd";
|
|
|
|
rev = containerdRev;
|
|
|
|
sha256 = containerdSha256;
|
|
|
|
};
|
2017-09-27 13:16:42 +01:00
|
|
|
|
|
|
|
# This should go into the containerd derivation once 1.0.0 is out
|
2017-09-28 06:09:54 +01:00
|
|
|
preBuild = (optionalString (version == "17.09.0-ce") ''
|
2017-09-27 13:16:42 +01:00
|
|
|
mkdir $(pwd)/vendor/src
|
|
|
|
mv $(pwd)/vendor/{github.com,golang.org,google.golang.org} $(pwd)/vendor/src/
|
2017-09-28 06:09:54 +01:00
|
|
|
'') + oldAttrs.preBuild;
|
2017-04-04 13:03:55 +01:00
|
|
|
});
|
|
|
|
docker-tini = tini.overrideAttrs (oldAttrs: rec {
|
|
|
|
name = "docker-init";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "krallin";
|
|
|
|
repo = "tini";
|
|
|
|
rev = tiniRev;
|
|
|
|
sha256 = tiniSha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Do not remove static from make files as we want a static binary
|
|
|
|
patchPhase = ''
|
|
|
|
'';
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = [
|
|
|
|
"-DMINIMAL=ON"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2017-07-22 19:27:44 +01:00
|
|
|
# Optimizations break compilation of libseccomp c bindings
|
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
2017-09-14 20:24:37 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2017-04-04 13:03:55 +01:00
|
|
|
buildInputs = [
|
2017-09-14 20:24:37 +01:00
|
|
|
makeWrapper removeReferencesTo go-md2man go
|
2017-07-22 19:27:44 +01:00
|
|
|
sqlite devicemapper btrfs-progs systemd libtool libseccomp
|
2017-04-04 13:03:55 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
DOCKER_BUILDTAGS = []
|
|
|
|
++ optional (systemd != null) [ "journald" ]
|
|
|
|
++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs"
|
2017-07-22 19:27:44 +01:00
|
|
|
++ optional (devicemapper == null) "exclude_graphdriver_devicemapper"
|
|
|
|
++ optional (libseccomp != null) "seccomp";
|
2017-04-04 13:03:55 +01:00
|
|
|
|
|
|
|
buildPhase = ''
|
2017-07-10 08:56:51 +01:00
|
|
|
# build engine
|
|
|
|
cd ./components/engine
|
2017-04-04 13:03:55 +01:00
|
|
|
export AUTO_GOPATH=1
|
|
|
|
export DOCKER_GITCOMMIT="${rev}"
|
|
|
|
./hack/make.sh dynbinary
|
2017-07-10 08:56:51 +01:00
|
|
|
cd -
|
|
|
|
|
|
|
|
# build cli
|
|
|
|
cd ./components/cli
|
|
|
|
# Mimic AUTO_GOPATH
|
|
|
|
mkdir -p .gopath/src/github.com/docker/
|
|
|
|
ln -sf $PWD .gopath/src/github.com/docker/cli
|
|
|
|
export GOPATH="$PWD/.gopath:$GOPATH"
|
|
|
|
export GITCOMMIT="${rev}"
|
|
|
|
export VERSION="${version}"
|
|
|
|
source ./scripts/build/.variables
|
|
|
|
export CGO_ENABLED=1
|
|
|
|
go build -tags pkcs11 --ldflags "$LDFLAGS" github.com/docker/cli/cmd/docker
|
|
|
|
cd -
|
2017-04-04 13:03:55 +01:00
|
|
|
'';
|
|
|
|
|
2017-07-10 08:56:51 +01:00
|
|
|
# systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd
|
|
|
|
patchPhase = ''
|
|
|
|
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" ""
|
|
|
|
'';
|
|
|
|
|
2017-04-04 13:03:55 +01:00
|
|
|
outputs = ["out" "man"];
|
|
|
|
|
|
|
|
extraPath = makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ];
|
|
|
|
|
|
|
|
installPhase = ''
|
2017-07-10 08:56:51 +01:00
|
|
|
install -Dm755 ./components/cli/docker $out/libexec/docker/docker
|
|
|
|
install -Dm755 ./components/engine/bundles/${version}/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd
|
2017-04-04 13:03:55 +01:00
|
|
|
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"
|
|
|
|
|
|
|
|
# docker uses containerd now
|
|
|
|
ln -s ${docker-containerd}/bin/containerd $out/libexec/docker/docker-containerd
|
|
|
|
ln -s ${docker-containerd}/bin/containerd-shim $out/libexec/docker/docker-containerd-shim
|
|
|
|
ln -s ${docker-runc}/bin/runc $out/libexec/docker/docker-runc
|
|
|
|
ln -s ${docker-proxy}/bin/docker-proxy $out/libexec/docker/docker-proxy
|
|
|
|
ln -s ${docker-tini}/bin/tini-static $out/libexec/docker/docker-init
|
|
|
|
|
|
|
|
# systemd
|
2017-07-10 08:56:51 +01:00
|
|
|
install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service
|
|
|
|
|
|
|
|
# completion (cli)
|
|
|
|
install -Dm644 ./components/cli/contrib/completion/bash/docker $out/share/bash-completion/completions/docker
|
|
|
|
install -Dm644 ./components/cli/contrib/completion/fish/docker.fish $out/share/fish/vendor_completions.d/docker.fish
|
|
|
|
install -Dm644 ./components/cli/contrib/completion/zsh/_docker $out/share/zsh/site-functions/_docker
|
2017-04-04 13:03:55 +01:00
|
|
|
|
2017-07-10 08:56:51 +01:00
|
|
|
# Include contributed man pages (cli)
|
|
|
|
# Generate man pages from cobra commands
|
|
|
|
echo "Generate man pages from cobra"
|
|
|
|
cd ./components/cli
|
|
|
|
mkdir -p ./man/man1
|
2017-07-21 08:54:41 +01:00
|
|
|
go build -o ./gen-manpages github.com/docker/cli/man
|
|
|
|
./gen-manpages --root . --target ./man/man1
|
2017-07-10 08:56:51 +01:00
|
|
|
|
|
|
|
# Generate legacy pages from markdown
|
|
|
|
echo "Generate legacy manpages"
|
|
|
|
./man/md2man-all.sh -q
|
2017-04-04 13:03:55 +01:00
|
|
|
|
|
|
|
manRoot="$man/share/man"
|
|
|
|
mkdir -p "$manRoot"
|
2017-07-10 08:56:51 +01:00
|
|
|
for manDir in ./man/man?; do
|
2017-04-04 13:03:55 +01:00
|
|
|
manBase="$(basename "$manDir")" # "man1"
|
|
|
|
for manFile in "$manDir"/*; do
|
|
|
|
manName="$(basename "$manFile")" # "docker-build.1"
|
|
|
|
mkdir -p "$manRoot/$manBase"
|
|
|
|
gzip -c "$manFile" > "$manRoot/$manBase/$manName.gz"
|
|
|
|
done
|
2016-09-10 11:45:01 +01:00
|
|
|
done
|
2017-04-04 13:03:55 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
|
|
|
find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} -t ${stdenv.glibc.dev} '{}' +
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2017-08-02 22:50:51 +01:00
|
|
|
homepage = https://www.docker.com/;
|
2017-04-04 13:03:55 +01:00
|
|
|
description = "An open source project to pack, ship and run any application as a lightweight container";
|
|
|
|
license = licenses.asl20;
|
2017-07-10 08:56:51 +01:00
|
|
|
maintainers = with maintainers; [ offline tailhook vdemeester ];
|
2017-04-04 13:03:55 +01:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-12 20:37:36 +01:00
|
|
|
# Get revisions from
|
|
|
|
# https://github.com/docker/docker-ce/blob/v${version}/components/engine/hack/dockerfile/binaries-commits
|
|
|
|
|
2017-07-10 08:56:51 +01:00
|
|
|
docker_17_06 = dockerGen rec {
|
2017-09-06 00:57:29 +01:00
|
|
|
version = "17.06.2-ce";
|
|
|
|
rev = "cec0b72a9940e047e945a09e1febd781e88366d6"; # git commit
|
|
|
|
sha256 = "1scqx28vzh72ziq00lbx92vsb896mj974j8f0zg11y6qc5n5jx3l";
|
|
|
|
runcRev = "810190ceaa507aa2727d7ae6f4790c76ec150bd2";
|
|
|
|
runcSha256 = "0f1x1z262qg579qb1w21axj3mibq4fbff3gamliw49sdqqnb7vk3";
|
|
|
|
containerdRev = "6e23458c129b551d5c9871e5174f6b1b7f6d1170";
|
|
|
|
containerdSha256 = "12kzc5z1nhxdbizzr494ywilbs6rdv39v5ql7lmfzwh350gwlg93";
|
2017-04-04 19:51:33 +01:00
|
|
|
tiniRev = "949e6facb77383876aeff8a6944dde66b3089574";
|
|
|
|
tiniSha256 = "0zj4kdis1vvc6dwn4gplqna0bs7v6d1y2zc8v80s3zi018inhznw";
|
|
|
|
};
|
2017-08-12 20:37:36 +01:00
|
|
|
|
2017-09-27 13:16:42 +01:00
|
|
|
docker_17_09 = dockerGen rec {
|
|
|
|
version = "17.09.0-ce";
|
|
|
|
rev = "afdb6d44a80f777069885a9ee0e0f86cf841b1bb"; # git commit
|
|
|
|
sha256 = "03g0imdcxqx9y4hhyymxqzvm8bqg4cqrmb7sjbxfdgrhzh9kcn1p";
|
|
|
|
runcRev = "3f2f8b84a77f73d38244dd690525642a72156c64";
|
|
|
|
runcSha256 = "0vaagmav8443kmyxac2y1y5l2ipcs1c7gdmsnvj48y9bafqx72rq";
|
|
|
|
containerdRev = "06b9cb35161009dcb7123345749fef02f7cea8e0";
|
|
|
|
containerdSha256 = "10hms8a2nn69nfnwly6923jzx40c3slpsdhjhff4bxh36flpf9gd";
|
2017-08-12 20:37:36 +01:00
|
|
|
tiniRev = "949e6facb77383876aeff8a6944dde66b3089574";
|
|
|
|
tiniSha256 = "0zj4kdis1vvc6dwn4gplqna0bs7v6d1y2zc8v80s3zi018inhznw";
|
|
|
|
};
|
2014-01-24 13:39:43 +00:00
|
|
|
}
|