2017-03-11 15:08:04 +01:00
|
|
|
{ stdenv, lib, fetchFromGitHub, makeWrapper, removeReferencesTo, pkgconfig
|
2017-07-10 09:56:51 +02:00
|
|
|
, go-md2man, go, containerd, runc, docker-proxy, tini, libtool
|
2016-09-10 12:45:01 +02:00
|
|
|
, sqlite, iproute, bridge-utils, devicemapper, systemd
|
|
|
|
, btrfs-progs, iptables, e2fsprogs, xz, utillinux, xfsprogs
|
2017-07-22 20:27:44 +02:00
|
|
|
, procps, libseccomp
|
2015-11-16 16:17:32 +01:00
|
|
|
}:
|
2014-01-24 14:39:43 +01:00
|
|
|
|
2016-09-10 12:45:01 +02:00
|
|
|
with lib;
|
2015-11-16 16:17:32 +01:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
rec {
|
|
|
|
dockerGen = {
|
|
|
|
version, rev, sha256
|
|
|
|
, runcRev, runcSha256
|
|
|
|
, containerdRev, containerdSha256
|
|
|
|
, tiniRev, tiniSha256
|
2017-11-16 12:48:28 +01:00
|
|
|
} :
|
|
|
|
let
|
2017-04-04 14:03:55 +02: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 = [];
|
|
|
|
});
|
2017-11-16 12:48:28 +01:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
docker-containerd = containerd.overrideAttrs (oldAttrs: rec {
|
|
|
|
name = "docker-containerd";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
|
|
|
repo = "containerd";
|
|
|
|
rev = containerdRev;
|
|
|
|
sha256 = containerdSha256;
|
|
|
|
};
|
2017-09-27 14:16:42 +02:00
|
|
|
|
2017-11-21 15:23:48 +01:00
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
|
|
|
buildInputs = [ removeReferencesTo go btrfs-progs ];
|
2017-04-04 14:03:55 +02:00
|
|
|
});
|
2017-11-16 12:48:28 +01:00
|
|
|
|
2017-04-04 14:03:55 +02: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-11-16 12:48:28 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec {
|
|
|
|
|
2017-11-20 20:16:08 +01:00
|
|
|
inherit docker-runc docker-containerd docker-proxy docker-tini;
|
2017-11-16 12:48:28 +01:00
|
|
|
|
|
|
|
DOCKER_BUILDTAGS = []
|
|
|
|
++ optional (systemd != null) [ "journald" ]
|
|
|
|
++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs"
|
|
|
|
++ optional (devicemapper == null) "exclude_graphdriver_devicemapper"
|
|
|
|
++ optional (libseccomp != null) "seccomp";
|
|
|
|
|
|
|
|
}) // rec {
|
|
|
|
inherit version rev;
|
|
|
|
|
|
|
|
name = "docker-${version}";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
|
|
|
repo = "docker-ce";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = sha256;
|
|
|
|
};
|
2017-04-04 14:03:55 +02:00
|
|
|
|
2017-07-22 20:27:44 +02:00
|
|
|
# Optimizations break compilation of libseccomp c bindings
|
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
2017-09-14 21:24:37 +02:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2017-04-04 14:03:55 +02:00
|
|
|
buildInputs = [
|
2017-11-16 12:48:28 +01:00
|
|
|
makeWrapper removeReferencesTo go-md2man go libtool
|
|
|
|
] ++ optionals (stdenv.isLinux) [
|
2017-11-21 15:23:48 +01:00
|
|
|
sqlite devicemapper btrfs-progs systemd libseccomp
|
2017-04-04 14:03:55 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
2017-11-16 12:48:28 +01:00
|
|
|
buildPhase = (optionalString (stdenv.isLinux) ''
|
2017-07-10 09:56:51 +02:00
|
|
|
# build engine
|
|
|
|
cd ./components/engine
|
2017-04-04 14:03:55 +02:00
|
|
|
export AUTO_GOPATH=1
|
|
|
|
export DOCKER_GITCOMMIT="${rev}"
|
2018-01-02 13:33:04 +01:00
|
|
|
export VERSION="${version}"
|
2017-04-04 14:03:55 +02:00
|
|
|
./hack/make.sh dynbinary
|
2017-07-10 09:56:51 +02:00
|
|
|
cd -
|
2017-11-16 12:48:28 +01:00
|
|
|
'') + ''
|
2017-07-10 09:56:51 +02:00
|
|
|
# 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 14:03:55 +02:00
|
|
|
'';
|
|
|
|
|
2017-07-10 09:56:51 +02:00
|
|
|
# systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd
|
|
|
|
patchPhase = ''
|
2017-11-16 12:48:28 +01:00
|
|
|
substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" ""
|
|
|
|
'' + optionalString (stdenv.isLinux) ''
|
2017-07-10 09:56:51 +02:00
|
|
|
patchShebangs .
|
|
|
|
substituteInPlace ./components/engine/hack/make.sh --replace libsystemd-journal libsystemd
|
|
|
|
substituteInPlace ./components/engine/daemon/logger/journald/read.go --replace libsystemd-journal libsystemd
|
2017-11-16 12:48:28 +01:00
|
|
|
'';
|
2017-07-10 09:56:51 +02:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
outputs = ["out" "man"];
|
|
|
|
|
2017-11-16 12:48:28 +01:00
|
|
|
extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]);
|
2017-10-17 23:22:25 +02:00
|
|
|
|
2017-11-16 12:48:28 +01:00
|
|
|
installPhase = optionalString (stdenv.isLinux) ''
|
2018-01-02 13:33:04 +01:00
|
|
|
install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd $out/libexec/docker/dockerd
|
2017-10-17 23:22:25 +02:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
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 09:56:51 +02:00
|
|
|
install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service
|
2017-11-16 12:48:28 +01:00
|
|
|
'' + ''
|
|
|
|
install -Dm755 ./components/cli/docker $out/libexec/docker/docker
|
|
|
|
|
|
|
|
makeWrapper $out/libexec/docker/docker $out/bin/docker \
|
|
|
|
--prefix PATH : "$out/libexec/docker:$extraPath"
|
2017-07-10 09:56:51 +02:00
|
|
|
|
|
|
|
# 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 14:03:55 +02:00
|
|
|
|
2017-07-10 09:56:51 +02: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 09:54:41 +02:00
|
|
|
go build -o ./gen-manpages github.com/docker/cli/man
|
|
|
|
./gen-manpages --root . --target ./man/man1
|
2017-07-10 09:56:51 +02:00
|
|
|
|
|
|
|
# Generate legacy pages from markdown
|
|
|
|
echo "Generate legacy manpages"
|
|
|
|
./man/md2man-all.sh -q
|
2017-04-04 14:03:55 +02:00
|
|
|
|
|
|
|
manRoot="$man/share/man"
|
|
|
|
mkdir -p "$manRoot"
|
2017-07-10 09:56:51 +02:00
|
|
|
for manDir in ./man/man?; do
|
2017-04-04 14:03:55 +02: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 12:45:01 +02:00
|
|
|
done
|
2017-04-04 14:03:55 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
2017-11-16 12:48:28 +01:00
|
|
|
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} '{}' +
|
2017-04-04 14:03:55 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2017-08-02 23:50:51 +02:00
|
|
|
homepage = https://www.docker.com/;
|
2017-04-04 14:03:55 +02:00
|
|
|
description = "An open source project to pack, ship and run any application as a lightweight container";
|
|
|
|
license = licenses.asl20;
|
2017-11-16 12:48:28 +01:00
|
|
|
maintainers = with maintainers; [ nequissimus offline tailhook vdemeester periklis ];
|
2017-11-20 20:30:46 +01:00
|
|
|
platforms = with platforms; linux ++ darwin;
|
2017-04-04 14:03:55 +02:00
|
|
|
};
|
2017-11-16 12:48:28 +01:00
|
|
|
});
|
2017-04-04 14:03:55 +02:00
|
|
|
|
2017-08-12 21:37:36 +02:00
|
|
|
# Get revisions from
|
2018-03-23 22:37:30 +01:00
|
|
|
# https://github.com/docker/docker-ce/tree/v${version}/components/engine/hack/dockerfile/install/*
|
|
|
|
|
|
|
|
docker_18_03 = dockerGen rec {
|
2018-04-26 14:02:21 +02:00
|
|
|
version = "18.03.1-ce";
|
|
|
|
rev = "9ee9f402cd1eba817c5591a64f1d770c87c421a4"; # git commit
|
|
|
|
sha256 = "1jm3jmcbkvvy3s8pi3xcpir6mwxjfbad46lbif4bnpjfd2r5irrx";
|
2018-03-23 22:37:30 +01:00
|
|
|
runcRev = "4fc53a81fb7c994640722ac585fa9ca548971871";
|
|
|
|
runcSha256 = "1ikqw39jn8dzb4snc4pcg3z85jb67ivskdhx028k17ss29bf4062";
|
2018-04-26 14:02:21 +02:00
|
|
|
containerdRev = "773c489c9c1b21a6d78b5c538cd395416ec50f88";
|
|
|
|
containerdSha256 = "0k1zjn0mpd7q3p5srxld2fr4k6ijzbk0r34r6w69sh0d0rd2fvbs";
|
2018-01-11 15:15:47 +01:00
|
|
|
tiniRev = "949e6facb77383876aeff8a6944dde66b3089574";
|
|
|
|
tiniSha256 = "0zj4kdis1vvc6dwn4gplqna0bs7v6d1y2zc8v80s3zi018inhznw";
|
|
|
|
};
|
2018-04-11 00:28:20 +02:00
|
|
|
|
2018-05-11 15:19:41 +02:00
|
|
|
docker_18_05 = dockerGen rec {
|
|
|
|
version = "18.05.0-ce";
|
|
|
|
rev = "f150324782643a5268a04e7d1a675587125da20e"; # git commit
|
|
|
|
sha256 = "0vgh03qwlfm25sm3yaa6vf5ap2ag575f814ccgcrp5zlcal13r0z";
|
2018-04-11 00:28:20 +02:00
|
|
|
runcRev = "4fc53a81fb7c994640722ac585fa9ca548971871";
|
|
|
|
runcSha256 = "1ikqw39jn8dzb4snc4pcg3z85jb67ivskdhx028k17ss29bf4062";
|
|
|
|
containerdRev = "773c489c9c1b21a6d78b5c538cd395416ec50f88";
|
|
|
|
containerdSha256 = "0k1zjn0mpd7q3p5srxld2fr4k6ijzbk0r34r6w69sh0d0rd2fvbs";
|
|
|
|
tiniRev = "949e6facb77383876aeff8a6944dde66b3089574";
|
|
|
|
tiniSha256 = "0zj4kdis1vvc6dwn4gplqna0bs7v6d1y2zc8v80s3zi018inhznw";
|
|
|
|
};
|
2014-01-24 14:39:43 +01:00
|
|
|
}
|