Skip to content

Commit d6ba37c

Browse files
authored
Add a development setup using nix (#372)
* Add nix development setup Uses poetry2nix to create a python environment from the poetry lock file. Defines two setups for external services: a nixos vm or a nixos container (the latter works only on nixos systems). The environment provides scripts to easily start the vm or container on demand. * Read config values for tests from environment Allows to configure external services (postgres, spicedb) not only for localhost.
1 parent d118c3a commit d6ba37c

File tree

5 files changed

+498
-9
lines changed

5 files changed

+498
-9
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,11 @@ target/
7171
# docker compose
7272
docker-compose.override.yml
7373
.devcontainer/.poetry_cache
74+
75+
# direnv
76+
.direnv/
77+
.envrc
78+
79+
# nix
80+
result
81+
*.qcow2

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ details.
2121

2222
1. `poetry install`
2323
2. `pre-commit install` to install pre commit hooks
24-
3. `DUMMY_STORES=true poetry run python bases/renku_data_services/data_api/main.py --debug --dev --fast`
24+
3. `make run` to run the server
2525

2626
## Developing
2727

@@ -36,6 +36,31 @@ The container image can be built to be used as a local development service (for
3636

3737
It can then be run as daemon: `docker run -d -e DUMMY_STORES=true --name renku-crc renku-data-service`
3838

39+
### Developing with nix
40+
41+
When using [nix](https://nixos.org/explore/), a development
42+
environment can be created:
43+
44+
1. Run `nix develop` in the source root to drop into the development
45+
environment.
46+
2. In another terminal, run `vm-run` (headless) to start a vm running
47+
necessary external services, like the postgresql database.
48+
3. Potentially run `poetry-fix-cfg` to alter the `pyvenv.cfg` so that
49+
poetry will use the env built by nix
50+
51+
Then `make run`, `make tests` etc can be used as usual.
52+
53+
The environment also contains other useful tools, like ruff-lsp,
54+
pyright and more. Instead of a vm, a development environment using
55+
NixOS containers is also available.
56+
57+
The first invocation will take a while for the first run, as the
58+
python environment is being built. Subsequent calls are then instant.
59+
60+
It will run a bash shell, check out [direnv](https://direnv.net/) and
61+
the [use flake](https://direnv.net/man/direnv-stdlib.1.html#codeuse-flake-ltinstallablegtcode)
62+
function if you prefer to keep your favorite shell.
63+
3964
## Migrations
4065

4166
We use Alembic for migrations and we have a single version table for all schemas. This version table

flake.lock

Lines changed: 258 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)