2024-06-30 08:16:52 +00:00
|
|
|
/*
|
|
|
|
This function builds a binary tarball. The resulting binaries are
|
|
|
|
usually only useful if they are don't have any runtime dependencies
|
|
|
|
on any paths in the Nix store, since those aren't distributed in
|
|
|
|
the tarball. For instance, the binaries should be statically
|
|
|
|
linked: they can't depend on dynamic libraries in the store
|
|
|
|
(including Glibc).
|
|
|
|
|
|
|
|
The binaries are built and installed with a prefix of /usr/local by
|
|
|
|
default. They are installed by setting DESTDIR to a temporary
|
|
|
|
directory, so the Makefile of the package should support DESTDIR.
|
2024-05-02 00:46:19 +00:00
|
|
|
*/
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
src,
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
name ? "binary-tarball",
|
|
|
|
...
|
|
|
|
}@args:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation (
|
|
|
|
|
|
|
|
{
|
|
|
|
# Also run a `make check'.
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
showBuildStats = true;
|
|
|
|
|
|
|
|
prefix = "/usr/local";
|
|
|
|
|
|
|
|
postPhases = "finalPhase";
|
|
|
|
}
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
// args
|
|
|
|
//
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
name = name + (lib.optionalString (src ? version) "-${src.version}");
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
postHook = ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "$system" > $out/nix-support/system
|
|
|
|
. ${./functions.sh}
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
origSrc=$src
|
|
|
|
src=$(findTarball $src)
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
if test -e $origSrc/nix-support/hydra-release-name; then
|
|
|
|
releaseName=$(cat $origSrc/nix-support/hydra-release-name)
|
|
|
|
fi
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
installFlagsArray=(DESTDIR=$TMPDIR/inst)
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
# Prefix hackery because of a bug in stdenv (it tries to `mkdir
|
|
|
|
# $prefix', which doesn't work due to the DESTDIR).
|
|
|
|
configureFlags="--prefix=$prefix $configureFlags"
|
|
|
|
dontAddPrefix=1
|
|
|
|
prefix=$TMPDIR/inst$prefix
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
doDist = true;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
distPhase = ''
|
|
|
|
mkdir -p $out/tarballs
|
|
|
|
tar cvfj $out/tarballs/''${releaseName:-binary-dist}.tar.bz2 -C $TMPDIR/inst .
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
finalPhase = ''
|
|
|
|
for i in $out/tarballs/*; do
|
|
|
|
echo "file binary-dist $i" >> $out/nix-support/hydra-build-products
|
|
|
|
done
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
# Propagate the release name of the source tarball. This is
|
|
|
|
# to get nice package names in channels.
|
|
|
|
test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name)
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
meta = (lib.optionalAttrs (args ? meta) args.meta) // {
|
|
|
|
description = "Build of a generic binary distribution";
|
|
|
|
};
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
)
|