-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nix: Rearrange Hydra release files to match Travis release script
- Loading branch information
Showing
6 changed files
with
154 additions
and
209 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
############################################################################ | ||
# Release package | ||
# | ||
# This bundles up the build of the given exes, with their | ||
# dependencies, and sets up the Hydra build artifact. | ||
# | ||
############################################################################ | ||
|
||
{ pkgs | ||
, platform | ||
, exes | ||
, format | ||
}: | ||
|
||
let | ||
inherit (pkgs) lib commonLib; | ||
|
||
exe = assert lib.assertMsg (lib.length exes > 0) "empty list of exes"; | ||
lib.head exes; | ||
name = "${commonLib.versionTag exe.meta.name}-${platform}"; | ||
|
||
makeTarball = format == "tar.gz"; | ||
makeZip = format == "zip"; | ||
|
||
isLinux = platform == "linux64"; | ||
isMacos = platform == "macos"; | ||
isWindows = platform == "win64"; | ||
|
||
in | ||
assert lib.assertMsg (makeTarball || makeZip) | ||
"format must be tar.gz or zip"; | ||
assert lib.assertMsg (isLinux || isMacos || isWindows) | ||
"wrong platform \"${platform}\""; | ||
|
||
pkgs.stdenv.mkDerivation { | ||
inherit name; | ||
buildInputs = with pkgs.buildPackages; [ | ||
binutils | ||
haskellBuildUtils | ||
nix | ||
] | ||
++ lib.optionals makeTarball [ gnutar gzip ] | ||
++ lib.optionals makeZip [ zip ]; | ||
checkInputs = with pkgs.buildPackages; [ | ||
ruby | ||
gnugrep | ||
gnused | ||
] | ||
++ lib.optionals isMacos [ darwin.cctools ] | ||
++ lib.optionals isWindows [ unzip wineMinimal ] | ||
++ lib.optional (stdenv.buildPlatform.libc == "glibc") glibcLocales; | ||
|
||
doCheck = true; | ||
phases = [ "buildPhase" "checkPhase" ]; | ||
pkgname = "${name}.${format}"; | ||
exeName = lib.getName exe.name; | ||
buildPhase = '' | ||
mkdir -p $out/nix-support $name | ||
cp -nR ${lib.concatMapStringsSep " " (exe: "${exe}/bin/*") exes} $name | ||
chmod -R 755 $name | ||
'' + lib.optionalString isMacos '' | ||
# Rewrite library paths to standard non-nix locations | ||
( cd $name; rewrite-libs . `ls -1 | grep -Fv .dylib` ) | ||
'' + lib.optionalString (isLinux || isMacos) '' | ||
mkdir -p $name/auto-completion/{bash,zsh,fish} | ||
cp ${exe}/share/bash-completion/completions/* $name/auto-completion/bash/$exeName.sh | ||
cp ${exe}/share/zsh/vendor-completions/* $name/auto-completion/zsh/_$exeName | ||
cp ${exe}/share/fish/vendor_completions.d/* $name/auto-completion/fish/$exeName.fish | ||
'' + lib.optionalString makeTarball '' | ||
tar -czf $out/$pkgname $name | ||
'' + lib.optionalString makeZip '' | ||
( cd $name; zip -r $out/$pkgname . ) | ||
'' + '' | ||
echo "file binary-dist $out/$pkgname" > $out/nix-support/hydra-build-products | ||
'' + lib.optionalString isWindows '' | ||
# make a separate configuration package if needed | ||
if [ -d ${exe}/configuration ]; then | ||
cp -R ${exe}/configuration .. | ||
cd ../configuration | ||
chmod -R +w . | ||
zip -r $out/${exe.name}-configuration.zip . | ||
echo "file binary-dist $out/${exe.name}-configuration.zip" >> $out/nix-support/hydra-build-products | ||
fi | ||
# make a separate deployments configuration package if needed | ||
if [ -d ${exe}/deployments ]; then | ||
cp -R ${exe}/deployments .. | ||
cd ../deployments | ||
chmod -R +w . | ||
zip -r $out/${exe.name}-deployments.zip . | ||
echo "file binary-dist $out/${exe.name}-deployments.zip" >> $out/nix-support/hydra-build-products | ||
fi | ||
''; | ||
|
||
# test that executables work | ||
exeRunner = lib.optionalString isWindows "wine64"; | ||
checkPhase = '' | ||
cd `mktemp -d` | ||
echo " - extracting $pkgname" | ||
${lib.optionalString makeTarball "tar -xzvf $out/$pkgname"} | ||
${lib.optionalString makeZip "unzip $out/$pkgname"} | ||
'' + lib.optionalString isWindows '' | ||
# setup wine | ||
export WINEPREFIX=$TMP | ||
export HOME=$TMP | ||
export WINEDLLOVERRIDES="winemac.drv=d" | ||
export WINEDEBUG=warn-all,fixme-all,-menubuilder,-mscoree,-ole,-secur32,-winediag | ||
'' + '' | ||
export PATH=`pwd`/$name:$PATH | ||
echo " - running checks" | ||
ruby ${../scripts/check-bundle.rb} $exeName $exeRunner | ||
''; | ||
} // lib.optionalAttrs (pkgs.stdenv.buildPlatform.libc == "glibc") { | ||
LOCALE_ARCHIVE = "${pkgs.buildPackages.glibcLocales}/lib/locale/locale-archive"; | ||
LANG = "en_US.UTF-8"; | ||
LC_ALL = "en_US.UTF-8"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters