summary refs log tree commit diff
path: root/pkgs/applications/virtualization/docker/default.nix
diff options
context:
space:
mode:
authorPeriklis Tsirakidis <periklis.tsirakidis@holidaycheck.com>2017-11-16 12:48:28 +0100
committerPeriklis Tsirakidis <periklis.tsirakidis@holidaycheck.com>2017-11-20 20:07:00 +0100
commit0f0ffa70a0221a9b19fcb95d53aa86475069087f (patch)
tree7de670ac66dab37d266d03d0cfc49b52581075ae /pkgs/applications/virtualization/docker/default.nix
parent7be449a97dfad96822680711a3d3f694cd066f68 (diff)
downloadnixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.tar
nixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.tar.gz
nixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.tar.bz2
nixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.tar.lz
nixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.tar.xz
nixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.tar.zst
nixpkgs-0f0ffa70a0221a9b19fcb95d53aa86475069087f.zip
docker-cli: enable darwin support
Diffstat (limited to 'pkgs/applications/virtualization/docker/default.nix')
-rw-r--r--pkgs/applications/virtualization/docker/default.nix79
1 files changed, 46 insertions, 33 deletions
diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix
index 48bb512e134..467b966f3ab 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,32 +60,49 @@ rec {
         "-DMINIMAL=ON"
       ];
     });
+  in
+    stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) rec {
+
+    inherit docker-runc docker-containerd docker-tini;
+
+    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;
+    };
 
     # Optimizations break compilation of libseccomp c bindings
     hardeningDisable = [ "fortify" ];
 
     nativeBuildInputs = [ pkgconfig ];
     buildInputs = [
-      makeWrapper removeReferencesTo go-md2man go
+      makeWrapper removeReferencesTo go-md2man go libtool
+    ] ++ optionals (stdenv.isLinux) [
       sqlite devicemapper btrfs-progs systemd libtool libseccomp
     ];
 
     dontStrip = true;
 
-    DOCKER_BUILDTAGS = []
-      ++ optional (systemd != null) [ "journald" ]
-      ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs"
-      ++ optional (devicemapper == null) "exclude_graphdriver_devicemapper"
-      ++ optional (libseccomp != null) "seccomp";
-
-    buildPhase = ''
+    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