easy-dhall-nix/build.nix
Profpatsch e555e2201c test(*): automatically check all binaries, based on binNames
The test list would go out-of-date when new packages were added. This
does the same check as before, but uses the binaries we already
specify on the nix level (via a passthru).

The next step is to try to run the binaries (e.g. with --version),
which will give us a better test of whether they are actually
executable.
2020-11-06 11:59:44 +01:00

53 lines
1.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ pkgs, release }:
{ simpleName, binNames, attrName }:
let
release = import ./release.nix;
in
pkgs.stdenv.mkDerivation rec {
name = simpleName;
src = if pkgs.stdenv.isDarwin
then pkgs.fetchzip {
url = release.${"${attrName}-darwin"}.url;
sha256 = release.${"${attrName}-darwin"}.hash;
}
else pkgs.fetchzip {
url = release.${"${attrName}-linux"}.url;
sha256 = release.${"${attrName}-linux"}.hash;
};
nativeBuildInputs = [ pkgs.installShellFiles ];
passthru.binNames = binNames;
installPhase = ''
mkdir -p $out/bin
${pkgs.lib.concatMapStringsSep "\n" (binName: ''
binPath="$out/bin/${binName}"
install -D -m555 -T "${binName}" "$binPath"
rm "${binName}"
"$binPath" --bash-completion-script "$binPath" > "${binName}.bash"
installShellCompletion --bash "${binName}.bash"
rm "${binName}.bash"
"$binPath" --zsh-completion-script "$binPath" > "${binName}.zsh"
installShellCompletion --zsh "${binName}.zsh"
rm "${binName}.zsh"
"$binPath" --fish-completion-script "$binPath" > "${binName}.fish"
installShellCompletion --fish "${binName}.fish"
rm "${binName}.fish"
'') binNames}
# check that we didnt forget any files (maybe a new binary was added)
if [ ! -z "$(${pkgs.lr}/bin/lr -1 -t 'depth == 1' .)" ]; then
echo "still some files remaining!" >&2
${pkgs.lr}/bin/lr .
exit 1
fi
'';
}