diff --git a/pkgs/tools/networking/slack-cli/default.nix b/pkgs/tools/networking/slack-cli/default.nix index 2e20fbe2c3c9..ac7d0d4175c9 100644 --- a/pkgs/tools/networking/slack-cli/default.nix +++ b/pkgs/tools/networking/slack-cli/default.nix @@ -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 ]} ''; } diff --git a/pkgs/tools/networking/slack-cli/wrapper.nix b/pkgs/tools/networking/slack-cli/wrapper.nix new file mode 100644 index 000000000000..3612aaa137ee --- /dev/null +++ b/pkgs/tools/networking/slack-cli/wrapper.nix @@ -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 "$@" +'' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c2f1f212a520..f53b144cee9d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };