1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-30 09:31:01 +00:00
nixpkgs/pkgs/tools/networking/slack-cli/default.nix
Jörg Thalheim dadc7eb329
treewide: use runtimeShell instead of stdenv.shell whenever possible
Whenever we create scripts that are installed to $out, we must use runtimeShell
in order to get the shell that can be executed on the machine we create the
package for. This is relevant for cross-compiling. The only use case for
stdenv.shell are scripts that are executed as part of the build system.
Usages in checkPhase are borderline however to decrease the likelyhood
of people copying the wrong examples, I decided to use runtimeShell as well.
2019-02-26 14:10:49 +00:00

49 lines
1.4 KiB
Nix

# 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, writeShellScriptBin, fetchFromGitHub, curl, jq, runtimeShell }:
stdenv.mkDerivation rec {
name = "slack-cli-${version}";
version = "0.18.0";
src = fetchFromGitHub {
owner = "rockymadden";
repo = "slack-cli";
rev = "v${version}";
sha256 = "022yr3cpfg0v7cxi62zzk08vp0l3w851qpfh6amyfgjiynnfyddl";
};
dontBuild = true;
installPhase = ''
mkdir -p "$out/bin"
cp src/slack "$out/bin/.slack-wrapped"
cat <<-WRAPPER > "$out/bin/slack"
#!${runtimeShell}
[ "\$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 = {
license = lib.licenses.mit;
maintainers = [ lib.maintainers.qyliss ];
platforms = lib.platforms.unix;
};
}