slack-cli: warn when not using SLACK_CLI_TOKEN

This commit is contained in:
Alyssa Ross 2018-08-15 13:56:19 +01:00
parent dac2235c1a
commit e276965a16
No known key found for this signature in database
GPG Key ID: C4844408C0657052
3 changed files with 25 additions and 8 deletions

View File

@ -1,8 +1,11 @@
# 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.
# 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.
#
# There is no reason that we couldn't change the file path that slack-cli uses
# for token storage, except that it would make the Nix package inconsistent with
# upstream and other distributions.
{ stdenv, lib, fetchFromGitHub, makeWrapper, curl, jq }:
{ stdenv, fetchFromGitHub }:
stdenv.mkDerivation rec {
name = "slack-cli-${version}";
@ -15,13 +18,10 @@ stdenv.mkDerivation rec {
sha256 = "022yr3cpfg0v7cxi62zzk08vp0l3w851qpfh6amyfgjiynnfyddl";
};
nativeBuildInputs = [ makeWrapper ];
dontBuild = true;
installPhase = ''
mkdir -p "$out/bin"
cp src/slack "$out/bin"
wrapProgram "$out/bin/slack" --prefix PATH : ${lib.makeBinPath [ curl jq ]}
'';
}

View File

@ -0,0 +1,15 @@
{ lib, writeShellScriptBin, curl, jq }:
slack-cli:
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 ${slack-cli}/bin/slack "$@"
''

View File

@ -16695,7 +16695,9 @@ with pkgs;
slack = callPackage ../applications/networking/instant-messengers/slack { };
slack-cli = callPackage ../tools/networking/slack-cli { };
wrapSlackCli = callPackage ../tools/networking/slack-cli/wrapper.nix { };
slack-cli-unwrapped = callPackage ../tools/networking/slack-cli { };
slack-cli = wrapSlackCli slack-cli-unwrapped;
singularity = callPackage ../applications/virtualization/singularity { };