2021-03-04 13:37:12 +00:00
|
|
|
{ lib, callPackage, fetchFromGitHub }:
|
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
|
2021-03-04 13:37:12 +00:00
|
|
|
, moby-src
|
2017-04-04 13:03:55 +01:00
|
|
|
, runcRev, runcSha256
|
|
|
|
, containerdRev, containerdSha256
|
2021-10-16 17:19:32 +01:00
|
|
|
, tiniRev, tiniSha256, buildxSupport ? true, composeSupport ? true
|
2021-01-26 12:01:50 +00:00
|
|
|
# package dependencies
|
2021-05-18 12:43:05 +01:00
|
|
|
, stdenv, fetchFromGitHub, buildGoPackage
|
2021-06-11 05:19:10 +01:00
|
|
|
, makeWrapper, installShellFiles, pkg-config, glibc
|
2021-08-10 10:37:20 +01:00
|
|
|
, go-md2man, go, containerd_1_4, runc, docker-proxy, tini, libtool
|
2021-10-16 17:19:32 +01:00
|
|
|
, sqlite, iproute2, lvm2, systemd, docker-buildx, docker-compose_2
|
2021-01-26 12:01:50 +00:00
|
|
|
, btrfs-progs, iptables, e2fsprogs, xz, util-linux, xfsprogs, git
|
2021-12-14 22:07:47 +00:00
|
|
|
, procps, libseccomp, rootlesskit, slirp4netns, fuse-overlayfs
|
2021-01-26 12:01:50 +00:00
|
|
|
, nixosTests
|
2021-10-16 17:19:32 +01:00
|
|
|
, clientOnly ? !stdenv.isLinux, symlinkJoin
|
2021-01-26 12:01:50 +00:00
|
|
|
}:
|
2017-11-16 11:48:28 +00:00
|
|
|
let
|
2019-08-13 22:52:01 +01:00
|
|
|
docker-runc = runc.overrideAttrs (oldAttrs: {
|
2018-11-04 23:35:13 +00:00
|
|
|
name = "docker-runc-${version}";
|
|
|
|
inherit version;
|
2017-04-04 13:03:55 +01:00
|
|
|
src = fetchFromGitHub {
|
2019-10-19 14:39:09 +01:00
|
|
|
owner = "opencontainers";
|
2017-04-04 13:03:55 +01:00
|
|
|
repo = "runc";
|
|
|
|
rev = runcRev;
|
|
|
|
sha256 = runcSha256;
|
|
|
|
};
|
|
|
|
# docker/runc already include these patches / are not applicable
|
|
|
|
patches = [];
|
|
|
|
});
|
2017-11-16 11:48:28 +00:00
|
|
|
|
2021-08-10 10:37:20 +01:00
|
|
|
docker-containerd = containerd_1_4.overrideAttrs (oldAttrs: {
|
2018-11-04 23:35:13 +00:00
|
|
|
name = "docker-containerd-${version}";
|
|
|
|
inherit version;
|
2017-04-04 13:03:55 +01:00
|
|
|
src = fetchFromGitHub {
|
2020-10-23 11:51:16 +01:00
|
|
|
owner = "containerd";
|
2017-04-04 13:03:55 +01:00
|
|
|
repo = "containerd";
|
|
|
|
rev = containerdRev;
|
|
|
|
sha256 = containerdSha256;
|
|
|
|
};
|
2021-01-13 10:33:14 +00:00
|
|
|
buildInputs = oldAttrs.buildInputs ++ [ libseccomp ];
|
2017-04-04 13:03:55 +01:00
|
|
|
});
|
2017-11-16 11:48:28 +00:00
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
docker-tini = tini.overrideAttrs (oldAttrs: {
|
2018-11-04 23:35:13 +00:00
|
|
|
name = "docker-init-${version}";
|
|
|
|
inherit version;
|
2017-04-04 13:03:55 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "krallin";
|
|
|
|
repo = "tini";
|
|
|
|
rev = tiniRev;
|
|
|
|
sha256 = tiniSha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Do not remove static from make files as we want a static binary
|
2021-06-11 05:19:10 +01:00
|
|
|
postPatch = "";
|
|
|
|
|
|
|
|
buildInputs = [ glibc glibc.static ];
|
2017-04-04 13:03:55 +01:00
|
|
|
|
2019-10-30 01:29:30 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-DMINIMAL=ON";
|
2017-04-04 13:03:55 +01:00
|
|
|
});
|
2021-01-13 10:33:14 +00:00
|
|
|
|
|
|
|
moby = buildGoPackage ((optionalAttrs (stdenv.isLinux)) rec {
|
|
|
|
name = "moby-${version}";
|
|
|
|
inherit version;
|
|
|
|
inherit docker-runc docker-containerd docker-proxy docker-tini;
|
|
|
|
|
2021-03-04 13:37:12 +00:00
|
|
|
src = moby-src;
|
2021-01-13 10:33:14 +00:00
|
|
|
|
|
|
|
goPackagePath = "github.com/docker/docker";
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper pkg-config go-md2man go libtool installShellFiles ];
|
|
|
|
buildInputs = [ sqlite lvm2 btrfs-progs systemd libseccomp ];
|
|
|
|
|
2021-03-14 16:05:16 +00:00
|
|
|
extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute2 iptables e2fsprogs xz xfsprogs procps util-linux git ]);
|
2021-01-13 10:33:14 +00:00
|
|
|
|
2021-12-16 23:40:41 +00:00
|
|
|
extraUserPath = optionals (stdenv.isLinux && !clientOnly) (makeBinPath [ rootlesskit slirp4netns fuse-overlayfs ]);
|
2021-12-14 22:07:47 +00:00
|
|
|
|
2021-06-06 12:32:42 +01:00
|
|
|
postPatch = ''
|
2021-06-15 11:12:02 +01:00
|
|
|
patchShebangs hack/make.sh hack/make/
|
2021-06-06 12:32:42 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-13 10:33:14 +00:00
|
|
|
buildPhase = ''
|
|
|
|
export GOCACHE="$TMPDIR/go-cache"
|
|
|
|
# build engine
|
|
|
|
cd ./go/src/${goPackagePath}
|
|
|
|
export AUTO_GOPATH=1
|
|
|
|
export DOCKER_GITCOMMIT="${rev}"
|
|
|
|
export VERSION="${version}"
|
|
|
|
./hack/make.sh dynbinary
|
|
|
|
cd -
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cd ./go/src/${goPackagePath}
|
|
|
|
install -Dm755 ./bundles/dynbinary-daemon/dockerd $out/libexec/docker/dockerd
|
|
|
|
|
|
|
|
makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \
|
|
|
|
--prefix PATH : "$out/libexec/docker:$extraPath"
|
|
|
|
|
|
|
|
ln -s ${docker-containerd}/bin/containerd $out/libexec/docker/containerd
|
|
|
|
ln -s ${docker-containerd}/bin/containerd-shim $out/libexec/docker/containerd-shim
|
|
|
|
ln -s ${docker-runc}/bin/runc $out/libexec/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
|
|
|
|
install -Dm644 ./contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service
|
2021-04-26 01:43:09 +01:00
|
|
|
substituteInPlace $out/etc/systemd/system/docker.service --replace /usr/bin/dockerd $out/bin/dockerd
|
|
|
|
install -Dm644 ./contrib/init/systemd/docker.socket $out/etc/systemd/system/docker.socket
|
2021-12-14 22:07:47 +00:00
|
|
|
|
|
|
|
# rootless Docker
|
|
|
|
install -Dm755 ./contrib/dockerd-rootless.sh $out/libexec/docker/dockerd-rootless.sh
|
|
|
|
makeWrapper $out/libexec/docker/dockerd-rootless.sh $out/bin/dockerd-rootless \
|
|
|
|
--prefix PATH : "$out/libexec/docker:$extraPath:$extraUserPath"
|
2021-01-13 10:33:14 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
DOCKER_BUILDTAGS = []
|
|
|
|
++ optional (systemd != null) [ "journald" ]
|
|
|
|
++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs"
|
|
|
|
++ optional (lvm2 == null) "exclude_graphdriver_devicemapper"
|
|
|
|
++ optional (libseccomp != null) "seccomp";
|
|
|
|
});
|
2021-10-16 17:19:32 +01:00
|
|
|
|
|
|
|
plugins = optionals buildxSupport [ docker-buildx ]
|
|
|
|
++ optionals composeSupport [ docker-compose_2 ];
|
|
|
|
pluginsRef = symlinkJoin { name = "docker-plugins"; paths = plugins; };
|
2017-11-16 11:48:28 +00:00
|
|
|
in
|
2021-05-27 00:59:49 +01:00
|
|
|
buildGoPackage ((optionalAttrs (!clientOnly) {
|
2017-11-16 11:48:28 +00:00
|
|
|
|
2021-01-13 10:33:14 +00:00
|
|
|
inherit docker-runc docker-containerd docker-proxy docker-tini moby;
|
2017-11-16 11:48:28 +00:00
|
|
|
|
2020-07-03 08:19:24 +01:00
|
|
|
}) // rec {
|
2017-11-16 11:48:28 +00:00
|
|
|
inherit version rev;
|
|
|
|
|
2021-05-18 12:43:05 +01:00
|
|
|
pname = "docker";
|
2017-11-16 11:48:28 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
2021-01-13 10:33:14 +00:00
|
|
|
repo = "cli";
|
2017-11-16 11:48:28 +00:00
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = sha256;
|
|
|
|
};
|
2017-04-04 13:03:55 +01:00
|
|
|
|
2021-01-13 10:33:14 +00:00
|
|
|
goPackagePath = "github.com/docker/cli";
|
2020-07-03 08:19:24 +01:00
|
|
|
|
2021-04-12 18:06:02 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper pkg-config go-md2man go libtool installShellFiles
|
|
|
|
];
|
2021-05-27 00:59:49 +01:00
|
|
|
buildInputs = optionals (!clientOnly) [
|
2018-07-17 21:11:16 +01:00
|
|
|
sqlite lvm2 btrfs-progs systemd libseccomp
|
2021-10-16 17:19:32 +01:00
|
|
|
] ++ plugins;
|
2017-04-04 13:03:55 +01:00
|
|
|
|
2021-06-06 12:32:42 +01:00
|
|
|
postPatch = ''
|
2021-06-15 11:12:02 +01:00
|
|
|
patchShebangs man scripts/build/
|
2021-06-06 12:32:42 +01:00
|
|
|
substituteInPlace ./scripts/build/.variables --replace "set -eu" ""
|
2021-10-16 17:19:32 +01:00
|
|
|
'' + optionalString (plugins != []) ''
|
2021-06-06 12:32:42 +01:00
|
|
|
substituteInPlace ./cli-plugins/manager/manager_unix.go --replace /usr/libexec/docker/cli-plugins \
|
2021-10-16 17:19:32 +01:00
|
|
|
"${pluginsRef}/libexec/docker/cli-plugins"
|
2021-06-06 12:32:42 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-13 10:33:14 +00:00
|
|
|
# Keep eyes on BUILDTIME format - https://github.com/docker/cli/blob/${version}/scripts/build/.variables
|
2019-03-10 20:54:19 +00:00
|
|
|
buildPhase = ''
|
|
|
|
export GOCACHE="$TMPDIR/go-cache"
|
2021-01-13 10:33:14 +00:00
|
|
|
|
|
|
|
cd ./go/src/${goPackagePath}
|
2017-07-10 08:56:51 +01:00
|
|
|
# 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}"
|
2021-01-13 10:33:14 +00:00
|
|
|
export BUILDTIME="1970-01-01T00:00:00Z"
|
2017-07-10 08:56:51 +01:00
|
|
|
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
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = ["out" "man"];
|
|
|
|
|
2020-08-28 01:00:00 +01:00
|
|
|
installPhase = ''
|
2020-07-03 08:19:24 +01:00
|
|
|
cd ./go/src/${goPackagePath}
|
2021-01-13 10:33:14 +00:00
|
|
|
install -Dm755 ./docker $out/libexec/docker/docker
|
2020-08-28 01:00:00 +01:00
|
|
|
|
|
|
|
makeWrapper $out/libexec/docker/docker $out/bin/docker \
|
|
|
|
--prefix PATH : "$out/libexec/docker:$extraPath"
|
2021-05-27 00:59:49 +01:00
|
|
|
'' + optionalString (!clientOnly) ''
|
2021-01-13 10:33:14 +00:00
|
|
|
# symlink docker daemon to docker cli derivation
|
|
|
|
ln -s ${moby}/bin/dockerd $out/bin/dockerd
|
2021-12-14 22:07:47 +00:00
|
|
|
ln -s ${moby}/bin/dockerd-rootless $out/bin/dockerd-rootless
|
2021-04-26 01:43:09 +01:00
|
|
|
|
|
|
|
# systemd
|
|
|
|
mkdir -p $out/etc/systemd/system
|
|
|
|
ln -s ${moby}/etc/systemd/system/docker.service $out/etc/systemd/system/docker.service
|
|
|
|
ln -s ${moby}/etc/systemd/system/docker.socket $out/etc/systemd/system/docker.socket
|
2017-11-16 11:48:28 +00:00
|
|
|
'' + ''
|
2017-07-10 08:56:51 +01:00
|
|
|
# completion (cli)
|
2021-01-13 10:33:14 +00:00
|
|
|
installShellCompletion --bash ./contrib/completion/bash/docker
|
|
|
|
installShellCompletion --fish ./contrib/completion/fish/docker.fish
|
|
|
|
installShellCompletion --zsh ./contrib/completion/zsh/_docker
|
2020-07-03 08:19:24 +01:00
|
|
|
'' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
|
2017-07-10 08:56:51 +01:00
|
|
|
# Generate man pages from cobra commands
|
|
|
|
echo "Generate man pages from cobra"
|
|
|
|
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
|
2020-07-03 08:19:24 +01:00
|
|
|
'' + ''
|
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
|
|
|
|
2020-05-10 02:24:03 +01:00
|
|
|
installManPage man/*/*.[1-9]
|
2017-04-04 13:03:55 +01:00
|
|
|
'';
|
|
|
|
|
2021-05-27 00:59:49 +01:00
|
|
|
passthru.tests = lib.optionals (!clientOnly) { inherit (nixosTests) docker; };
|
2020-11-22 00:59:08 +00:00
|
|
|
|
2017-04-04 13:03:55 +01:00
|
|
|
meta = {
|
2020-04-01 02:11: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;
|
2021-08-10 10:37:20 +01:00
|
|
|
maintainers = with maintainers; [ offline tailhook vdemeester periklis mikroskeem maxeaubrey ];
|
2017-11-20 19:30:46 +00:00
|
|
|
platforms = with platforms; linux ++ darwin;
|
2017-04-04 13:03:55 +01:00
|
|
|
};
|
2021-03-04 13:37:12 +00:00
|
|
|
|
|
|
|
# Exposed for tarsum build on non-linux systems (build-support/docker/default.nix)
|
|
|
|
inherit moby-src;
|
2017-11-16 11:48:28 +00:00
|
|
|
});
|
2017-04-04 13:03:55 +01:00
|
|
|
|
2017-08-12 20:37:36 +01:00
|
|
|
# Get revisions from
|
2021-01-13 10:33:14 +00:00
|
|
|
# https://github.com/moby/moby/tree/${version}/hack/dockerfile/install/*
|
2021-01-26 12:01:50 +00:00
|
|
|
docker_20_10 = callPackage dockerGen rec {
|
2022-01-06 14:26:57 +00:00
|
|
|
version = "20.10.12";
|
2020-06-26 22:45:19 +01:00
|
|
|
rev = "v${version}";
|
2022-01-06 14:26:57 +00:00
|
|
|
sha256 = "sha256-nU6grb2lSW7BY7w9aAXwVbGp9TyO2ZxnJaxAi0wbk/c=";
|
2021-03-04 13:37:12 +00:00
|
|
|
moby-src = fetchFromGitHub {
|
|
|
|
owner = "moby";
|
|
|
|
repo = "moby";
|
|
|
|
rev = "v${version}";
|
2022-01-06 14:26:57 +00:00
|
|
|
sha256 = "sha256-qizzK1qJNRGFisahE3iAzZTNW/HmledlMNxcJCMQSJ4=";
|
2021-03-04 13:37:12 +00:00
|
|
|
};
|
2022-01-06 14:26:57 +00:00
|
|
|
runcRev = "v1.0.2";
|
2021-10-04 20:48:42 +01:00
|
|
|
runcSha256 = "1bpckghjah0rczciw1a1ab8z718lb2d3k4mjm4zb45lpm3njmrcp";
|
2022-01-06 14:26:57 +00:00
|
|
|
containerdRev = "v1.4.12";
|
|
|
|
containerdSha256 = "sha256-g30kshXyGVew5tVaXFAOQUOYvvo0JBqIj1YaC5nTiS8=";
|
2021-08-04 23:25:01 +01:00
|
|
|
tiniRev = "v0.19.0"; # v0.19.0
|
2019-07-26 17:42:55 +01:00
|
|
|
tiniSha256 = "1h20i3wwlbd8x4jr2gz68hgklh0lb0jj7y5xk1wvr8y58fip1rdn";
|
|
|
|
};
|
2014-01-24 13:39:43 +00:00
|
|
|
}
|