Skip to content

Commit 901b387

Browse files
authored
chore(nix): add flake
chore(nix): add flake
2 parents dd5f967 + 9671e1e commit 901b387

9 files changed

Lines changed: 471 additions & 1 deletion

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake ./tools/nix --no-pure-eval
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
on:
2+
pull_request_target:
3+
paths:
4+
- '**.nix'
5+
steps:
6+
- uses: actions/checkout@v3
7+
- name: Install Nix
8+
uses: cachix/install-nix-action@v17
9+
with:
10+
extra_nix_config: |
11+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
12+
- name: Build dev shell
13+
run: nix develop --no-pure-eval --accept-flake-config "./tools/nix" --command "bash"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# nix
2+
.devenv/
3+
.direnv/
14
# project
25
.idea/
36
.vscode/

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ Langchain-powered natural language interface to RDF knowledge-graphs.
66
This repository uses `uv` for package management. A Makefile rule is provided to install the dependencies:
77

88
```bash
9-
make install
9+
just setup
1010
```
1111

12+
To start the nix-based development shell (linux-only), run:
13+
14+
```bash
15+
just dev
16+
``````
17+
1218
## Configuration
1319

1420
Configuration variables are loaded from the `.env` file or environment variables. A template configuration file is provided in `.env.example`.

justfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
set positional-arguments
2+
set dotenv-load
3+
set shell := ["bash", "-cue"]
4+
root_dir := `git rev-parse --show-toplevel`
5+
flake_dir := root_dir / "tools/nix"
6+
7+
# Manage nix flakes
8+
mod nix 'tools/just/nix.just'
9+
10+
[private]
11+
default:
12+
just --unsorted --list --no-aliases
13+
14+
alias dev := develop
15+
16+
# Enter a development shell.
17+
develop:
18+
just nix::develop default
19+
20+
# Set up python environment.
21+
setup:
22+
@echo "🔧 Setting up python environment"
23+
uv sync --all-extras --group dev
24+
uv run pre-commit install
25+
26+
27+
# Run all quality checks.
28+
check: setup
29+
@echo "🚀 Validating lock file"
30+
uv lock --check
31+
@echo "🚀 Running all pre-commit hooks"
32+
uv run pre-commit run -a
33+
34+
alias fmt := format
35+
# Format code.
36+
format *args: setup
37+
@echo "🚀 Formatting python code"
38+
uv run ruff format {{args}}
39+
40+
# Run unit tests.
41+
test *args: setup
42+
@echo "🚀 Testing code: Running pytest"
43+
@uv run pytest {{args}}

tools/just/nix.just

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set positional-arguments
2+
set dotenv-load
3+
set shell := ["bash", "-cue"]
4+
root_dir := `git rev-parse --show-toplevel`
5+
flake_dir := root_dir / "tools/nix"
6+
7+
## Nix Stuff ==================================================================
8+
# Show all packages configured in the Nix `flake.nix`.
9+
list *args:
10+
cd {{flake_dir}} && nix flake --no-pure-eval show
11+
12+
# Enter the Nix `devShell` with name `$1` and execute the command `${@:2}` (default command is '$SHELL')
13+
[private]
14+
develop *args:
15+
#!/usr/bin/env bash
16+
set -eu
17+
shell="$1"; shift 1;
18+
args=("$@") && [ "${#args[@]}" != 0 ] || args="$SHELL"
19+
cd {{root_dir}}
20+
nix develop --no-pure-eval --accept-flake-config \
21+
"{{flake_dir}}#$shell" --command "${args[@]}"
22+
## ============================================================================

tools/nix/flake.lock

Lines changed: 276 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)