Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/target
.env*
.cargo/config.toml
/logs/
/strace_*.txt
/flake.test-result.json
/test.shellcheck-result.txt
*~
/result
3 changes: 3 additions & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
the file /data/data/com.termux.nix/files/home/pick-up-nix2/nix/flakes/repo-data-flake/flake.nix is really in /data/data/com.termux.nix/files/home/ai-ml-zk-ops/flakes/repo-data-flakes/flake.nix
we created a ln -s /data/data/com.termux.nix/files/home/ai-ml-zk-ops/flakes /data/data/com.termux.nix/files/home/pick-up-nix2/nix/flakes
to find files grep ~/nix/index/
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

bootstrap :
bash ./test.sh

NIX_FLAKES := flake.nix
SH_SCRIPTS := $(shell find . -name "*.sh")

# Transform flake.nix paths to various result paths
TEST_RESULTS := $(patsubst %.nix,%.test-result.json,$(NIX_FLAKES))
RAW_DUMPS := $(patsubst %.nix,%.raw-dump.txt,$(NIX_FLAKES))
JSON_DUMPS := $(patsubst %.nix,%.json-dump.json,$(NIX_FLAKES))
LINT_RESULTS := $(patsubst %.nix,%.lint-result.txt,$(NIX_FLAKES))
EVAL_RESULTS := $(patsubst %.nix,%.eval-result.txt,$(NIX_FLAKES))
TWOGRAM_REPORTS := $(patsubst %.nix,%.2gram-report.txt,$(NIX_FLAKES))

# Transform .sh paths to .shellcheck-result.txt paths
SHELLCHECK_RESULTS := $(patsubst %.sh,%.shellcheck-result.txt,$(SH_SCRIPTS))

VERBOSE_LOGS := $(patsubst %.nix,%.verbose-log.txt,$(NIX_FLAKES))

.PHONY: all clean help

all: $(TEST_RESULTS) $(SHELLCHECK_RESULTS) $(RAW_DUMPS) $(JSON_DUMPS) $(LINT_RESULTS) $(EVAL_RESULTS) $(TWOGRAM_REPORTS) $(VERBOSE_LOGS)

%.verbose-log.txt: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/dump_flake_verbose_log.sh $< $@


all: $(TEST_RESULTS) $(SHELLCHECK_RESULTS) $(RAW_DUMPS) $(JSON_DUMPS) $(LINT_RESULTS) $(EVAL_RESULTS) $(TWOGRAM_REPORTS)

help:
@echo "For help with debugging flakes, see docs/tutorials/Debugging_Nix_Flakes.md"


%.test-result.json: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/build_test_result.sh $< $@

%.shellcheck-result.txt: %.sh
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/run_shellcheck.sh $< $@

%.raw-dump.txt: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/dump_flake_raw.sh $< $@

%.json-dump.json: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/dump_flake_json.sh $< $@

%.lint-result.txt: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/lint_flake.sh $< $@

%.eval-result.txt: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/eval_flake.sh $< $@

%.2gram-report.txt: %.nix
@bash /data/data/com.termux.nix/files/home/pick-up-nix2/source/github/meta-introspector/ai-ml-zk-ops/flakes/repo-data-flake/scripts/generate_2gram_report.sh $< $@

clean:
@echo "Cleaning up all generated files..."
$(RM) $(TEST_RESULTS) $(SHELLCHECK_RESULTS) $(RAW_DUMPS) $(JSON_DUMPS) $(LINT_RESULTS) $(EVAL_RESULTS) $(TWOGRAM_REPORTS)
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@ llm = { version = "1.2.4", features = ["openai", "anthropic", "ollama", "deepsee

More details in the [`api_example`](examples/api_example.rs)

## Nixification

This project can be built and developed using Nix flakes, ensuring a consistent and reproducible environment.

### Build with Nix

To build the project using Nix, run the following command from the project root:

```bash
nix build .#llm
```

This will build the `llm` package and place the resulting executable in `result/bin/llm`.

### Development Environment with Nix

To enter a development shell with the Rust toolchain and other necessary tools, run:

```bash
nix develop
```

Inside the development shell, you can use `cargo` commands as usual (e.g., `cargo build`, `cargo test`).

## More examples

| Name | Description |
Expand Down
64 changes: 64 additions & 0 deletions crq.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# CRQ-001: LLM Nixification of Rust Project

## 1. Overview

This Change Request outlines the process for Nixifying a Rust project, integrating it with the existing vendored Nix infrastructure. The primary goal is to ensure the Rust project can be built, tested, and deployed consistently using Nix flakes, leveraging vendored dependencies and adhering to project-specific Nixification standards.

## 2. Motivation

Consistent build environments, reproducible builds, and simplified dependency management are crucial for maintaining the quality and stability of our Rust projects. Nixification provides these benefits by encapsulating the entire build process and its dependencies within Nix flakes. This CRQ aims to apply these principles to a specific Rust project, setting a precedent for future Rust projects.

## 3. Scope

- **Target Project**: The Rust project specified in the initial task.
- **Nixification**: Create or update `flake.nix` and `flake.lock` files for the Rust project.
- **Dependency Management**: Utilize vendored Nix packages, specifically `naersk`, for Rust build processes.
- **Integration**: Ensure the Nixified Rust project integrates seamlessly with the main project's Nix flake structure.
- **Documentation**: Update relevant documentation (e.g., `README.md`, `docs/sops/`) to reflect the Nixification process and usage.

## 4. Technical Details

### 4.1. Vendored Nix Packages

- **Naersk**: The `naersk` Nix package will be used for building Rust projects. Reference: `~/nix2/./source/github/meta-introspector/git-submodules-rs-nix/naersk/`.
- **Nixpkgs**: All Nix flake references must use GitHub URLs, e.g., `github:meta-introspector/nixpkgs?ref=feature/CRQ-016-nixify`. Local paths are not permitted.
- **Naersk**: All Nix flake references must use GitHub URLs, e.g., `github:meta-introspector/naersk?ref=feature/CRQ-016-nixify`. Local paths are not permitted.
- **AI/ML ZK Ops**: The `github:meta-introspector/ai-ml-zk-ops?ref=feature/concept-to-nix-8s` flake input will be used.

### 4.2. Nix Flake Structure

The Rust project's `flake.nix` will define:
- `inputs`: References to `nixpkgs`, `naersk`, and `ai-ml-zk-ops`.
- `outputs`:
- `packages`: The Nixified Rust project's build output.
- `devShell`: A development environment with Rust toolchain and other necessary tools.

### 4.3. Build Process

The build process will leverage `naersk` to compile the Rust project within the Nix environment, ensuring all dependencies are correctly managed by Nix.

## 5. Acceptance Criteria

- The Rust project successfully builds using `nix build .#<package-name>`.
- A `devShell` is available and functional (`nix develop`).
- All Nix flake references adhere to the GitHub URL convention.
- The `flake.lock` file is up-to-date and reflects all vendored dependencies.
- Documentation is updated to guide future Nixification efforts for Rust projects.

## 6. Implementation Plan

1. **Identify Rust Project**: Determine the specific Rust project to be Nixified. (This is the current task's implicit target).
2. **Create `flake.nix`**: Generate an initial `flake.nix` for the Rust project, including `nixpkgs`, `naersk`, and `ai-ml-zk-ops` inputs.
3. **Configure `naersk`**: Set up `naersk` to build the Rust project.
4. **Define `devShell`**: Create a `devShell` with the necessary Rust toolchain and development dependencies.
5. **Test Build and Develop Environment**: Verify that `nix build` and `nix develop` work as expected.
6. **Update Documentation**: Document the Nixification process in relevant SOPs and tutorials.

## 7. References

- `~/nix2/./source/github/meta-introspector/git-submodules-rs-nix/naersk/`
- `nix_rust.txt` (if found)
- `github:meta-introspector/nixpkgs?ref=feature/CRQ-016-nixify`
- `github:meta-introspector/ai-ml-zk-ops?ref=feature/concept-to-nix-8s`
- `/data/data/com.termux.nix/files/home/nix/current-month/25/llm/task.md` (Original Task)
- /data/data/com.termux.nix/files/home/ai-ml-zk-ops/flakes/repo-data-flake copied the makefile and flake.nix from here, see if you can trim it down and get it to work. we want a lattice of flakes like that.
Loading