From 00422d6a8b1d1b43e0a7a25f00d34f4970d0c70a Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 25 Jan 2019 10:46:16 +0000 Subject: [PATCH 1/4] tini: fix cross-compilation (cherry picked from commit 6176cf75c6e9767fd078aa5bac9970b9e9d3d669) --- pkgs/applications/virtualization/tini/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/virtualization/tini/default.nix b/pkgs/applications/virtualization/tini/default.nix index db3fb1c96eb..e3b1ccd4ce2 100644 --- a/pkgs/applications/virtualization/tini/default.nix +++ b/pkgs/applications/virtualization/tini/default.nix @@ -15,7 +15,8 @@ stdenv.mkDerivation rec { NIX_CFLAGS_COMPILE = "-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"; - buildInputs = [ cmake glibc glibc.static ]; + nativeBuildInputs = [ cmake ]; + buildInputs = [ glibc glibc.static ]; meta = with stdenv.lib; { description = "A tiny but valid init for containers"; From b9ac86e7520adee0f9d18a700f8838fca9fe637a Mon Sep 17 00:00:00 2001 From: betaboon Date: Fri, 3 Jul 2020 09:17:54 +0200 Subject: [PATCH 2/4] buildGoPackage: remove references in $out/libexec --- pkgs/development/go-packages/generic/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/go-packages/generic/default.nix b/pkgs/development/go-packages/generic/default.nix index 54d1c743bee..9d3c7c3d573 100644 --- a/pkgs/development/go-packages/generic/default.nix +++ b/pkgs/development/go-packages/generic/default.nix @@ -212,6 +212,7 @@ let preFixup = preFixup + '' find $out/bin -type f -exec ${removeExpr removeReferences} '{}' + || true + find $out/libexec -type f -exec ${removeExpr removeReferences} '{}' + || true ''; strictDeps = true; From 493f219f9509320cb07efb9235ab7572a1c1103b Mon Sep 17 00:00:00 2001 From: betaboon Date: Fri, 3 Jul 2020 09:19:24 +0200 Subject: [PATCH 3/4] docker: use buildGoPackage --- .../virtualization/docker/default.nix | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index e9fc96986a8..6b76ea24e3d 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -1,4 +1,5 @@ -{ stdenv, lib, fetchFromGitHub, makeWrapper, removeReferencesTo, installShellFiles, pkgconfig +{ stdenv, lib, fetchFromGitHub, fetchpatch, buildGoPackage +, makeWrapper, removeReferencesTo, installShellFiles, pkgconfig , go-md2man, go, containerd, runc, docker-proxy, tini, libtool , sqlite, iproute, lvm2, systemd , btrfs-progs, iptables, e2fsprogs, xz, utillinux, xfsprogs, git @@ -56,7 +57,7 @@ rec { NIX_CFLAGS_COMPILE = "-DMINIMAL=ON"; }); in - stdenv.mkDerivation ((optionalAttrs (stdenv.isLinux) { + buildGoPackage ((optionalAttrs (stdenv.isLinux) { inherit docker-runc docker-containerd docker-proxy docker-tini; @@ -66,7 +67,7 @@ rec { ++ optional (lvm2 == null) "exclude_graphdriver_devicemapper" ++ optional (libseccomp != null) "seccomp"; - }) // { + }) // rec { inherit version rev; name = "docker-${version}"; @@ -78,9 +79,19 @@ rec { sha256 = sha256; }; - nativeBuildInputs = [ installShellFiles pkgconfig ]; + patches = [ + # Replace hard-coded cross-compiler with $CC + (fetchpatch { + url = https://github.com/docker/docker-ce/commit/2fdfb4404ab811cb00227a3de111437b829e55cf.patch; + sha256 = "1af20bzakhpfhaixc29qnl9iml9255xdinxdnaqp4an0n1xa686a"; + }) + ]; + + goPackagePath = "github.com/docker/docker-ce"; + + nativeBuildInputs = [ pkgconfig go-md2man go libtool removeReferencesTo installShellFiles ]; buildInputs = [ - makeWrapper removeReferencesTo go-md2man go libtool + makeWrapper ] ++ optionals (stdenv.isLinux) [ sqlite lvm2 btrfs-progs systemd libseccomp ]; @@ -91,7 +102,7 @@ rec { export GOCACHE="$TMPDIR/go-cache" '' + (optionalString (stdenv.isLinux) '' # build engine - cd ./components/engine + cd ./go/src/${goPackagePath}/components/engine export AUTO_GOPATH=1 export DOCKER_GITCOMMIT="${rev}" export VERSION="${version}" @@ -99,7 +110,7 @@ rec { cd - '') + '' # build cli - cd ./components/cli + cd ./go/src/${goPackagePath}/components/cli # Mimic AUTO_GOPATH mkdir -p .gopath/src/github.com/docker/ ln -sf $PWD .gopath/src/github.com/docker/cli @@ -113,7 +124,7 @@ rec { ''; # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd - patchPhase = '' + postPatch = '' substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" "" '' + optionalString (stdenv.isLinux) '' patchShebangs . @@ -126,6 +137,7 @@ rec { extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps utillinux git ]); installPhase = optionalString (stdenv.isLinux) '' + cd ./go/src/${goPackagePath} install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd $out/libexec/docker/dockerd makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \ @@ -152,13 +164,14 @@ rec { installShellCompletion --zsh ./components/cli/contrib/completion/zsh/_docker # Include contributed man pages (cli) + cd ./components/cli + '' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' # Generate man pages from cobra commands echo "Generate man pages from cobra" - cd ./components/cli 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 From 0e305341fdc062d39ad62d5b8b2d08eb447d2f36 Mon Sep 17 00:00:00 2001 From: betaboon Date: Fri, 3 Jul 2020 09:19:56 +0200 Subject: [PATCH 4/4] cni: support aarch64-linux --- pkgs/applications/networking/cluster/cni/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/networking/cluster/cni/default.nix b/pkgs/applications/networking/cluster/cni/default.nix index 5bbd1014125..02f5fc18d13 100644 --- a/pkgs/applications/networking/cluster/cni/default.nix +++ b/pkgs/applications/networking/cluster/cni/default.nix @@ -18,6 +18,6 @@ buildGoPackage rec { license = licenses.asl20; homepage = "https://github.com/containernetworking/cni"; maintainers = with maintainers; [ offline vdemeester ]; - platforms = [ "x86_64-linux" ]; + platforms = [ "x86_64-linux" "aarch64-linux" ]; }; }