mirror of
https://github.com/Death916/nixconfig.git
synced 2026-04-10 02:54:39 -07:00
tmuxai
This commit is contained in:
parent
5f5d41fbf2
commit
e56e6b8684
1 changed files with 26 additions and 61 deletions
|
|
@ -4,105 +4,71 @@
|
|||
, fetchurl
|
||||
, autoPatchelfHook
|
||||
, makeWrapper
|
||||
# Add runtime dependencies of the binary if known/needed.
|
||||
# For a Go binary, it's often self-contained, but sometimes needs libc, libpthread.
|
||||
# These are usually part of stdenv.cc.cc.lib or glibc.
|
||||
# autoPatchelfHook will try to find them.
|
||||
, glibc # For basic C library dependencies
|
||||
# , tmux # tmux is a runtime dep, but typically installed separately by the user
|
||||
, glibc
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "tmuxai";
|
||||
version = "1.0.3"; # Current release
|
||||
|
||||
# Determine src based on system architecture
|
||||
# The install.sh script constructs the filename as:
|
||||
# ${PROJECT_NAME}_${os_raw}_${arch}.${archive_ext}
|
||||
# os_raw is `Linux` or `Darwin`. arch is `amd64` or `arm64`.
|
||||
# Example: tmuxai_Linux_amd64.tar.gz
|
||||
# For Linux x86_64 (amd64)
|
||||
srcFilename = if stdenv.isLinux && stdenv.hostPlatform.isx86_64 then
|
||||
"tmuxai_Linux_amd64.tar.gz"
|
||||
else if stdenv.isLinux && stdenv.hostPlatform.isAarch64 then
|
||||
"tmuxai_Linux_arm64.tar.gz"
|
||||
# Add more platform conditions if needed, e.g., for Darwin
|
||||
# else if stdenv.isDarwin && stdenv.hostPlatform.isx86_64 then
|
||||
# "tmuxai_Darwin_amd64.tar.gz"
|
||||
# else if stdenv.isDarwin && stdenv.hostPlatform.isAarch64 then
|
||||
# "tmuxai_Darwin_arm64.tar.gz"
|
||||
else throw "Unsupported platform for tmuxai precompiled binary: ${stdenv.hostPlatform.system}";
|
||||
|
||||
# For Linux x86_64:
|
||||
srcFilename = "${pname}_Linux_amd64.tar.gz";
|
||||
srcHash = "sha256-58770cf1f98badf0635e7f9ad05fbe31dde52557d20294a3a4fa01abcd1554eb"; # <-- TODO: GET HASH for tmuxai_Linux_amd64.tar.gz v1.0.3
|
||||
|
||||
# For Linux aarch64 (if you need it):
|
||||
# srcFilename = if stdenv.hostPlatform.system == "aarch64-linux"
|
||||
# then "${pname}_Linux_arm64.tar.gz"
|
||||
# else "${pname}_Linux_amd64.tar.gz";
|
||||
# srcHash = if stdenv.hostPlatform.system == "aarch64-linux"
|
||||
# then "sha256-yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy=" # <-- TODO: HASH for arm64
|
||||
# else "sha256-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx="; # <-- TODO: HASH for amd64
|
||||
srcHash = if stdenv.isLinux && stdenv.hostPlatform.isx86_64 then
|
||||
"sha256-916b390a283d415f9d303fd705cc162402ed071d616dbe7620ea683b49c28a4e" # From your tmuxsha256.txt for Linux amd64
|
||||
else if stdenv.isLinux && stdenv.hostPlatform.isAarch64 then
|
||||
"sha256-58770cf1f98badf0635e7f9ad05fbe31dde52557d20294a3a4fa01abcd1554eb" # From your tmuxsha256.txt for Linux arm64
|
||||
# else if stdenv.isDarwin && stdenv.hostPlatform.isx86_64 then
|
||||
# "sha256-41e880247972f86874aef4e60a77db93e2c2b47d857f1088b856af8e98f20d9d" # Darwin amd64
|
||||
# else if stdenv.isDarwin && stdenv.hostPlatform.isAarch64 then
|
||||
# "sha256-ff40f1c4605933507c8f65e3a694756740cc5b65b264457f9f454f1d9f00f8d9" # Darwin arm64
|
||||
else throw "Unsupported platform for tmuxai precompiled binary hash: ${stdenv.hostPlatform.system}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/alvinunreal/tmuxai/releases/download/v${version}/${srcFilename}";
|
||||
# The hash needs to be for the specific binary archive you download.
|
||||
# To get the hash:
|
||||
# 1. Go to: https://github.com/alvinunreal/tmuxai/releases/tag/v1.0.3
|
||||
# 2. Download the correct .tar.gz file (e.g., tmuxai_Linux_amd64.tar.gz)
|
||||
# 3. Run: nix-prefetch-url file:///path/to/downloaded/tmuxai_Linux_amd64.tar.gz
|
||||
# OR directly: nix-prefetch-url https://github.com/alvinunreal/tmuxai/releases/download/v1.0.3/tmuxai_Linux_amd64.tar.gz
|
||||
# 4. Copy the sha256 hash here.
|
||||
hash = srcHash;
|
||||
};
|
||||
|
||||
# autoPatchelfHook needs to know where to find the ELF files.
|
||||
# The binary is typically at the root of the tar.gz.
|
||||
sourceRoot = "."; # The binary is directly in the archive after extraction
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
makeWrapper # To potentially wrap the binary if needed later
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
# buildInputs are dependencies the binary might need at runtime.
|
||||
# For a typical Go binary, glibc might be enough.
|
||||
# autoPatchelfHook will use these to patch the RPATH.
|
||||
buildInputs = [
|
||||
glibc
|
||||
# If tmuxai dynamically links against other specific libraries, add them here.
|
||||
# e.g., if it used libcurl directly (unlikely for Go), you'd add pkgs.curl.
|
||||
# The .goreleaser.yml sets CGO_ENABLED=0, so it should be statically linked against Go libs,
|
||||
# but will still dynamically link against system C libraries like glibc, libpthread.
|
||||
];
|
||||
|
||||
# We don't need to build anything, just install the pre-compiled binary.
|
||||
# The install.sh script does `install -m755 "$binary_path" "$target_path"`
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
# The binary is named 'tmuxai' inside the archive.
|
||||
install -m755 -D tmuxai $out/bin/tmuxai
|
||||
|
||||
# If you need to wrap the binary to set environment variables (e.g., for API keys if not handled by user env)
|
||||
# or ensure tmux is found:
|
||||
# wrapProgram $out/bin/tmuxai \
|
||||
# --prefix PATH : ${lib.makeBinPath [ tmux ]} # Example: ensure tmux is in PATH for the binary
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# We are not building from source, so some Go-specific phases are not needed.
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontCheck = true; # No tests to run on a pre-compiled binary
|
||||
dontCheck = true;
|
||||
doCheck = false;
|
||||
|
||||
# Test phase: check if the binary runs and prints version
|
||||
# This is optional but good practice.
|
||||
# It uses the version embedded by goreleaser.
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
echo "Checking installed tmuxai version..."
|
||||
$out/bin/tmuxai version | grep "tmuxai version: v${version}"
|
||||
# The goreleaser config sets internal.Version to "v{{.Version}}"
|
||||
# So we grep for "v1.0.3" for example.
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
doInstallCheck = true;
|
||||
|
||||
|
||||
meta = with lib; {
|
||||
description = "Your intelligent pair programmer directly within your tmux sessions";
|
||||
longDescription = ''
|
||||
|
|
@ -114,8 +80,7 @@ stdenv.mkDerivation rec {
|
|||
homepage = "https://github.com/alvinunreal/tmuxai";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ "death916" ];
|
||||
platforms = platforms.linux; # The binaries are provided for Linux and Darwin
|
||||
# If you need macOS, you'd add another src/hash conditional block or a separate derivation.
|
||||
sourceProvenance = [แหล่งที่มา.binaryTarball inputs.src]; # Indicate it's a binary
|
||||
platforms = platforms.linux ++ platforms.darwin; # Reflects available binaries
|
||||
sourceProvenance = [ lib.sourceTypes.binaryTarball ]; # Corrected sourceProvenance
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue