From 7efcc93e23ce98f45ef065d6c3a99488ea49d957 Mon Sep 17 00:00:00 2001 From: cristianoliveira Date: Mon, 28 Apr 2025 11:56:03 +0200 Subject: [PATCH 1/2] chore: adds nix and nixflakes environment --- .gitignore | 2 ++ default.nix | 38 +++++++++++++++++++++++++++++++++ flake.lock | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 2603e63..113bfa7 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ Thumbs.db .opencode/ +# Nix specific files when running 'nix build' +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..e06ee2e --- /dev/null +++ b/default.nix @@ -0,0 +1,38 @@ +{ pkgs ? import {} }: + 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; + maintainers = with maintainers; [ + zestsystem + ]; + }; + } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..db6d4fa --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1745833332, + "narHash": "sha256-KKNuFt4QqycQS7I4/FvYBTe/BNnhVVxJurjMv+Ab7Xs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4c022c908261f21431bfde61c95910ff2185a651", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..92c3e0d --- /dev/null +++ b/flake.nix @@ -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; + }; + }); +} From 75830591696e744d34eef16313a3ca0719922e66 Mon Sep 17 00:00:00 2001 From: cristianoliveira Date: Mon, 28 Apr 2025 12:30:37 +0200 Subject: [PATCH 2/2] docs: adds installing instruction to readme --- README.md | 6 ++++++ default.nix | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 75fe729..b2e9dcd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/default.nix b/default.nix index e06ee2e..b5bb749 100644 --- a/default.nix +++ b/default.nix @@ -31,8 +31,5 @@ homepage = "https://github.com/opencode-ai/opencode"; mainProgram = "opencode"; license = licenses.mit; - maintainers = with maintainers; [ - zestsystem - ]; }; }