Skip to content

chore: adds nix and nixflakes environment #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ Thumbs.db

.opencode/

# Nix specific files when running 'nix build'
result
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ yay -S opencode-bin
paru -S opencode-bin
```

### Using nix flakes

```bash
nix profile install 'github:opencode-ai/opencode'
```

### Using Go

```bash
Expand Down
35 changes: 35 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ pkgs ? import <nixpkgs> {} }:
let
lib = pkgs.lib;
in
pkgs.buildGoModule rec {
name = "opencode";
version = "0.0.34";

src = pkgs.fetchFromGitHub {
owner = "opencode-ai";
repo = "opencode";
tag = "v${version}";
hash = "sha256-EaspkL0TEBJEUU3f75EhZ4BOIvbneUKnTNeNGhJdjYE=";
};

vendorHash = "sha256-cFzkMunPkGQDFhQ4NQZixc5z7JCGNI7eXBn826rWEvk=";

checkFlags =
let
skippedTests = [
# permission denied
"TestBashTool_Run"
"TestSourcegraphTool_Run"
"TestLsTool_Run"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

meta = with lib; {
description = "A powerful terminal-based AI assistant for developers, providing intelligent coding assistance directly in your terminal.";
homepage = "https://github.com/opencode-ai/opencode";
mainProgram = "opencode";
license = licenses.mit;
};
}
60 changes: 60 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
description = "Opencode's nix flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
utils.url = "github:numtide/flake-utils";
};

outputs = { nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
defaultPkg = pkgs.callPackage ./default.nix {
inherit pkgs;
};
in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
# Development tools
go

# Aux tools
goreleaser
];
};

packages = {
default = defaultPkg;
};
});
}