Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ jobs:

- name: Test
run: go test ./...
nix:
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- uses: actions/checkout@v7
- uses: cachix/install-nix-action@6b2916c41eac5735ac995c58c9e8561a78c42319 # v31
# Check that the flake is at least correct on all systems, does not run
# any builds
- name: Run nix flake check
run: |
nix flake check -vL --no-build --all-systems
# Checks get run during the nix build
- name: Nix build/test
run: |
nix build -vL .#clawscli --print-out-paths
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ claws.log
node_modules/
.claude
.gtrconfig

# Nix
result
result-*
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ go install github.com/clawscli/claws/cmd/claws@latest
docker run -it --rm -v ~/.aws:/home/claws/.aws:ro ghcr.io/clawscli/claws
```

### Nix

```bash
nix profile add github:clawscli/claws
# or run it without installing to a profile:
nix run github:clawscli/claws -- ...
```

## Quick Start

```bash
Expand Down
147 changes: 101 additions & 46 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,113 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;

indexionPlatform = {
"aarch64-darwin" = "darwin-arm64";
"x86_64-darwin" = "darwin-x64";
"aarch64-linux" = "linux-arm64";
"x86_64-linux" = "linux-x64";
}.${system} or (throw "indexion: unsupported system ${system}");

indexionHash = {
"darwin-arm64" = "1w3m4px4f5hjr0776rxf3682rizz909zrvsh8i115ig67n1riqq5";
"darwin-x64" = "0000000000000000000000000000000000000000000000000000";
"linux-arm64" = "0000000000000000000000000000000000000000000000000000";
"linux-x64" = "0y7dbkrxyr56kdz326hxpm6i3pljp2z4jpzv1mc5qqwrzqfgybbd";
}.${indexionPlatform};

# No upstream release binary for this platform yet (e.g. linux-arm64).
# Dummy hash = unsupported; drop indexion from the shell instead of failing.
indexionSupported = indexionHash != "0000000000000000000000000000000000000000000000000000";

indexion = pkgs.stdenvNoCC.mkDerivation {
pname = "indexion";
version = "0.16.0";
src = pkgs.fetchzip {
url = "https://github.com/trkbt10/indexion/releases/download/v0.16.0/indexion-${indexionPlatform}.tar.gz";
sha256 = indexionHash;
stripRoot = true;
};
installPhase = ''
mkdir -p $out/bin $out/share/indexion
cp indexion $out/bin/
cp -r kgfs $out/share/indexion/
'';
indexion =
let
indexionHashes = {
"aarch64-darwin" = "1w3m4px4f5hjr0776rxf3682rizz909zrvsh8i115ig67n1riqq5";
"x86_64-linux" = "0y7dbkrxyr56kdz326hxpm6i3pljp2z4jpzv1mc5qqwrzqfgybbd";
};
nodePlatform = pkgs.stdenv.targetPlatform.node;
indexionFile = "indexion-${nodePlatform.platform}-${nodePlatform.arch}.tar.gz";
in
pkgs.stdenvNoCC.mkDerivation (fa: {
pname = "indexion";
version = "0.16.0";
src = pkgs.fetchzip {
url = "https://github.com/trkbt10/${fa.pname}/releases/download/v${fa.version}/${indexionFile}";
sha256 = indexionHashes.${system} or (throw "indexion: unsupported system");
stripRoot = true;
};
installPhase = ''
mkdir -p $out/bin $out/share/indexion
cp indexion $out/bin/
cp -r kgfs $out/share/indexion/
'';
meta = {
platforms = builtins.attrNames indexionHashes;
};
});
in
{
packages = {
clawscli = pkgs.buildGoModule (fa: {
Comment thread
KaiSforza marked this conversation as resolved.
pname = "claws";
version = "git-${self.dirtyShortRev or self.shortRev}";
# Needs to be changed whenever dependencies are updated
vendorHash = "sha256-Ef/2Xs15E5noUYJk2J9k48g0kfTPB6v+D9uUHdOyya0=";
src =
let
inherit (pkgs.lib.fileset) toSource unions;
in
toSource {
root = ./.;
fileset = unions [
./go.mod
./go.sum
./cmd
./custom
./docs
./internal
./scripts
./testdata
];
};
# Note: only building `cmd/claws` does not run the checks properly
excludedPackages = [
"scripts/gen-imports"
];
ldflags = [
"-s"
"-w"
"-X main.version=${fa.version}"
];
# Replace these absolute path to echo with the nix path for testing
postPatch = ''
substituteInPlace internal/action/action_test.go \
--replace-warn '/bin/echo' '${pkgs.coreutils}/bin/echo'
'';
# Fix home to be a writable tmp directory for config tests
preCheck = ''
export HOME=$(mktemp -d)
'';
Comment thread
KaiSforza marked this conversation as resolved.
});
gen-imports = self.packages.${system}.clawscli.overrideAttrs (
f: p: {
pname = "gen-imports";
subPackages = p.excludedPackages or [ ];
excludedPackages = [ ];
}
);
default = self.packages.${system}.clawscli;
};
in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
go_1_25
go-task
gopls
golangci-lint
vhs
ttyd
nodejs
bash
] ++ lib.optionals indexionSupported [
indexion
];
packages =
with pkgs;
[
go_1_25
go-task
gopls
golangci-lint
vhs
ttyd
nodejs
bash
]
++ lib.optionals (builtins.elem pkgs.stdenv.targetPlatform.system indexion.meta.platforms) [
indexion
];

env.GOROOT = "${pkgs.go_1_25}/share/go";

Expand Down