feat(package): add nix package

This commit is contained in:
Horace Liu
2026-05-05 14:26:28 +08:00
parent abc8751d81
commit c13c80ac3d
4 changed files with 229 additions and 0 deletions
+4
View File
@@ -81,3 +81,7 @@ apps/
# Maintainer-internal design notes (trade-secret material, never published) # Maintainer-internal design notes (trade-secret material, never published)
.private/ .private/
# direnv
.envrc
.direnv
Generated
+66
View File
@@ -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
}
+103
View File
@@ -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);
};
}
+56
View File
@@ -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";
};
})