From 4b9a2e13a82ea293e0d1530e8d32ca07074996dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 18 Aug 2020 09:33:18 +0100 Subject: [PATCH] cloud-utils: split of smaller .guest output --- nixos/modules/system/boot/grow-partition.nix | 2 +- pkgs/tools/misc/cloud-utils/default.nix | 30 ++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/nixos/modules/system/boot/grow-partition.nix b/nixos/modules/system/boot/grow-partition.nix index 71a86c74772..be70c4ad9c8 100644 --- a/nixos/modules/system/boot/grow-partition.nix +++ b/nixos/modules/system/boot/grow-partition.nix @@ -23,7 +23,7 @@ with lib; copy_bin_and_libs ${pkgs.utillinux}/sbin/sfdisk copy_bin_and_libs ${pkgs.utillinux}/sbin/lsblk - substitute "${pkgs.cloud-utils}/bin/.growpart-wrapped" "$out/bin/growpart" \ + substitute "${pkgs.cloud-utils.guest}/bin/.growpart-wrapped" "$out/bin/growpart" \ --replace "${pkgs.bash}/bin/sh" "/bin/sh" \ --replace "awk" "gawk" \ --replace "sed" "gnused" diff --git a/pkgs/tools/misc/cloud-utils/default.nix b/pkgs/tools/misc/cloud-utils/default.nix index d5c5b0ee783..afae939ef38 100644 --- a/pkgs/tools/misc/cloud-utils/default.nix +++ b/pkgs/tools/misc/cloud-utils/default.nix @@ -1,9 +1,18 @@ { stdenv, fetchurl, makeWrapper , gawk, gnused, utillinux, file , wget, python3, qemu-utils, euca2ools -, e2fsprogs, cdrkit }: +, e2fsprogs, cdrkit +, gptfdisk }: -stdenv.mkDerivation rec { +let + # according to https://packages.debian.org/sid/cloud-image-utils + https://packages.debian.org/sid/admin/cloud-guest-utils + guestDeps = [ + e2fsprogs gptfdisk gawk gnused utillinux + ]; + binDeps = guestDeps ++ [ + wget file qemu-utils cdrkit + ]; +in stdenv.mkDerivation rec { # NOTICE: if you bump this, make sure to run # $ nix-build nixos/release-combined.nix -A nixos.tests.ec2-nixops # growpart is needed in initrd in nixos/system/boot/grow-partition.nix @@ -17,15 +26,24 @@ stdenv.mkDerivation rec { buildInputs = [ python3 ]; installFlags = [ "LIBDIR=$(out)/lib" "BINDIR=$(out)/bin" "MANDIR=$(out)/man/man1" "DOCDIR=$(out)/doc" ]; - # according to https://packages.ubuntu.com/source/zesty/cloud-utils - binDeps = [ - wget e2fsprogs file gnused gawk utillinux qemu-utils euca2ools cdrkit - ]; + # $guest output contains all executables needed for cloud-init and $out the rest + $guest + # This is similar to debian's package split into cloud-image-utils and cloud-guest-utils + # The reason is to reduce the closure size + outputs = [ "out" "guest"]; postFixup = '' + moveToOutput bin/ec2metadata $guest + moveToOutput bin/growpart $guest + moveToOutput bin/vcs-run $guest + for i in $out/bin/*; do wrapProgram $i --prefix PATH : "${stdenv.lib.makeBinPath binDeps}:$out/bin" done + + for i in $guest/bin/*; do + wrapProgram $i --prefix PATH : "${stdenv.lib.makeBinPath guestDeps}:$guest/bin" + ln -s $i $out/bin + done ''; dontBuild = true;