From 0f0ffa70a0221a9b19fcb95d53aa86475069087f Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Thu, 16 Nov 2017 12:48:28 +0100 Subject: [PATCH 1/4] docker-cli: enable darwin support --- .../virtualization/docker/default.nix | 85 +++++++++++-------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index 48bb512e1341..467b966f3ab0 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -13,18 +13,8 @@ rec { , runcRev, runcSha256 , containerdRev, containerdSha256 , tiniRev, tiniSha256 - } : stdenv.mkDerivation rec { - inherit version rev; - - name = "docker-${version}"; - - src = fetchFromGitHub { - owner = "docker"; - repo = "docker-ce"; - rev = "v${version}"; - sha256 = sha256; - }; - + } : + let docker-runc = runc.overrideAttrs (oldAttrs: rec { name = "docker-runc"; src = fetchFromGitHub { @@ -36,6 +26,7 @@ rec { # docker/runc already include these patches / are not applicable patches = []; }); + docker-containerd = containerd.overrideAttrs (oldAttrs: rec { name = "docker-containerd"; src = fetchFromGitHub { @@ -51,6 +42,7 @@ rec { mv $(pwd)/vendor/{github.com,golang.org,google.golang.org} $(pwd)/vendor/src/ '' + oldAttrs.preBuild; }); + docker-tini = tini.overrideAttrs (oldAttrs: rec { name = "docker-init"; src = fetchFromGitHub { @@ -68,17 +60,10 @@ rec { "-DMINIMAL=ON" ]; }); + in + stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec { - # Optimizations break compilation of libseccomp c bindings - hardeningDisable = [ "fortify" ]; - - nativeBuildInputs = [ pkgconfig ]; - buildInputs = [ - makeWrapper removeReferencesTo go-md2man go - sqlite devicemapper btrfs-progs systemd libtool libseccomp - ]; - - dontStrip = true; + inherit docker-runc docker-containerd docker-tini; DOCKER_BUILDTAGS = [] ++ optional (systemd != null) [ "journald" ] @@ -86,14 +71,38 @@ rec { ++ optional (devicemapper == null) "exclude_graphdriver_devicemapper" ++ optional (libseccomp != null) "seccomp"; - buildPhase = '' + }) // rec { + inherit version rev; + + name = "docker-${version}"; + + src = fetchFromGitHub { + owner = "docker"; + repo = "docker-ce"; + rev = "v${version}"; + sha256 = sha256; + }; + + # Optimizations break compilation of libseccomp c bindings + hardeningDisable = [ "fortify" ]; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ + makeWrapper removeReferencesTo go-md2man go libtool + ] ++ optionals (stdenv.isLinux) [ + sqlite devicemapper btrfs-progs systemd libtool libseccomp + ]; + + dontStrip = true; + + buildPhase = (optionalString (stdenv.isLinux) '' # build engine cd ./components/engine export AUTO_GOPATH=1 export DOCKER_GITCOMMIT="${rev}" ./hack/make.sh dynbinary cd - - + '') + '' # build cli cd ./components/cli # Mimic AUTO_GOPATH @@ -110,27 +119,24 @@ rec { # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd patchPhase = '' + substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" + '' + optionalString (stdenv.isLinux) '' 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" "" - ''; + ''; outputs = ["out" "man"]; - extraPath = makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]; - - installPhase = '' - install -Dm755 ./components/cli/docker $out/libexec/docker/docker + extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux ]); + installPhase = optionalString (stdenv.isLinux) '' if [ -d "./components/engine/bundles/${version}" ]; then install -Dm755 ./components/engine/bundles/${version}/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd else install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd-${version} $out/libexec/docker/dockerd fi - 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" @@ -143,6 +149,11 @@ rec { # systemd install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service + '' + '' + install -Dm755 ./components/cli/docker $out/libexec/docker/docker + + makeWrapper $out/libexec/docker/docker $out/bin/docker \ + --prefix PATH : "$out/libexec/docker:$extraPath" # completion (cli) install -Dm644 ./components/cli/contrib/completion/bash/docker $out/share/bash-completion/completions/docker @@ -174,17 +185,19 @@ rec { ''; preFixup = '' - find $out -type f -exec remove-references-to -t ${go} -t ${stdenv.cc.cc} -t ${stdenv.glibc.dev} '{}' + + 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} '{}' + ''; 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; [ nequissimus offline tailhook vdemeester ]; - platforms = platforms.linux; + maintainers = with maintainers; [ nequissimus offline tailhook vdemeester periklis ]; + platforms = with platforms; [ linux darwin ]; }; - }; + }); # Get revisions from # https://github.com/docker/docker-ce/blob/v${version}/components/engine/hack/dockerfile/binaries-commits From 73c915296f8f358a4dab6d97c01225c9d2ed77b8 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Mon, 20 Nov 2017 20:06:29 +0100 Subject: [PATCH 2/4] docker-machine-xhyve: init darwin support --- .../cluster/docker-machine/xhyve-deps.nix | 21 +++++++++++++++ .../cluster/docker-machine/xhyve.nix | 27 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 pkgs/applications/networking/cluster/docker-machine/xhyve-deps.nix create mode 100644 pkgs/applications/networking/cluster/docker-machine/xhyve.nix diff --git a/pkgs/applications/networking/cluster/docker-machine/xhyve-deps.nix b/pkgs/applications/networking/cluster/docker-machine/xhyve-deps.nix new file mode 100644 index 000000000000..99cb7b98f5cc --- /dev/null +++ b/pkgs/applications/networking/cluster/docker-machine/xhyve-deps.nix @@ -0,0 +1,21 @@ +# This file was generated by https://github.com/kamilchm/go2nix v1.2.1 +[ + { + goPackagePath = "github.com/docker/machine"; + fetch = { + type = "git"; + url = "https://github.com/docker/machine"; + rev = "5b274558ea6ca822c06dd407a4e774a0105c3f60"; + sha256 = "1wdq9h4bx7awgclh969gvmcnl9jvgv7ldfklnclh5iv47mi7q22d"; + }; + } + { + goPackagePath = "github.com/zchee/libhyperkit"; + fetch = { + type = "git"; + url = "https://github.com/zchee/libhyperkit"; + rev = "1a19a7693fac32b46ec6cdd22da6fbec974447fc"; + sha256 = "119f5gcl24znwnmi837jk667asd3lirx32jldpd4mbyb3sm9nz24"; + }; + } +] diff --git a/pkgs/applications/networking/cluster/docker-machine/xhyve.nix b/pkgs/applications/networking/cluster/docker-machine/xhyve.nix new file mode 100644 index 000000000000..6b0440eb84ae --- /dev/null +++ b/pkgs/applications/networking/cluster/docker-machine/xhyve.nix @@ -0,0 +1,27 @@ +{ stdenv, buildGoPackage, fetchFromGitHub, pkgconfig, Hypervisor, vmnet }: + +buildGoPackage rec { + name = "docker-machine-xhyve-${version}"; + version = "0.3.3"; + + goPackagePath = "github.com/zchee/docker-machine-driver-xhyve"; + goDeps = ./xhyve-deps.nix; + + src = fetchFromGitHub { + rev = "v${version}"; + owner = "zchee"; + repo = "docker-machine-driver-xhyve"; + sha256 = "0rj6pyqp4yv4j28bglqjs95rip5i77vv8mrkmqv1rxrsl3i8aqqy"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ Hypervisor vmnet ]; + + meta = with stdenv.lib; { + homepage = https://github.com/zchee/docker-machine-driver-xhyve; + description = "Xhyve driver for docker-machine."; + license = licenses.bsd3; + maintainers = with maintainers; [ periklis ]; + platforms = platforms.darwin; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8bad50a4799a..23a9bb27fe0a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14250,6 +14250,9 @@ with pkgs; docker-machine = callPackage ../applications/networking/cluster/docker-machine { }; docker-machine-kvm = callPackage ../applications/networking/cluster/docker-machine/kvm.nix { }; + docker-machine-xhyve = callPackage ../applications/networking/cluster/docker-machine/xhyve.nix { + inherit (darwin.apple_sdk.frameworks) Hypervisor vmnet; + }; docker-distribution = callPackage ../applications/virtualization/docker-distribution { }; From 4a2bd8ed145f5f18cbdfa64bab5ccd2e655c879c Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Mon, 20 Nov 2017 20:16:08 +0100 Subject: [PATCH 3/4] fixup! docker-cli: enable darwin support --- pkgs/applications/virtualization/docker/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index 467b966f3ab0..ae3106669b52 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -63,7 +63,7 @@ rec { in stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec { - inherit docker-runc docker-containerd docker-tini; + inherit docker-runc docker-containerd docker-proxy docker-tini; DOCKER_BUILDTAGS = [] ++ optional (systemd != null) [ "journald" ] From 1434c5ed9c5f9f9f1253f258f759d6dc2ebc0eea Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Mon, 20 Nov 2017 20:30:46 +0100 Subject: [PATCH 4/4] fixup! docker-cli: enable darwin support --- pkgs/applications/virtualization/docker/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index ae3106669b52..2aa418f0d844 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -195,7 +195,7 @@ rec { description = "An open source project to pack, ship and run any application as a lightweight container"; license = licenses.asl20; maintainers = with maintainers; [ nequissimus offline tailhook vdemeester periklis ]; - platforms = with platforms; [ linux darwin ]; + platforms = with platforms; linux ++ darwin; }; });