Not ready for use yet, no usable packages are exported from this repository
nix-task is a task/action runner that lets you use the Nix language to write simple tasks or entire CI/CD pipelines, as an alternative to tools like Make, Dagger, Taskfile, etc.
It is not a replacement of CI/CD runners like GitLab CI or GitHub Actions, and instead is designed to complement these tools by being called by CI/CD runners. This allows pipelines to be authored and run agnostic to any particular CI/CD runner.
See examples/nixMathHomework/flake.nix as an example.
Tasks will be collected recursively from the provided attr path, unless any attrset that is encountered has _nixTaskDontRecurseTasks
set to true.
nix-task.lib.mkTask({
# other tasks that this task is dependant on
deps =? [ other tasks ];
# nix packages that should be made available to the PATH for task execution
path =? [ nix pkgs here ];
# script to run for this task
run = string | { deps }: string;
# script to run when entering a shell using `nix-task shell`
shellHook ?= string | { deps }: string;
id =? string;
})
Returns the path to an output directory where output artifacts can be stored. For this directory to be available, artifacts = [ "output" "file" "names" "here" ];
needs to be set on the mkTask
.
Returns the path to your user home directory.
Sets <json>
as the output of this task, which can be used by other tasks that depend on this task.
Runs <command>
in the background of this task. Will be sent a SIGTERM when the task has finished and will wait for the process to gracefully terminate.
Runs <command>
when this task finishes either successfully or on error.
Dumps the deps and their outputs as JSON.
Licensed under the MIT License.
View the full license here.
This section outlines the conceptual integration of Solana blockchain events with Nix-managed AI workflows, facilitated by various Nix tasks and example flakes within this repository.
The proposed architecture involves:
- Solana Smart Contract: Emits observable events or modifies account state.
- Off-Chain Listener (e.g., Geyser/Polling): Monitors the Solana blockchain for these events.
- Nix Task Trigger: The listener, upon detecting an event, triggers a specific Nix task.
- Nix Flake Signatures: Solana event data can contain "signatures" (e.g., attribute paths, parameters) that guide which Nix task to execute or how.
- AI Interaction: Triggered Nix tasks interact with AI services.
- Nix Scheduler: Manages and executes Nix tasks based on triggers.
The following tasks have been created to demonstrate parts of this workflow:
tasks.gemini
: (Existing task) Represents a general Gemini CLI interaction.tasks.run-gemini-cli
: A task configured to run thegemini-cli
in non-interactive mode with an empty prompt, simulating automated AI interaction.- Usage:
nix run .#tasks.run-gemini-cli
- Usage:
tasks.solana-ai-trigger
: Simulates an AI interaction triggered by a Solana smart contract event. This task acts as a placeholder for actual AI API calls.- Usage:
nix run .#tasks.solana-ai-trigger
- Usage:
tasks.process-solana-nar
: Demonstrates how a Nix task can consume Solana data packaged as a NAR (Nix Archive) file. It expects theSOLANA_NAR_PATH
environment variable to point to the NAR file.- Usage:
SOLANA_NAR_PATH=/path/to/your/solana.nar nix run .#tasks.process-solana-nar
- Usage:
tasks.helius-block-processor
: Simulates an off-chain service polling the Helius API for Solana blocks. It represents the logic for fetching blockchain data and identifying derivations needed for the Nix build system.- Usage:
nix run .#tasks.helius-block-processor
- Usage:
tasks.solana-nix-trigger-interpreter
: Simulates the off-chain interpretation of Solana event data. It extracts a "Nix flake signature" (e.g., a flake attribute path) from theSOLANA_EVENT_DATA
environment variable and simulates triggering the corresponding Nix task.- Usage:
SOLANA_EVENT_DATA="some event data with my-task" nix run .#tasks.solana-nix-trigger-interpreter
- Usage:
examples/gemini-caller-flake
: A flake that demonstrates how to call therun-gemini-cli
task from an external flake. ItsdevShell
executes therun-gemini-cli
task upon entering the shell.- Usage:
nix develop ./examples/gemini-caller-flake
- Usage:
examples/gemini-input-flake
: A simple flake that consumes thegemini-caller-flake
, showcasing a chained flake dependency. ItsdevShell
re-exports thedevShell
fromgemini-caller-flake
.- Usage:
nix develop ./examples/gemini-input-flake
- Usage:
flakes/all-repos
: A "meta-flake" designed to aggregate multiple project repositories. It demonstrates how to include external repositories as inputs and can be extended to expose their packages or define combined development shells, laying the groundwork for managing a large number of interdependent projects within the Nix ecosystem.- Usage:
nix develop ./flakes/all-repos
(to enter a shell with aggregated packages) - Usage:
nix build ./flakes/all-repos#packages.example-package
(to build an example package from an aggregated repo)
- Usage:
To test the various components:
- Run individual tasks: Use
nix run .#tasks.<task-name>
with appropriate environment variables (e.g.,SOLANA_NAR_PATH
,SOLANA_EVENT_DATA
) as described above. - Test example flakes: Use
nix develop ./examples/<flake-name>
to enter their development shells and observe their behavior. - Test the meta-flake: Use
nix develop ./flakes/all-repos
to see the aggregated environment, ornix build ./flakes/all-repos#packages.example-package
to build a package from an aggregated repository.