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 }: { pkgs, release }:
{ simpleName, binName, attrName }: { simpleName, binNames, attrName }:
let let
release = import ./release.nix; release = import ./release.nix;
@ -23,9 +23,22 @@ pkgs.stdenv.mkDerivation rec {
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
binPath="$out/bin/${binName}"
install -D -m555 -T "${binName}" "$binPath" ${pkgs.lib.concatMapStringsSep "\n" (binName: ''
rm "${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) # check that we didnt forget any files (maybe a new binary was added)
if [ ! -z "$(${pkgs.lr}/bin/lr -1 -t 'depth == 1' .)" ]; then if [ ! -z "$(${pkgs.lr}/bin/lr -1 -t 'depth == 1' .)" ]; then
@ -34,11 +47,5 @@ pkgs.stdenv.mkDerivation rec {
exit 1 exit 1
fi 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; } { import ./build.nix { inherit pkgs; release = import ./release.nix; } {
simpleName = "dhall-bash-simple"; simpleName = "dhall-bash-simple";
binName = "dhall-to-bash"; binNames = [ "dhall-to-bash" ];
attrName = "dhall-bash"; attrName = "dhall-bash";
} }

View File

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

View File

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

View File

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

View File

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