slack-cli: fix dirname hack

This commit is contained in:
Alyssa Ross 2018-08-15 16:53:11 +01:00
parent 026f49e28c
commit 0e374a1b9c
No known key found for this signature in database
GPG Key ID: C4844408C0657052
1 changed files with 34 additions and 33 deletions

View File

@ -7,20 +7,7 @@
{ stdenv, lib, writeShellScriptBin, fetchFromGitHub, curl, jq }:
let
wrapper = writeShellScriptBin "slack" ''
[ "$1" = "init" -a -z "$SLACK_CLI_TOKEN" ] && cat >&2 <<-'MESSAGE'
WARNING: slack-cli must be configured using the SLACK_CLI_TOKEN environment
variable. Using `slack init` will not work because it tries to write to the
Nix store.
MESSAGE
export PATH=${lib.makeBinPath [ curl jq ]}:"$PATH"
exec "$(dirname "$0")/.slack-wrapped" "$@"
'';
in stdenv.mkDerivation rec {
stdenv.mkDerivation rec {
name = "slack-cli-${version}";
version = "0.18.0";
@ -36,7 +23,21 @@ in stdenv.mkDerivation rec {
installPhase = ''
mkdir -p "$out/bin"
cp src/slack "$out/bin/.slack-wrapped"
ln -s ${wrapper}/bin/slack "$out/bin/slack"
cat <<-WRAPPER > "$out/bin/slack"
#!${stdenv.shell}
[ "\$1" = "init" -a -z "\$SLACK_CLI_TOKEN" ] && cat <<-'MESSAGE' >&2
WARNING: slack-cli must be configured using the SLACK_CLI_TOKEN
environment variable. Using \`slack init\` will not work because it tries
to write to the Nix store.
MESSAGE
export PATH=${lib.makeBinPath [ curl jq ]}:"\$PATH"
exec "$out/bin/.slack-wrapped" "\$@"
WRAPPER
chmod +x "$out/bin/slack"
'';
meta = {
@ -44,4 +45,4 @@ in stdenv.mkDerivation rec {
maintainers = [ lib.maintainers.qyliss ];
platforms = lib.platforms.unix;
};
}
}