about summary refs log tree commit diff
path: root/pkgs/tools/networking
diff options
context:
space:
mode:
authormatthewcroughan <matt@croughan.sh>2022-06-14 20:48:16 +0100
committermatthewcroughan <matt@croughan.sh>2022-06-15 09:18:52 +0100
commitb96b41d2a818c4b997b8e6a647b960a01c7f046c (patch)
treedbbec836891e5390d059aac4185d82ee76ee0e1d /pkgs/tools/networking
parent7a9920561983f35934bf43b61d101f05a8755fb1 (diff)
discord-sh: init at unstable-2022-05-19
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/tools/networking')
-rw-r--r--pkgs/tools/networking/discord-sh/default.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/pkgs/tools/networking/discord-sh/default.nix b/pkgs/tools/networking/discord-sh/default.nix
new file mode 100644
index 0000000000000..98696fad0780d
--- /dev/null
+++ b/pkgs/tools/networking/discord-sh/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenvNoCC, fetchFromGitHub, makeWrapper, curl, jq, coreutils }:
+
+stdenvNoCC.mkDerivation {
+  pname = "discord-sh";
+  version = "unstable-2022-05-19";
+
+  src = fetchFromGitHub {
+    owner = "ChaoticWeg";
+    repo = "discord.sh";
+    rev = "6aaea548f88eb48b7adeef824fbddac1c4749447";
+    sha256 = "sha256-RoPhn/Ot4ID1nEbZEz1bd2iq8g7mU2e7kwNRvZOD/pc=";
+  };
+
+  # ignore Makefile by disabling buildPhase. Upstream Makefile tries to download
+  # binaries from the internet for linting
+  dontBuild = true;
+
+  # discord.sh looks for the .webhook file in the source code directory, which
+  # isn't mutable on Nix
+  postPatch = ''
+    substituteInPlace discord.sh \
+      --replace 'thisdir="$(cd "$(dirname "$(readlink -f "''${BASH_SOURCE[0]}")")" && pwd)"' 'thisdir="$(pwd)"'
+  '';
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  doInstallCheck = true;
+
+  installCheckPhase = ''
+    runHook preCheck
+    $out/bin/discord.sh --help
+    runHook postCheck
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    install -Dm555 discord.sh $out/bin/discord.sh
+    wrapProgram $out/bin/discord.sh \
+      --set PATH "${lib.makeBinPath [ curl jq coreutils ]}"
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Write-only command-line Discord webhook integration written in 100% Bash script";
+    homepage = "https://github.com/ChaoticWeg/discord.sh";
+    license = licenses.gpl3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ matthewcroughan ];
+  };
+}