easy-dhall-nix/build.nix
Profpatsch 66da4ffe17 feat(build): check that we copied all binaries
Sometmmes a new binary is added to an output, like in the `dhall-yaml`
case, where yaml-to-dhall was added.

This uses `lr` because I can’t be bothered to figure out how to use
`find` to the same effect.
2020-08-04 23:06:03 +02:00

44 lines
1.2 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, binName, 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 ];
installPhase = ''
mkdir -p $out/bin
binPath="$out/bin/${binName}"
install -D -m555 -T "${binName}" "$binPath"
rm "${binName}"
# 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
"$binPath" --bash-completion-script "$binPath" > "${binName}.bash"
installShellCompletion --bash "${binName}.bash"
"$binPath" --zsh-completion-script "$binPath" > "${binName}.zsh"
installShellCompletion --zsh "${binName}.zsh"
"$binPath" --fish-completion-script "$binPath" > "${binName}.fish"
installShellCompletion --fish "${binName}.fish"
'';
}