From c13c80ac3dae637cdf0d31dcf371a0f549b67455 Mon Sep 17 00:00:00 2001 From: Horace Liu Date: Tue, 5 May 2026 14:26:28 +0800 Subject: [PATCH 1/4] feat(package): add nix package --- .gitignore | 4 ++ flake.lock | 66 +++++++++++++++++++++++++++++++ flake.nix | 103 ++++++++++++++++++++++++++++++++++++++++++++++++ nix/package.nix | 56 ++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix diff --git a/.gitignore b/.gitignore index 90595039..3dbbcbab 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,7 @@ apps/ # Maintainer-internal design notes (trade-secret material, never published) .private/ + +# direnv +.envrc +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..eb24d0db --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1777884425, + "narHash": "sha256-MzIEqXcx2EzJXOqrGETHFlzx6aGP2NhLVLxrM+ej41s=", + "owner": "nix-community", + "repo": "fenix", + "rev": "18454832b8f5d6cb33910382defc793dd78306f2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1777578337, + "narHash": "sha256-Ad49moKWeXtKBJNy2ebiTQUEgdLyvGmTeykAQ9xM+Z4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "15f4ee454b1dce334612fa6843b3e05cf546efab", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1777843182, + "narHash": "sha256-AO068PumYkLmubBSjlEQKAsnhVdF1Es7NC25X3KmuOw=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f04c37286472e3687a2d32d3d1fad2772de515a1", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..3716bd08 --- /dev/null +++ b/flake.nix @@ -0,0 +1,103 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + self, + fenix, + ... + }@inputs: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + forEachSystem = + f: + inputs.nixpkgs.lib.genAttrs systems ( + system: + f { + inherit system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + inputs.self.overlays.default + ]; + }; + } + ); + rev = self.shortRev or self.dirtyShortRev or "dirty"; + in + { + packages = forEachSystem ( + { pkgs, system }: + { + default = self.packages.${system}.deepseek-tui; + deepseek-tui = pkgs.callPackage ./nix/package.nix { + inherit rev; + rustPlatform = pkgs.makeRustPlatform { + cargo = pkgs.rustToolchain; + rustc = pkgs.rustToolchain; + }; + }; + } + ); + + overlays.default = final: prev: { + rustToolchain = + with fenix.packages.${prev.stdenv.hostPlatform.system}; + combine ( + with stable; + [ + rustc + cargo + clippy + rustfmt + rust-src + ] + ); + }; + + devShells = forEachSystem ( + { pkgs, system }: + { + default = pkgs.mkShell { + packages = with pkgs; [ + rustToolchain + rust-analyzer + lldb + + pkg-config + openssl + dbus + python3 + + self.formatter.${system} + ]; + + env = { + # Required by rust-analyzer + RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library"; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ( + with pkgs; + [ + openssl + dbus + ] + ); + }; + }; + } + ); + + formatter = forEachSystem ({ pkgs, ... }: pkgs.nixfmt); + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 00000000..4d306b4c --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,56 @@ +{ + lib, + rustPlatform, + pkg-config, + openssl, + dbus, + + # for cargo test + python3, + gitMinimal, + cacert, + + rev ? "dirty", +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "deepseek-tui"; + version = "git-${rev}"; + + src = ../.; + + cargoLock = { + lockFile = ../Cargo.lock; + }; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ + openssl + dbus + ]; + + nativeCheckInputs = [ + python3 + gitMinimal + cacert + ]; + + cargoBuildFlags = [ + "--package" + "deepseek-tui-cli" + "--package" + "deepseek-tui" + ]; + cargoTestFlags = finalAttrs.cargoBuildFlags; + + preCheck = '' + export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt + ''; + + meta = { + description = "Coding agent for DeepSeek models that runs in your terminal"; + homepage = "https://github.com/Hmbown/DeepSeek-TUI"; + license = lib.licenses.mit; + mainProgram = "deepseek"; + }; +}) From b9890aa77ac433fba7ca155e2451d9402907e940 Mon Sep 17 00:00:00 2001 From: Horace Liu Date: Tue, 5 May 2026 14:30:20 +0800 Subject: [PATCH 2/4] docs(install): add nix section --- docs/INSTALL.md | 63 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 98ed4427..385b74f6 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -129,7 +129,62 @@ is fastest from your network. --- -## 4. Manual download from GitHub Releases +## 4. Install via Nix + +**Try it** + +If you already have Nix setup with flake support, you can try out `deepseek-tui` with the nix run command: + +```sh +nix run github:Hmbown/DeepSeek-TUI +``` + +Nix will build `deepseek-tui` and run it. + +If you want to pass arguments this way, use e.g. `nix run github:Hmbown/DeepSeek-TUI -- --help`. + +### Flake + +Add inputs to `flake.nix` + +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + deepseek-tui.url = "github:Hmbown/DeepSeek-TUI"; + deepseek-tui.inputs.nixpkgs.follows = "nixpkgs"; + }; +} +``` + +Install into a NixOS Module + +```nix +{ + outputs = { self, nixpkgs, deepseek-tui }: + let + # replace system "x86_64-linux" with your system + system = "x86_64-linux"; + in + { + # change `yourhostname` to your actual hostname + nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + # ... + { + environment.systemPackages = [ deepseek-tui.packages.${system}.default ]; + } + ]; + }; + }; +} +``` + +--- + +## 5. Manual download from GitHub Releases Grab the matching pair of binaries for your platform from the [Releases page](https://github.com/Hmbown/DeepSeek-TUI/releases) and drop them @@ -158,7 +213,7 @@ curl -L -o /tmp/deepseek-artifacts-sha256.txt \ --- -## 5. Build from source +## 6. Build from source This is the catch-all for any platform we don't ship — including musl, riscv64, LoongArch, FreeBSD, and pre-2024 ARM64 distros. @@ -295,7 +350,7 @@ Both binaries appear in `target\release\deepseek.exe` and --- -## 6. Troubleshooting +## 7. Troubleshooting ### `Unsupported architecture: arm64 on platform linux` @@ -404,7 +459,7 @@ target/debug/build/libsqlite3-sys-*/build-script-build --- -## 7. Verifying your install +## 8. Verifying your install ```bash deepseek --version From 7cb04b7d0cb45d1302690ebab6acbadb6b304466 Mon Sep 17 00:00:00 2001 From: Horace Liu Date: Tue, 5 May 2026 15:13:52 +0800 Subject: [PATCH 3/4] fix(nix): replace dbus with dbus.lib --- nix/package.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nix/package.nix b/nix/package.nix index 4d306b4c..2771cad2 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -22,11 +22,14 @@ rustPlatform.buildRustPackage (finalAttrs: { lockFile = ../Cargo.lock; }; - nativeBuildInputs = [ pkg-config ]; + nativeBuildInputs = [ + pkg-config + dbus + ]; buildInputs = [ openssl - dbus + dbus.lib ]; nativeCheckInputs = [ From 5c917880689a5a0146630216ba2b516f1874094f Mon Sep 17 00:00:00 2001 From: ~horin Date: Tue, 5 May 2026 16:31:22 +0800 Subject: [PATCH 4/4] fix(nix): failed to load lib (#1) --- nix/package.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nix/package.nix b/nix/package.nix index 2771cad2..e606bf74 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,7 +1,9 @@ { lib, + stdenv, rustPlatform, pkg-config, + autoPatchelfHook, openssl, dbus, @@ -24,12 +26,14 @@ rustPlatform.buildRustPackage (finalAttrs: { nativeBuildInputs = [ pkg-config - dbus + autoPatchelfHook ]; buildInputs = [ openssl + dbus.dev dbus.lib + stdenv.cc.cc.lib ]; nativeCheckInputs = [ @@ -44,7 +48,10 @@ rustPlatform.buildRustPackage (finalAttrs: { "--package" "deepseek-tui" ]; - cargoTestFlags = finalAttrs.cargoBuildFlags; + cargoTestFlags = finalAttrs.cargoBuildFlags ++ [ + "--lib" + "--bins" + ]; preCheck = '' export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt