Skip to content

Commit d9c71f4

Browse files
Merge pull request #52 from y0usaf/feat/nix-flake-and-hash-updater
feat(nix): add flake package and automated source hash updates
2 parents aa14d18 + 23aaa5d commit d9c71f4

File tree

8 files changed

+250
-1
lines changed

8 files changed

+250
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update Nix Sources
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 9 * * 1"
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
20+
- name: Install Nix
21+
uses: cachix/install-nix-action@v31
22+
23+
- name: Update nix sources
24+
run: ./scripts/update-nix-sources.sh
25+
26+
- name: Create pull request
27+
uses: peter-evans/create-pull-request@v7
28+
with:
29+
commit-message: "chore(nix): update release hashes"
30+
title: "chore(nix): update release hashes"
31+
body: |
32+
Automated update of `nix/sources.json` from the latest GitHub release checksums.
33+
branch: chore/update-nix-sources
34+
delete-branch: true

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ OR npm global install (requires Node >= 22.5):
2323
npm i -g agent-slack
2424
```
2525

26+
OR run via Nix flake:
27+
28+
```bash
29+
nix run github:stablyai/agent-slack
30+
```
31+
2632
## At a glance
2733

2834
- **Read**: fetch a message, browse channel history, list full threads

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
description = "agent-slack: Slack automation CLI for AI agents";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = {
10+
self,
11+
nixpkgs,
12+
flake-utils,
13+
}:
14+
flake-utils.lib.eachDefaultSystem (system: let
15+
pkgs = import nixpkgs {inherit system;};
16+
agent-slack = pkgs.callPackage ./nix/package.nix {};
17+
in {
18+
packages = {
19+
inherit agent-slack;
20+
default = agent-slack;
21+
};
22+
23+
apps = {
24+
default = flake-utils.lib.mkApp {
25+
drv = agent-slack;
26+
name = "agent-slack";
27+
};
28+
};
29+
});
30+
}

nix/package.nix

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{lib, fetchurl, stdenvNoCC}:
2+
let
3+
sources = builtins.fromJSON (builtins.readFile ./sources.json);
4+
5+
assetBySystem = {
6+
aarch64-darwin = "agent-slack-darwin-arm64";
7+
x86_64-darwin = "agent-slack-darwin-x64";
8+
aarch64-linux = "agent-slack-linux-arm64";
9+
x86_64-linux = "agent-slack-linux-x64";
10+
};
11+
12+
system = stdenvNoCC.hostPlatform.system;
13+
14+
asset =
15+
assetBySystem.${system}
16+
or (throw "agent-slack: unsupported system '${system}'");
17+
18+
hash =
19+
sources.hashes.${system}
20+
or (throw "agent-slack: missing hash for system '${system}' in nix/sources.json");
21+
in
22+
stdenvNoCC.mkDerivation {
23+
pname = "agent-slack";
24+
inherit (sources) version;
25+
26+
src = fetchurl {
27+
url = "https://github.com/stablyai/agent-slack/releases/download/v${sources.version}/${asset}";
28+
inherit hash;
29+
};
30+
31+
dontUnpack = true;
32+
33+
installPhase = ''
34+
runHook preInstall
35+
install -Dm755 "$src" "$out/bin/agent-slack"
36+
runHook postInstall
37+
'';
38+
39+
meta = {
40+
description = "Slack automation CLI for AI agents";
41+
homepage = "https://github.com/stablyai/agent-slack";
42+
license = lib.licenses.mit;
43+
platforms = builtins.attrNames assetBySystem;
44+
mainProgram = "agent-slack";
45+
sourceProvenance = with lib.sourceTypes; [binaryNativeCode];
46+
};
47+
}

nix/sources.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": "0.5.2",
3+
"hashes": {
4+
"aarch64-darwin": "sha256-/amxMaLwMxmfyHqUZn8bKd6/bjrx/glCSzLSbFs+kKk=",
5+
"x86_64-darwin": "sha256-w/uvefbqwaeiAsTSGt4VxY/VYWkFVQokQkjyIcL2EDw=",
6+
"aarch64-linux": "sha256-CvpfyhuwI1V4XPSM6tiATq7h2tNHeK/Q1Ohwyq1ZFNw=",
7+
"x86_64-linux": "sha256-7C+Z6CgXsagfgo+RPIj9dz7edwwzcqgpX2aJmRs2Xuc="
8+
}
9+
}

scripts/update-nix-sources.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo="stablyai/agent-slack"
5+
latest_api="https://api.github.com/repos/${repo}/releases/latest"
6+
7+
if ! command -v jq >/dev/null 2>&1; then
8+
echo "error: jq is required" >&2
9+
exit 1
10+
fi
11+
12+
if ! command -v nix >/dev/null 2>&1; then
13+
echo "error: nix is required" >&2
14+
exit 1
15+
fi
16+
17+
tag="$(curl -fsSL "$latest_api" | jq -r '.tag_name')"
18+
if [[ -z "$tag" || "$tag" == "null" ]]; then
19+
echo "error: unable to resolve latest release tag" >&2
20+
exit 1
21+
fi
22+
23+
version="${tag#v}"
24+
checksums_url="https://github.com/${repo}/releases/download/${tag}/checksums-sha256.txt"
25+
checksums="$(curl -fsSL "$checksums_url")"
26+
27+
get_sri() {
28+
local asset="$1"
29+
local hex
30+
hex="$(awk -v asset="$asset" '$2 == asset { print $1 }' <<<"$checksums")"
31+
32+
if [[ -z "$hex" ]]; then
33+
echo "error: missing checksum for ${asset}" >&2
34+
exit 1
35+
fi
36+
37+
nix hash convert --hash-algo sha256 --to sri "$hex"
38+
}
39+
40+
arm64_darwin="$(get_sri agent-slack-darwin-arm64)"
41+
x64_darwin="$(get_sri agent-slack-darwin-x64)"
42+
arm64_linux="$(get_sri agent-slack-linux-arm64)"
43+
x64_linux="$(get_sri agent-slack-linux-x64)"
44+
45+
jq -n \
46+
--arg version "$version" \
47+
--arg aarch64_darwin "$arm64_darwin" \
48+
--arg x86_64_darwin "$x64_darwin" \
49+
--arg aarch64_linux "$arm64_linux" \
50+
--arg x86_64_linux "$x64_linux" \
51+
'{
52+
version: $version,
53+
hashes: {
54+
"aarch64-darwin": $aarch64_darwin,
55+
"x86_64-darwin": $x86_64_darwin,
56+
"aarch64-linux": $aarch64_linux,
57+
"x86_64-linux": $x86_64_linux
58+
}
59+
}' > nix/sources.json
60+
61+
echo "Updated nix/sources.json to ${version}"

skills/agent-slack/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ description: |
1515

1616
# Slack automation with `agent-slack`
1717

18-
`agent-slack` is a CLI binary installed on `$PATH`. Invoke it directly (e.g. `agent-slack user list`)
18+
`agent-slack` is a CLI binary installed on `$PATH`. Invoke it directly (e.g. `agent-slack user list`).
19+
If installed via Nix flake only, run commands with `nix run github:stablyai/agent-slack -- <args>`.
1920

2021
## Quick start (auth)
2122

0 commit comments

Comments
 (0)