From 17ddcccb56fb42e03337c02a214c212955cd2c9d Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Thu, 20 Dec 2018 14:25:24 +0100 Subject: [PATCH] containerd: migrate to using buildGoPackage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and add man pages, which means `containerd` becomes a multi-output derivation : `containerd.bin` and `containerd.man`. Signed-off-by: Vincent Demeester --- .../virtualization/containerd/default.nix | 40 ++++++++++--------- .../virtualization/docker/default.nix | 4 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkgs/applications/virtualization/containerd/default.nix b/pkgs/applications/virtualization/containerd/default.nix index d9056c4111d1..8babf2acd7e9 100644 --- a/pkgs/applications/virtualization/containerd/default.nix +++ b/pkgs/applications/virtualization/containerd/default.nix @@ -1,9 +1,8 @@ -{ stdenv, lib, fetchFromGitHub, removeReferencesTo -, go, btrfs-progs }: +{ stdenv, lib, fetchFromGitHub, buildGoPackage, btrfs-progs, go-md2man, utillinux }: with lib; -stdenv.mkDerivation rec { +buildGoPackage rec { name = "containerd-${version}"; version = "1.2.1"; @@ -14,34 +13,37 @@ stdenv.mkDerivation rec { sha256 = "16zn6p1ky3yrgn53z8h9wza53ch91fj47wj5xgz6w4c57j30f66p"; }; + goPackagePath = "github.com/containerd/containerd"; + outputs = [ "bin" "out" "man" ]; + hardeningDisable = [ "fortify" ]; - buildInputs = [ removeReferencesTo go btrfs-progs ]; + buildInputs = [ btrfs-progs go-md2man utillinux ]; buildFlags = "VERSION=v${version}"; BUILDTAGS = [] ++ optional (btrfs-progs == null) "no_btrfs"; - preConfigure = '' - # Extract the source - cd "$NIX_BUILD_TOP" - mkdir -p "go/src/github.com/containerd" - mv "$sourceRoot" "go/src/github.com/containerd/containerd" - export GOPATH=$NIX_BUILD_TOP/go:$GOPATH -''; - - preBuild = '' - cd go/src/github.com/containerd/containerd + buildPhase = '' + cd go/src/${goPackagePath} patchShebangs . + make binaries ''; installPhase = '' - mkdir -p $out/bin - cp bin/* $out/bin - ''; + for b in bin/*; do + install -Dm555 $b $bin/$b + done - preFixup = '' - find $out -type f -exec remove-references-to -t ${go} '{}' + + make man + manRoot="$man/share/man" + mkdir -p "$manRoot" + for manFile in man/*; do + manName="$(basename "$manFile")" # "docker-build.1" + number="$(echo $manName | rev | cut -d'.' -f1 | rev)" + mkdir -p "$manRoot/man$number" + gzip -c "$manFile" > "$manRoot/man$number/$manName.gz" + done ''; meta = { diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index 729ba9eae185..28c43debcabe 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -28,7 +28,7 @@ rec { patches = []; }); - docker-containerd = (containerd.override { inherit go; }).overrideAttrs (oldAttrs: rec { + docker-containerd = containerd.overrideAttrs (oldAttrs: rec { name = "docker-containerd-${version}"; inherit version; src = fetchFromGitHub { @@ -39,8 +39,6 @@ rec { }; hardeningDisable = [ "fortify" ]; - - buildInputs = [ removeReferencesTo go btrfs-progs ]; }); docker-tini = tini.overrideAttrs (oldAttrs: rec {