1 # This function compiles a source tarball in a virtual machine image
2 # that contains a Debian-like (i.e. dpkg-based) OS.
4 { name ? "debian-build"
6 , src, lib, stdenv, vmTools, checkinstall
7 , fsTranslation ? false
8 , # Features provided by this package.
10 , # Features required by this package.
14 vmTools.runInLinuxImage (stdenv.mkDerivation (
21 prePhases = "installExtraDebsPhase sysInfoPhase";
24 // removeAttrs args ["vmTools" "lib"] //
27 name = name + "-" + diskImage.name + (lib.optionalString (src ? version) "-${src.version}");
29 # !!! cut&paste from rpm-build.nix
33 src=$(findTarball $src)
36 installExtraDebsPhase = ''
37 for i in $extraDebs; do
38 dpkg --install $(ls $i/debs/*.deb | sort | head -1)
43 [ ! -f /etc/lsb-release ] || (source /etc/lsb-release; echo "OS release: $DISTRIB_DESCRIPTION")
44 echo "System/kernel: $(uname -a)"
45 if test -e /etc/debian_version; then echo "Debian release: $(cat /etc/debian_version)"; fi
46 echo "installed Debian packages"
54 # otherwise build hangs when it wants to display
57 ${checkinstall}/sbin/checkinstall --nodoc -y -D \
58 --fstrans=${if fsTranslation then "yes" else "no"} \
59 --requires="${lib.concatStringsSep "," debRequires}" \
60 --provides="${lib.concatStringsSep "," debProvides}" \
61 ${if (src ? version) then "--pkgversion=$(echo ${src.version} | tr _ -)"
62 else "--pkgversion=0.0.0"} \
63 ''${debMaintainer:+--maintainer="'$debMaintainer'"} \
64 ''${debName:+--pkgname="'$debName'"} \
67 $SHELL -c "''${installCommand:-make install}"
70 find . -name "*.deb" -exec cp {} $out/debs \;
72 [ "$(echo $out/debs/*.deb)" != "" ]
74 for i in $out/debs/*.deb; do
75 echo "Generated DEB package: $i"
77 pkgName=$(dpkg-deb -W "$i" | awk '{print $1}')
78 echo "file deb $i" >> $out/nix-support/hydra-build-products
80 dpkg -i $out/debs/*.deb
82 for i in $extraDebs; do
83 echo "file deb-extra $(ls $i/debs/*.deb | sort | head -1)" >> $out/nix-support/hydra-build-products
89 meta = (lib.optionalAttrs (args ? meta) args.meta) // {
90 description = "Deb package for ${diskImage.fullName}";