feat(build): allow multiple binaries

I gave in because I wanted to use yaml-to-dhall, so this implements
copying multiple binaries.
This commit is contained in:
Profpatsch 2020-08-04 23:04:23 +02:00
parent 66da4ffe17
commit f0270205ee
6 changed files with 22 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{ pkgs, release }:
{ simpleName, binName, attrName }:
{ simpleName, binNames, attrName }:
let
release = import ./release.nix;
@ -23,9 +23,22 @@ pkgs.stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/bin
binPath="$out/bin/${binName}"
install -D -m555 -T "${binName}" "$binPath"
rm "${binName}"
${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
@ -34,11 +47,5 @@ pkgs.stdenv.mkDerivation rec {
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"
'';
}

View file

@ -2,6 +2,6 @@
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
simpleName = "dhall-bash-simple";
binName = "dhall-to-bash";
binNames = [ "dhall-to-bash" ];
attrName = "dhall-bash";
}

View file

@ -2,6 +2,6 @@
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
simpleName = "dhall-lsp-simple";
binName = "dhall-lsp-server";
binNames = [ "dhall-lsp-server" ];
attrName = "dhall-lsp-server";
}

View file

@ -2,6 +2,6 @@
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
simpleName = "dhall-nix-simple";
binName = "dhall-to-nix";
binNames = [ "dhall-to-nix" ];
attrName = "dhall-nix";
}

View file

@ -2,6 +2,6 @@
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
simpleName = "dhall-simple";
binName = "dhall";
binNames = [ "dhall" ];
attrName = "dhall";
}

View file

@ -2,6 +2,6 @@
import ./build.nix { inherit pkgs; release = import ./release.nix; } {
simpleName = "dhall-yaml-simple";
binName = "dhall-to-yaml-ng";
binNames = [ "dhall-to-yaml-ng" "yaml-to-dhall" ];
attrName = "dhall-yaml";
}