diff --git a/.gitignore b/.gitignore index ce9645a0..b53f8acf 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,7 @@ apps/ # Maintainer-internal design notes (trade-secret material, never published) .private/ + +# direnv +.envrc +.direnv diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 3503bd0c..f93bead7 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -138,7 +138,65 @@ is fastest from your network. --- -## 4. Manual download from GitHub Releases +## 4. Install via Nix + +**Try it** + +If you already have Nix with flake support, run: + +```sh +nix run github:Hmbown/DeepSeek-TUI +``` + +Nix builds `deepseek-tui` and then starts the `deepseek` dispatcher. Pass +arguments after `--`, for example: + +```sh +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 @@ -181,7 +239,7 @@ when you need the newest version immediately. --- -## 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. @@ -318,7 +376,7 @@ Both binaries appear in `target\release\deepseek.exe` and --- -## 6. Troubleshooting +## 7. Troubleshooting ### `Unsupported architecture: arm64 on platform linux` @@ -492,7 +550,7 @@ Use one of these paths: --- -## 7. Verifying your install +## 8. Verifying your install ```bash deepseek --version 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..fbe1d8a3 --- /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" + "x86_64-darwin" + "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 = [ + pkgs.rustToolchain + pkgs.rust-analyzer + pkgs.lldb + pkgs.pkg-config + pkgs.openssl + pkgs.python3 + self.formatter.${system} + ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ + pkgs.dbus + ]; + + env = { + # Required by rust-analyzer + RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library"; + } // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { + 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..96188471 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,68 @@ +{ + lib, + stdenv, + rustPlatform, + pkg-config, + autoPatchelfHook ? null, + openssl, + dbus ? null, + + # 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 + ] ++ lib.optionals stdenv.isLinux [ + autoPatchelfHook + ]; + + buildInputs = [ + openssl + ] ++ lib.optionals stdenv.isLinux [ + dbus.dev + dbus.lib + stdenv.cc.cc.lib + ]; + + nativeCheckInputs = [ + python3 + gitMinimal + cacert + ]; + + cargoBuildFlags = [ + "--package" + "deepseek-tui-cli" + "--package" + "deepseek-tui" + ]; + cargoTestFlags = finalAttrs.cargoBuildFlags ++ [ + "--lib" + "--bins" + ]; + + 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"; + }; +})