diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/virtualization/docker')
6 files changed, 378 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/virtualization/docker/buildx.nix b/nixpkgs/pkgs/applications/virtualization/docker/buildx.nix new file mode 100644 index 000000000000..89afc45ba4a9 --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/docker/buildx.nix @@ -0,0 +1,25 @@ +{ lib, buildGoModule, fetchFromGitHub }: + +buildGoModule rec { + pname = "docker-buildx"; + version = "0.6.3"; + + src = fetchFromGitHub { + owner = "docker"; + repo = "buildx"; + rev = "v${version}"; + sha256 = "sha256-UKIT3PfybuQjKxxFbRQSCA8G3R2xIySWEDUKg27u5Rk="; + }; + + vendorSha256 = null; + + installPhase = '' + install -D $GOPATH/bin/buildx $out/libexec/docker/cli-plugins/docker-buildx + ''; + + meta = with lib; { + description = "Docker CLI plugin for extended build capabilities with BuildKit"; + license = licenses.asl20; + maintainers = [ maintainers.ivan-babrou ]; + }; +} diff --git a/nixpkgs/pkgs/applications/virtualization/docker/compose.nix b/nixpkgs/pkgs/applications/virtualization/docker/compose.nix new file mode 100644 index 000000000000..3ce3d9a880f8 --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/docker/compose.nix @@ -0,0 +1,26 @@ +{ lib, buildGoModule, fetchFromGitHub }: + +buildGoModule rec { + pname = "docker-compose"; + version = "2.0.1"; + + src = fetchFromGitHub { + owner = "docker"; + repo = "compose"; + rev = "v${version}"; + sha256 = "sha256-6OjA3f6c9s/86UPxy9EqLIc/0ZuW6UhKyQdkM7YoTsU="; + }; + + vendorSha256 = "sha256-6h36TZmo0RvB3YzZRmsrs2Fbl+8zPTuL9LxWkuNgRqw="; + + doCheck = false; + installPhase = '' + install -D $GOPATH/bin/cmd $out/libexec/docker/cli-plugins/docker-compose + ''; + + meta = with lib; { + description = "Docker CLI plugin to define and run multi-container applications with Docker"; + license = licenses.asl20; + maintainers = [ maintainers.babariviere ]; + }; +} diff --git a/nixpkgs/pkgs/applications/virtualization/docker/default.nix b/nixpkgs/pkgs/applications/virtualization/docker/default.nix new file mode 100644 index 000000000000..8345b2b42d76 --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/docker/default.nix @@ -0,0 +1,244 @@ +{ lib, callPackage, fetchFromGitHub }: + +with lib; + +rec { + dockerGen = { + version, rev, sha256 + , moby-src + , runcRev, runcSha256 + , containerdRev, containerdSha256 + , tiniRev, tiniSha256, buildxSupport ? true, composeSupport ? true + # package dependencies + , stdenv, fetchFromGitHub, buildGoPackage + , makeWrapper, installShellFiles, pkg-config, glibc + , go-md2man, go, containerd_1_4, runc, docker-proxy, tini, libtool + , sqlite, iproute2, lvm2, systemd, docker-buildx, docker-compose_2 + , btrfs-progs, iptables, e2fsprogs, xz, util-linux, xfsprogs, git + , procps, libseccomp + , nixosTests + , clientOnly ? !stdenv.isLinux, symlinkJoin + }: + let + docker-runc = runc.overrideAttrs (oldAttrs: { + name = "docker-runc-${version}"; + inherit version; + src = fetchFromGitHub { + owner = "opencontainers"; + repo = "runc"; + rev = runcRev; + sha256 = runcSha256; + }; + # docker/runc already include these patches / are not applicable + patches = []; + }); + + docker-containerd = containerd_1_4.overrideAttrs (oldAttrs: { + name = "docker-containerd-${version}"; + inherit version; + src = fetchFromGitHub { + owner = "containerd"; + repo = "containerd"; + rev = containerdRev; + sha256 = containerdSha256; + }; + buildInputs = oldAttrs.buildInputs ++ [ libseccomp ]; + }); + + docker-tini = tini.overrideAttrs (oldAttrs: { + name = "docker-init-${version}"; + inherit version; + src = fetchFromGitHub { + owner = "krallin"; + repo = "tini"; + rev = tiniRev; + sha256 = tiniSha256; + }; + + # Do not remove static from make files as we want a static binary + postPatch = ""; + + buildInputs = [ glibc glibc.static ]; + + NIX_CFLAGS_COMPILE = "-DMINIMAL=ON"; + }); + + moby = buildGoPackage ((optionalAttrs (stdenv.isLinux)) rec { + name = "moby-${version}"; + inherit version; + inherit docker-runc docker-containerd docker-proxy docker-tini; + + src = moby-src; + + goPackagePath = "github.com/docker/docker"; + + nativeBuildInputs = [ makeWrapper pkg-config go-md2man go libtool installShellFiles ]; + buildInputs = [ sqlite lvm2 btrfs-progs systemd libseccomp ]; + + extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute2 iptables e2fsprogs xz xfsprogs procps util-linux git ]); + + postPatch = '' + patchShebangs hack/make.sh hack/make/ + ''; + + 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 + 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 + ''; + + DOCKER_BUILDTAGS = [] + ++ optional (systemd != null) [ "journald" ] + ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs" + ++ optional (lvm2 == null) "exclude_graphdriver_devicemapper" + ++ optional (libseccomp != null) "seccomp"; + }); + + plugins = optionals buildxSupport [ docker-buildx ] + ++ optionals composeSupport [ docker-compose_2 ]; + pluginsRef = symlinkJoin { name = "docker-plugins"; paths = plugins; }; + in + buildGoPackage ((optionalAttrs (!clientOnly) { + + inherit docker-runc docker-containerd docker-proxy docker-tini moby; + + }) // rec { + inherit version rev; + + pname = "docker"; + + src = fetchFromGitHub { + owner = "docker"; + repo = "cli"; + rev = "v${version}"; + sha256 = sha256; + }; + + goPackagePath = "github.com/docker/cli"; + + nativeBuildInputs = [ + makeWrapper pkg-config go-md2man go libtool installShellFiles + ]; + buildInputs = optionals (!clientOnly) [ + sqlite lvm2 btrfs-progs systemd libseccomp + ] ++ plugins; + + postPatch = '' + patchShebangs man scripts/build/ + substituteInPlace ./scripts/build/.variables --replace "set -eu" "" + '' + optionalString (plugins != []) '' + substituteInPlace ./cli-plugins/manager/manager_unix.go --replace /usr/libexec/docker/cli-plugins \ + "${pluginsRef}/libexec/docker/cli-plugins" + ''; + + # Keep eyes on BUILDTIME format - https://github.com/docker/cli/blob/${version}/scripts/build/.variables + buildPhase = '' + export GOCACHE="$TMPDIR/go-cache" + + cd ./go/src/${goPackagePath} + # 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}" + export BUILDTIME="1970-01-01T00:00:00Z" + source ./scripts/build/.variables + export CGO_ENABLED=1 + go build -tags pkcs11 --ldflags "$LDFLAGS" github.com/docker/cli/cmd/docker + cd - + ''; + + outputs = ["out" "man"]; + + installPhase = '' + cd ./go/src/${goPackagePath} + install -Dm755 ./docker $out/libexec/docker/docker + + makeWrapper $out/libexec/docker/docker $out/bin/docker \ + --prefix PATH : "$out/libexec/docker:$extraPath" + '' + optionalString (!clientOnly) '' + # symlink docker daemon to docker cli derivation + ln -s ${moby}/bin/dockerd $out/bin/dockerd + + # 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 + '' + '' + # completion (cli) + installShellCompletion --bash ./contrib/completion/bash/docker + installShellCompletion --fish ./contrib/completion/fish/docker.fish + installShellCompletion --zsh ./contrib/completion/zsh/_docker + '' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' + # Generate man pages from cobra commands + echo "Generate man pages from cobra" + mkdir -p ./man/man1 + go build -o ./gen-manpages github.com/docker/cli/man + ./gen-manpages --root . --target ./man/man1 + '' + '' + # Generate legacy pages from markdown + echo "Generate legacy manpages" + ./man/md2man-all.sh -q + + installManPage man/*/*.[1-9] + ''; + + passthru.tests = lib.optionals (!clientOnly) { inherit (nixosTests) docker; }; + + meta = { + homepage = "https://www.docker.com/"; + description = "An open source project to pack, ship and run any application as a lightweight container"; + license = licenses.asl20; + maintainers = with maintainers; [ offline tailhook vdemeester periklis mikroskeem maxeaubrey ]; + platforms = with platforms; linux ++ darwin; + }; + + # Exposed for tarsum build on non-linux systems (build-support/docker/default.nix) + inherit moby-src; + }); + + # Get revisions from + # https://github.com/moby/moby/tree/${version}/hack/dockerfile/install/* + docker_20_10 = callPackage dockerGen rec { + version = "20.10.9"; + rev = "v${version}"; + sha256 = "1msqvzfccah6cggvf1pm7n35zy09zr4qg2aalgwpqigv0jmrbyd4"; + moby-src = fetchFromGitHub { + owner = "moby"; + repo = "moby"; + rev = "v${version}"; + sha256 = "04xx7m8s9vrkm67ba2k5i90053h5qqkjcvw5rc8w7m5a309xcp4n"; + }; + runcRev = "v1.0.2"; # v1.0.2 + runcSha256 = "1bpckghjah0rczciw1a1ab8z718lb2d3k4mjm4zb45lpm3njmrcp"; + containerdRev = "v1.4.11"; # v1.4.11 + containerdSha256 = "02slv4gc2blxnmv0p8pkm139vjn6ihjblmn8ps2k1afbbyps0ilr"; + tiniRev = "v0.19.0"; # v0.19.0 + tiniSha256 = "1h20i3wwlbd8x4jr2gz68hgklh0lb0jj7y5xk1wvr8y58fip1rdn"; + }; +} diff --git a/nixpkgs/pkgs/applications/virtualization/docker/distribution.nix b/nixpkgs/pkgs/applications/virtualization/docker/distribution.nix new file mode 100644 index 000000000000..96722fe393f6 --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/docker/distribution.nix @@ -0,0 +1,23 @@ +{ lib, buildGoPackage, fetchFromGitHub }: + +buildGoPackage rec { + pname = "distribution"; + version = "2.7.1"; + rev = "v${version}"; + + goPackagePath = "github.com/docker/distribution"; + + src = fetchFromGitHub { + owner = "docker"; + repo = "distribution"; + inherit rev; + sha256 = "1nx8b5a68rn81alp8wkkw6qd5v32mgf0fk23mxm60zdf63qk1nzw"; + }; + + meta = with lib; { + description = "The Docker toolset to pack, ship, store, and deliver content"; + license = licenses.asl20; + maintainers = [ maintainers.globin ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/applications/virtualization/docker/gc.nix b/nixpkgs/pkgs/applications/virtualization/docker/gc.nix new file mode 100644 index 000000000000..52ca54501d75 --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/docker/gc.nix @@ -0,0 +1,33 @@ +{ stdenv, lib, fetchFromGitHub, makeWrapper, docker, coreutils, procps, gnused, findutils, gnugrep }: + +with lib; + +stdenv.mkDerivation rec { + name = "docker-gc-${rev}"; + rev = "b0cc52aa3da2e2ac0080794e0be6e674b1f063fc"; + + src = fetchFromGitHub { + inherit rev; + owner = "spotify"; + repo = "docker-gc"; + sha256 = "07wf9yn0f771xkm3x12946x5rp83hxjkd70xgfgy35zvj27wskzm"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + mkdir -p $out/bin + cp docker-gc $out/bin + chmod +x $out/bin/docker-gc + wrapProgram $out/bin/docker-gc \ + --prefix PATH : "${lib.makeBinPath [ docker coreutils procps gnused findutils gnugrep ]}" + ''; + + meta = { + description = "Docker garbage collection of containers and images"; + license = licenses.asl20; + homepage = "https://github.com/spotify/docker-gc"; + maintainers = with maintainers; [offline]; + platforms = docker.meta.platforms; + }; +} diff --git a/nixpkgs/pkgs/applications/virtualization/docker/proxy.nix b/nixpkgs/pkgs/applications/virtualization/docker/proxy.nix new file mode 100644 index 000000000000..a247e2cecfaf --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/docker/proxy.nix @@ -0,0 +1,27 @@ +{ lib, buildGoPackage, fetchFromGitHub }: + +buildGoPackage rec { + name = "docker-proxy-${rev}"; + rev = "fa125a3512ee0f6187721c88582bf8c4378bd4d7"; + + src = fetchFromGitHub { + inherit rev; + owner = "docker"; + repo = "libnetwork"; + sha256 = "1r47y0gww3j7fas4kgiqbhrz5fazsx1c6sxnccdfhj8fzik77s9y"; + }; + + goPackagePath = "github.com/docker/libnetwork"; + + installPhase = '' + install -m755 -D ./go/bin/proxy $out/bin/docker-proxy + ''; + + meta = with lib; { + description = "Docker proxy binary to forward traffic between host and containers"; + license = licenses.asl20; + homepage = "https://github.com/docker/libnetwork"; + maintainers = with maintainers; [vdemeester]; + platforms = platforms.linux; + }; +} |