2021-03-04 14:37:12 +01:00
|
|
|
{ lib, callPackage, fetchFromGitHub }:
|
2014-01-24 14:39:43 +01:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
rec {
|
|
|
|
dockerGen = {
|
|
|
|
version, rev, sha256
|
2021-03-04 14:37:12 +01:00
|
|
|
, moby-src
|
2017-04-04 14:03:55 +02:00
|
|
|
, runcRev, runcSha256
|
|
|
|
, containerdRev, containerdSha256
|
2021-10-16 18:19:32 +02:00
|
|
|
, tiniRev, tiniSha256, buildxSupport ? true, composeSupport ? true
|
2021-01-26 13:01:50 +01:00
|
|
|
# package dependencies
|
2022-03-09 17:26:50 +01:00
|
|
|
, stdenv, fetchFromGitHub, fetchpatch, buildGoPackage
|
2021-06-11 06:19:10 +02:00
|
|
|
, makeWrapper, installShellFiles, pkg-config, glibc
|
2022-03-18 16:27:48 +01:00
|
|
|
, go-md2man, go, containerd, runc, docker-proxy, tini, libtool
|
2022-11-22 23:12:07 +01:00
|
|
|
, sqlite, iproute2, docker-buildx, docker-compose
|
|
|
|
, iptables, e2fsprogs, xz, util-linux, xfsprogs, git
|
|
|
|
, procps, rootlesskit, slirp4netns, fuse-overlayfs, nixosTests
|
2021-10-16 18:19:32 +02:00
|
|
|
, clientOnly ? !stdenv.isLinux, symlinkJoin
|
2022-11-29 00:52:46 +01:00
|
|
|
, withSystemd ? stdenv.isLinux, systemd
|
|
|
|
, withBtrfs ? stdenv.isLinux, btrfs-progs
|
|
|
|
, withLvm ? stdenv.isLinux, lvm2
|
|
|
|
, withSeccomp ? stdenv.isLinux, libseccomp
|
2021-01-26 13:01:50 +01:00
|
|
|
}:
|
2017-11-16 12:48:28 +01:00
|
|
|
let
|
2019-08-13 23:52:01 +02:00
|
|
|
docker-runc = runc.overrideAttrs (oldAttrs: {
|
2022-08-26 15:27:07 +02:00
|
|
|
pname = "docker-runc";
|
2018-11-05 00:35:13 +01:00
|
|
|
inherit version;
|
2022-08-26 15:27:07 +02:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
src = fetchFromGitHub {
|
2019-10-19 15:39:09 +02:00
|
|
|
owner = "opencontainers";
|
2017-04-04 14:03:55 +02:00
|
|
|
repo = "runc";
|
|
|
|
rev = runcRev;
|
|
|
|
sha256 = runcSha256;
|
|
|
|
};
|
2022-08-26 15:27:07 +02:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
# docker/runc already include these patches / are not applicable
|
|
|
|
patches = [];
|
|
|
|
});
|
2017-11-16 12:48:28 +01:00
|
|
|
|
2022-03-18 16:27:48 +01:00
|
|
|
docker-containerd = containerd.overrideAttrs (oldAttrs: {
|
2022-08-26 15:27:07 +02:00
|
|
|
pname = "docker-containerd";
|
2018-11-05 00:35:13 +01:00
|
|
|
inherit version;
|
2022-08-26 15:27:07 +02:00
|
|
|
|
2017-04-04 14:03:55 +02:00
|
|
|
src = fetchFromGitHub {
|
2020-10-23 12:51:16 +02:00
|
|
|
owner = "containerd";
|
2017-04-04 14:03:55 +02:00
|
|
|
repo = "containerd";
|
|
|
|
rev = containerdRev;
|
|
|
|
sha256 = containerdSha256;
|
|
|
|
};
|
2022-08-26 15:27:07 +02:00
|
|
|
|
2022-11-22 23:12:07 +01:00
|
|
|
buildInputs = oldAttrs.buildInputs
|
2022-12-08 23:26:13 +01:00
|
|
|
++ lib.optionals withSeccomp [ libseccomp ];
|
2017-04-04 14:03:55 +02:00
|
|
|
});
|
2017-11-16 12:48:28 +01:00
|
|
|
|
2022-08-26 15:27:07 +02:00
|
|
|
docker-tini = tini.overrideAttrs (oldAttrs: {
|
|
|
|
pname = "docker-init";
|
2018-11-05 00:35:13 +01:00
|
|
|
inherit version;
|
2022-08-26 15:27:07 +02:00
|
|
|
|
2017-04-04 14:03:55 +02: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 06:19:10 +02:00
|
|
|
postPatch = "";
|
|
|
|
|
|
|
|
buildInputs = [ glibc glibc.static ];
|
2017-04-04 14:03:55 +02:00
|
|
|
|
2019-10-30 02:29:30 +01:00
|
|
|
NIX_CFLAGS_COMPILE = "-DMINIMAL=ON";
|
2017-04-04 14:03:55 +02:00
|
|
|
});
|
2021-01-13 11:33:14 +01:00
|
|
|
|
2022-11-22 23:12:55 +01:00
|
|
|
moby = buildGoPackage (lib.optionalAttrs stdenv.isLinux rec {
|
2022-08-26 15:27:07 +02:00
|
|
|
pname = "moby";
|
2021-01-13 11:33:14 +01:00
|
|
|
inherit version;
|
|
|
|
|
2021-03-04 14:37:12 +01:00
|
|
|
src = moby-src;
|
2021-01-13 11:33:14 +01:00
|
|
|
|
|
|
|
goPackagePath = "github.com/docker/docker";
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper pkg-config go-md2man go libtool installShellFiles ];
|
2022-11-22 23:12:07 +01:00
|
|
|
buildInputs = [ sqlite ]
|
|
|
|
++ lib.optional withLvm lvm2
|
|
|
|
++ lib.optional withBtrfs btrfs-progs
|
|
|
|
++ lib.optional withSystemd systemd
|
|
|
|
++ lib.optional withSeccomp libseccomp;
|
2021-01-13 11:33:14 +01:00
|
|
|
|
2022-11-22 23:12:55 +01:00
|
|
|
extraPath = lib.optionals stdenv.isLinux (lib.makeBinPath [ iproute2 iptables e2fsprogs xz xfsprogs procps util-linux git ]);
|
2021-01-13 11:33:14 +01:00
|
|
|
|
2022-11-22 23:12:55 +01:00
|
|
|
extraUserPath = lib.optionals (stdenv.isLinux && !clientOnly) (lib.makeBinPath [ rootlesskit slirp4netns fuse-overlayfs ]);
|
2021-12-14 23:07:47 +01:00
|
|
|
|
2022-03-09 17:26:50 +01:00
|
|
|
patches = [
|
|
|
|
# This patch incorporates code from a PR fixing using buildkit with the ZFS graph driver.
|
|
|
|
# It could be removed when a version incorporating this patch is released.
|
|
|
|
(fetchpatch {
|
|
|
|
name = "buildkit-zfs.patch";
|
|
|
|
url = "https://github.com/moby/moby/pull/43136.patch";
|
|
|
|
sha256 = "1WZfpVnnqFwLMYqaHLploOodls0gHF8OCp7MrM26iX8=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-06-06 13:32:42 +02:00
|
|
|
postPatch = ''
|
2021-06-15 12:12:02 +02:00
|
|
|
patchShebangs hack/make.sh hack/make/
|
2021-06-06 13:32:42 +02:00
|
|
|
'';
|
|
|
|
|
2021-01-13 11:33:14 +01: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 02:43:09 +02: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 23:07:47 +01: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 11:33:14 +01:00
|
|
|
'';
|
|
|
|
|
2022-11-22 23:12:07 +01:00
|
|
|
DOCKER_BUILDTAGS = lib.optional withSystemd "journald"
|
2022-12-04 06:52:35 +01:00
|
|
|
++ lib.optional (!withBtrfs) "exclude_graphdriver_btrfs"
|
|
|
|
++ lib.optional (!withLvm) "exclude_graphdriver_devicemapper"
|
2022-11-22 23:12:07 +01:00
|
|
|
++ lib.optional withSeccomp "seccomp";
|
2021-01-13 11:33:14 +01:00
|
|
|
});
|
2021-10-16 18:19:32 +02:00
|
|
|
|
2022-11-22 23:12:07 +01:00
|
|
|
plugins = lib.optional buildxSupport docker-buildx
|
|
|
|
++ lib.optional composeSupport docker-compose;
|
2021-10-16 18:19:32 +02:00
|
|
|
pluginsRef = symlinkJoin { name = "docker-plugins"; paths = plugins; };
|
2017-11-16 12:48:28 +01:00
|
|
|
in
|
2022-11-22 23:12:55 +01:00
|
|
|
buildGoPackage (lib.optionalAttrs (!clientOnly) {
|
2022-11-22 23:12:07 +01:00
|
|
|
# allow overrides of docker components
|
|
|
|
# TODO: move packages out of the let...in into top-level to allow proper overrides
|
|
|
|
inherit docker-runc docker-containerd docker-proxy docker-tini moby;
|
|
|
|
} // rec {
|
2021-05-18 13:43:05 +02:00
|
|
|
pname = "docker";
|
2022-08-26 15:27:07 +02:00
|
|
|
inherit version;
|
2017-11-16 12:48:28 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "docker";
|
2021-01-13 11:33:14 +01:00
|
|
|
repo = "cli";
|
2017-11-16 12:48:28 +01:00
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = sha256;
|
|
|
|
};
|
2017-04-04 14:03:55 +02:00
|
|
|
|
2021-01-13 11:33:14 +01:00
|
|
|
goPackagePath = "github.com/docker/cli";
|
2020-07-03 09:19:24 +02:00
|
|
|
|
2021-04-12 19:06:02 +02:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper pkg-config go-md2man go libtool installShellFiles
|
|
|
|
];
|
2022-11-22 23:12:07 +01:00
|
|
|
buildInputs = lib.optional (!clientOnly) sqlite
|
|
|
|
++ lib.optional withLvm lvm2
|
|
|
|
++ lib.optional withBtrfs btrfs-progs
|
|
|
|
++ lib.optional withSystemd systemd
|
|
|
|
++ lib.optional withSeccomp libseccomp
|
|
|
|
++ plugins;
|
2017-04-04 14:03:55 +02:00
|
|
|
|
2021-06-06 13:32:42 +02:00
|
|
|
postPatch = ''
|
2021-06-15 12:12:02 +02:00
|
|
|
patchShebangs man scripts/build/
|
2021-06-06 13:32:42 +02:00
|
|
|
substituteInPlace ./scripts/build/.variables --replace "set -eu" ""
|
2022-11-22 23:12:55 +01:00
|
|
|
'' + lib.optionalString (plugins != []) ''
|
2021-06-06 13:32:42 +02:00
|
|
|
substituteInPlace ./cli-plugins/manager/manager_unix.go --replace /usr/libexec/docker/cli-plugins \
|
2021-10-16 18:19:32 +02:00
|
|
|
"${pluginsRef}/libexec/docker/cli-plugins"
|
2021-06-06 13:32:42 +02:00
|
|
|
'';
|
|
|
|
|
2021-01-13 11:33:14 +01:00
|
|
|
# Keep eyes on BUILDTIME format - https://github.com/docker/cli/blob/${version}/scripts/build/.variables
|
2019-03-10 21:54:19 +01:00
|
|
|
buildPhase = ''
|
|
|
|
export GOCACHE="$TMPDIR/go-cache"
|
2021-01-13 11:33:14 +01:00
|
|
|
|
|
|
|
cd ./go/src/${goPackagePath}
|
2017-07-10 09:56:51 +02: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 11:33:14 +01:00
|
|
|
export BUILDTIME="1970-01-01T00:00:00Z"
|
2017-07-10 09:56:51 +02:00
|
|
|
source ./scripts/build/.variables
|
|
|
|
export CGO_ENABLED=1
|
2022-05-06 00:40:15 +02:00
|
|
|
go build -tags pkcs11 --ldflags "$GO_LDFLAGS" github.com/docker/cli/cmd/docker
|
2017-07-10 09:56:51 +02:00
|
|
|
cd -
|
2017-04-04 14:03:55 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = ["out" "man"];
|
|
|
|
|
2020-08-28 02:00:00 +02:00
|
|
|
installPhase = ''
|
2020-07-03 09:19:24 +02:00
|
|
|
cd ./go/src/${goPackagePath}
|
2021-01-13 11:33:14 +01:00
|
|
|
install -Dm755 ./docker $out/libexec/docker/docker
|
2020-08-28 02:00:00 +02:00
|
|
|
|
|
|
|
makeWrapper $out/libexec/docker/docker $out/bin/docker \
|
|
|
|
--prefix PATH : "$out/libexec/docker:$extraPath"
|
2022-11-22 23:12:55 +01:00
|
|
|
'' + lib.optionalString (!clientOnly) ''
|
2021-01-13 11:33:14 +01:00
|
|
|
# symlink docker daemon to docker cli derivation
|
|
|
|
ln -s ${moby}/bin/dockerd $out/bin/dockerd
|
2021-12-14 23:07:47 +01:00
|
|
|
ln -s ${moby}/bin/dockerd-rootless $out/bin/dockerd-rootless
|
2021-04-26 02:43:09 +02: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 12:48:28 +01:00
|
|
|
'' + ''
|
2017-07-10 09:56:51 +02:00
|
|
|
# completion (cli)
|
2021-01-13 11:33:14 +01:00
|
|
|
installShellCompletion --bash ./contrib/completion/bash/docker
|
|
|
|
installShellCompletion --fish ./contrib/completion/fish/docker.fish
|
|
|
|
installShellCompletion --zsh ./contrib/completion/zsh/_docker
|
2020-07-03 09:19:24 +02:00
|
|
|
'' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
|
2017-07-10 09:56:51 +02:00
|
|
|
# Generate man pages from cobra commands
|
|
|
|
echo "Generate man pages from cobra"
|
|
|
|
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
|
2020-07-03 09:19:24 +02:00
|
|
|
'' + ''
|
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
|
|
|
|
2020-05-10 03:24:03 +02:00
|
|
|
installManPage man/*/*.[1-9]
|
2017-04-04 14:03:55 +02:00
|
|
|
'';
|
|
|
|
|
2022-11-22 23:13:06 +01:00
|
|
|
passthru = {
|
|
|
|
# Exposed for tarsum build on non-linux systems (build-support/docker/default.nix)
|
|
|
|
inherit moby-src;
|
|
|
|
tests = lib.optionals (!clientOnly) { inherit (nixosTests) docker; };
|
|
|
|
};
|
2020-11-22 01:59:08 +01:00
|
|
|
|
2022-11-22 23:12:55 +01:00
|
|
|
meta = with lib; {
|
2020-04-01 03:11: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;
|
2021-08-10 11:37:20 +02:00
|
|
|
maintainers = with maintainers; [ offline tailhook vdemeester periklis mikroskeem maxeaubrey ];
|
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
|
2021-01-13 11:33:14 +01:00
|
|
|
# https://github.com/moby/moby/tree/${version}/hack/dockerfile/install/*
|
2021-01-26 13:01:50 +01:00
|
|
|
docker_20_10 = callPackage dockerGen rec {
|
2022-10-26 17:39:37 +02:00
|
|
|
version = "20.10.21";
|
2020-06-26 23:45:19 +02:00
|
|
|
rev = "v${version}";
|
2022-10-26 17:39:37 +02:00
|
|
|
sha256 = "sha256-hPQ1t7L2fqoFWoinqIrDwFQ1bo9TzMb4l3HmAotIUS8=";
|
2021-03-04 14:37:12 +01:00
|
|
|
moby-src = fetchFromGitHub {
|
|
|
|
owner = "moby";
|
|
|
|
repo = "moby";
|
|
|
|
rev = "v${version}";
|
2022-10-26 17:39:37 +02:00
|
|
|
sha256 = "sha256-BcYDh/UEmmURt7hWLWdPTKVu/Nzoeq/shE+HnUoh8b4=";
|
2021-03-04 14:37:12 +01:00
|
|
|
};
|
2022-09-09 14:20:48 +02:00
|
|
|
runcRev = "v1.1.4";
|
|
|
|
runcSha256 = "sha256-ougJHW1Z+qZ324P8WpZqawY1QofKnn8WezP7orzRTdA=";
|
2022-10-26 17:39:37 +02:00
|
|
|
containerdRev = "v1.6.9";
|
|
|
|
containerdSha256 = "sha256-KvQdYQLzgt/MKPsA/mO5un6nE3/xcvVYwIveNn/uDnU=";
|
2022-03-18 16:27:48 +01:00
|
|
|
tiniRev = "v0.19.0";
|
|
|
|
tiniSha256 = "sha256-ZDKu/8yE5G0RYFJdhgmCdN3obJNyRWv6K/Gd17zc1sI=";
|
2019-07-26 18:42:55 +02:00
|
|
|
};
|
2014-01-24 14:39:43 +01:00
|
|
|
}
|