2020-08-04 20:56:48 +02:00
|
|
|
|
{ pkgs, release }:
|
|
|
|
|
|
2020-12-01 00:37:26 +01:00
|
|
|
|
{ simpleName, binNames, attrName, manPages ? [] }:
|
2020-08-04 20:56:48 +02:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
release = import ./release.nix;
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
pkgs.stdenv.mkDerivation rec {
|
|
|
|
|
name = simpleName;
|
|
|
|
|
|
|
|
|
|
src = if pkgs.stdenv.isDarwin
|
2020-11-30 23:29:31 +01:00
|
|
|
|
then pkgs.fetchurl {
|
2020-08-04 20:56:48 +02:00
|
|
|
|
url = release.${"${attrName}-darwin"}.url;
|
|
|
|
|
sha256 = release.${"${attrName}-darwin"}.hash;
|
|
|
|
|
}
|
2020-11-30 23:29:31 +01:00
|
|
|
|
else pkgs.fetchurl {
|
2020-08-04 20:56:48 +02:00
|
|
|
|
url = release.${"${attrName}-linux"}.url;
|
|
|
|
|
sha256 = release.${"${attrName}-linux"}.hash;
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-04 21:47:05 +02:00
|
|
|
|
nativeBuildInputs = [ pkgs.installShellFiles ];
|
|
|
|
|
|
2020-11-06 11:47:26 +01:00
|
|
|
|
passthru.binNames = binNames;
|
|
|
|
|
|
2020-11-30 23:46:04 +01:00
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
|
2020-08-04 20:56:48 +02:00
|
|
|
|
installPhase = ''
|
|
|
|
|
mkdir -p $out/bin
|
2020-08-04 23:04:23 +02:00
|
|
|
|
|
|
|
|
|
${pkgs.lib.concatMapStringsSep "\n" (binName: ''
|
|
|
|
|
binPath="$out/bin/${binName}"
|
2020-11-30 23:46:04 +01:00
|
|
|
|
install -D -m555 -T "bin/${binName}" "$binPath"
|
|
|
|
|
rm "bin/${binName}"
|
2020-08-04 23:04:23 +02:00
|
|
|
|
|
|
|
|
|
"$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}
|
2020-08-04 22:51:27 +02:00
|
|
|
|
|
2020-11-30 23:46:04 +01:00
|
|
|
|
rmdir bin
|
|
|
|
|
|
2020-12-01 00:37:26 +01:00
|
|
|
|
${pkgs.lib.optionalString (manPages != []) ''
|
|
|
|
|
${pkgs.lib.concatMapStringsSep "\n" (manPage: ''
|
|
|
|
|
# TODO: split into $man output
|
|
|
|
|
manPagePath="$out/share/man/man1/${manPage}"
|
|
|
|
|
install -D -m644 -T "share/man/man1/${manPage}" "$manPagePath"
|
|
|
|
|
rm "share/man/man1/${manPage}"
|
|
|
|
|
'') manPages}
|
|
|
|
|
rmdir --parent share/man/man1
|
|
|
|
|
''}
|
|
|
|
|
|
2020-11-30 23:46:04 +01:00
|
|
|
|
# a bit hacky, but sourceRoot unfortunately unpacks to the runtime build dir
|
|
|
|
|
rm env-vars .sandbox.sb || true
|
|
|
|
|
|
2020-08-04 22:51:27 +02:00
|
|
|
|
# check that we didn’t 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
|
2020-08-04 20:56:48 +02:00
|
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
}
|