<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ohcnwiki.tellmey.fyi/index.php?action=history&amp;feed=atom&amp;title=Contributing%2FLocal_development%2FNix_development_environment</id>
	<title>Contributing/Local development/Nix development environment - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ohcnwiki.tellmey.fyi/index.php?action=history&amp;feed=atom&amp;title=Contributing%2FLocal_development%2FNix_development_environment"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=Contributing/Local_development/Nix_development_environment&amp;action=history"/>
	<updated>2026-07-06T05:19:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.4</generator>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=Contributing/Local_development/Nix_development_environment&amp;diff=466&amp;oldid=prev</id>
		<title>Admin: Add Navbox contributing (via update-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=Contributing/Local_development/Nix_development_environment&amp;diff=466&amp;oldid=prev"/>
		<updated>2026-07-06T04:22:09Z</updated>

		<summary type="html">&lt;p&gt;Add Navbox contributing (via update-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:52, 6 July 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 151:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 151:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;Commands run directly&#039;&#039;&#039; in the shell — there is no &amp;lt;code&amp;gt;docker compose exec&amp;lt;/code&amp;gt; indirection.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;Commands run directly&#039;&#039;&#039; in the shell — there is no &amp;lt;code&amp;gt;docker compose exec&amp;lt;/code&amp;gt; indirection.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;Versions are pinned&#039;&#039;&#039; by the flake (for example Python 3.13 and PostgreSQL 15 from the Nix store), so the toolchain is reproducible across machines.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;Versions are pinned&#039;&#039;&#039; by the flake (for example Python 3.13 and PostgreSQL 15 from the Nix store), so the toolchain is reproducible across machines.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Navbox contributing}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=Contributing/Local_development/Nix_development_environment&amp;diff=198&amp;oldid=prev</id>
		<title>Admin: OHC identity seed</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=Contributing/Local_development/Nix_development_environment&amp;diff=198&amp;oldid=prev"/>
		<updated>2026-07-04T23:07:27Z</updated>

		<summary type="html">&lt;p&gt;OHC identity seed&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Doc header&lt;br /&gt;
|type=guide&lt;br /&gt;
|domain=contributing&lt;br /&gt;
|title=Nix development environment&lt;br /&gt;
|order=3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Nix is an alternative to Docker Compose for backend development. Instead of running PostgreSQL, Redis, and MinIO inside containers, the Nix dev shell installs pinned versions of those services (and Python, ruff, and the build toolchain) from the Nix store and runs them directly on your host. Service data lives in a project-local &amp;lt;code&amp;gt;.nix-data/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
If you would rather use the standard Docker-based workflow, see the [[Contributing/Local development/Backend setup|backend setup guide]].&lt;br /&gt;
&lt;br /&gt;
{{Note|1=This environment is for backend (&amp;lt;code&amp;gt;care&amp;lt;/code&amp;gt;) development. It targets macOS and non-NixOS Linux — the automated setup script intentionally refuses to run on NixOS, which should use NixOS-specific configuration instead.}}&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;&amp;#039;&amp;#039;&amp;#039;Install Nix.&amp;#039;&amp;#039;&amp;#039; The Determinate Systems installer is preferred — it provides a cleaner install and hassle-free uninstallation:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;curl --proto &amp;#039;=https&amp;#039; --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;&amp;#039;&amp;#039;&amp;#039;Enable flakes.&amp;#039;&amp;#039;&amp;#039; Modern installers enable flakes automatically. If yours did not, add the following to &amp;lt;code&amp;gt;~/.config/nix/nix.conf&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;experimental-features = nix-command flakes&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;&amp;#039;&amp;#039;&amp;#039;Optional — install direnv&amp;#039;&amp;#039;&amp;#039; for automatic shell activation when you &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; into the repo:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;# macOS (Homebrew)&lt;br /&gt;
brew install direnv&lt;br /&gt;
&lt;br /&gt;
# Linux (varies by distribution)&lt;br /&gt;
sudo apt install direnv   # Ubuntu/Debian&lt;br /&gt;
sudo dnf install direnv   # Fedora&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Then, from the repo root:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;echo &amp;quot;use flake&amp;quot; &amp;gt; .envrc&lt;br /&gt;
direnv allow&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automated setup ==&lt;br /&gt;
&lt;br /&gt;
For a first-time setup, run the setup script from the repo root:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;./scripts/nix-dev-setup.sh&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script checks that Nix is installed and flakes are enabled, creates the Python virtual environment and installs dependencies, starts the services (PostgreSQL, Redis, MinIO), runs migrations, and optionally loads sample fixtures.&lt;br /&gt;
&lt;br /&gt;
== Quick start (manual) ==&lt;br /&gt;
&lt;br /&gt;
To set things up by hand, enter the dev shell and run the in-shell commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;nix develop&lt;br /&gt;
setup-dev&lt;br /&gt;
start-services&lt;br /&gt;
rundev&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This enters the development environment, installs Python dependencies into a &amp;lt;code&amp;gt;.venv&amp;lt;/code&amp;gt;, starts the background services, runs migrations, and launches the unified development server (Django API plus Celery worker).&lt;br /&gt;
&lt;br /&gt;
{{Tip|1=Background services persist between shell sessions. On later days you usually only need &amp;lt;code&amp;gt;nix develop&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;start-services&amp;lt;/code&amp;gt; (if not already running), then &amp;lt;code&amp;gt;rundev&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
== In-shell commands ==&lt;br /&gt;
&lt;br /&gt;
Once you are inside the dev shell (&amp;lt;code&amp;gt;nix develop&amp;lt;/code&amp;gt;), these commands are on your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Group&lt;br /&gt;
! Command&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| Services&lt;br /&gt;
| &amp;lt;code&amp;gt;start-services&amp;lt;/code&amp;gt;&lt;br /&gt;
| Start PostgreSQL, Redis, and MinIO&lt;br /&gt;
|-&lt;br /&gt;
| Services&lt;br /&gt;
| &amp;lt;code&amp;gt;stop-services&amp;lt;/code&amp;gt;&lt;br /&gt;
| Stop the background services only&lt;br /&gt;
|-&lt;br /&gt;
| Services&lt;br /&gt;
| &amp;lt;code&amp;gt;kill-care&amp;lt;/code&amp;gt;&lt;br /&gt;
| Stop all development processes and services&lt;br /&gt;
|-&lt;br /&gt;
| Server&lt;br /&gt;
| &amp;lt;code&amp;gt;rundev&amp;lt;/code&amp;gt;&lt;br /&gt;
| Start the API server and Celery worker together (recommended)&lt;br /&gt;
|-&lt;br /&gt;
| Server&lt;br /&gt;
| &amp;lt;code&amp;gt;runserver&amp;lt;/code&amp;gt;&lt;br /&gt;
| Start the Django development server only&lt;br /&gt;
|-&lt;br /&gt;
| Server&lt;br /&gt;
| &amp;lt;code&amp;gt;celery&amp;lt;/code&amp;gt;&lt;br /&gt;
| Start the Celery worker with beat scheduler only&lt;br /&gt;
|-&lt;br /&gt;
| Database&lt;br /&gt;
| &amp;lt;code&amp;gt;migrate&amp;lt;/code&amp;gt;&lt;br /&gt;
| Run database migrations&lt;br /&gt;
|-&lt;br /&gt;
| Database&lt;br /&gt;
| &amp;lt;code&amp;gt;load-fixtures&amp;lt;/code&amp;gt;&lt;br /&gt;
| Load sample data&lt;br /&gt;
|-&lt;br /&gt;
| Database&lt;br /&gt;
| &amp;lt;code&amp;gt;reset-db&amp;lt;/code&amp;gt;&lt;br /&gt;
| Drop and recreate the database&lt;br /&gt;
|-&lt;br /&gt;
| Testing&lt;br /&gt;
| &amp;lt;code&amp;gt;test&amp;lt;/code&amp;gt;&lt;br /&gt;
| Run the test suite (reuses the database)&lt;br /&gt;
|-&lt;br /&gt;
| Testing&lt;br /&gt;
| &amp;lt;code&amp;gt;test-coverage&amp;lt;/code&amp;gt;&lt;br /&gt;
| Run tests and produce a coverage report&lt;br /&gt;
|-&lt;br /&gt;
| Quality&lt;br /&gt;
| &amp;lt;code&amp;gt;ruff&amp;lt;/code&amp;gt;&lt;br /&gt;
| Lint and fix staged Python files&lt;br /&gt;
|-&lt;br /&gt;
| Quality&lt;br /&gt;
| &amp;lt;code&amp;gt;ruff-all&amp;lt;/code&amp;gt;&lt;br /&gt;
| Lint all Python files&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{Note|1=Additional helpers are available in the shell, including &amp;lt;code&amp;gt;makemigrations&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;manage &amp;amp;lt;command&amp;amp;gt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dump-db&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;load-db&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;clean-data&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;healthcheck&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;test-no-keep&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;ruff-fix-all&amp;lt;/code&amp;gt;. The dev shell prints the full list when you enter it.}}&lt;br /&gt;
&lt;br /&gt;
== Service URLs ==&lt;br /&gt;
&lt;br /&gt;
After &amp;lt;code&amp;gt;start-services&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rundev&amp;lt;/code&amp;gt; are up:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Service&lt;br /&gt;
! URL / address&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| Django application&lt;br /&gt;
| http://localhost:9000&lt;br /&gt;
| API and admin&lt;br /&gt;
|-&lt;br /&gt;
| MinIO console&lt;br /&gt;
| http://localhost:9001&lt;br /&gt;
| S3-compatible object storage UI&lt;br /&gt;
|-&lt;br /&gt;
| PostgreSQL&lt;br /&gt;
| &amp;lt;code&amp;gt;localhost:5432&amp;lt;/code&amp;gt;&lt;br /&gt;
| Database&lt;br /&gt;
|-&lt;br /&gt;
| Redis&lt;br /&gt;
| &amp;lt;code&amp;gt;localhost:6379&amp;lt;/code&amp;gt;&lt;br /&gt;
| Cache and Celery broker&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{Info|1=Default development credentials (for example the MinIO and database logins) are set automatically by the dev shell and are intended for local use only. Services bind to localhost and are not reachable externally.}}&lt;br /&gt;
&lt;br /&gt;
== How it differs from Docker ==&lt;br /&gt;
&lt;br /&gt;
The Nix workflow produces the same database schema, migrations, and Python dependency versions as the Docker setup — the two can coexist. The main differences:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Services run on the host&amp;#039;&amp;#039;&amp;#039;, not inside containers, so there is no container overhead and startup is faster.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Data lives in &amp;lt;code&amp;gt;.nix-data/&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;postgres/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;redis/&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;minio/&amp;lt;/code&amp;gt;) instead of Docker volumes. This directory is added to &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; automatically.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Commands run directly&amp;#039;&amp;#039;&amp;#039; in the shell — there is no &amp;lt;code&amp;gt;docker compose exec&amp;lt;/code&amp;gt; indirection.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Versions are pinned&amp;#039;&amp;#039;&amp;#039; by the flake (for example Python 3.13 and PostgreSQL 15 from the Nix store), so the toolchain is reproducible across machines.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>