A modular Nix flake providing development environments for multiple programming languages, built around the NixOS + direnv workflow: each project folder gets its own isolated toolchain (language servers, formatters, linters, dependency management) with no containers or VMs โ the Nix store deduplicates everything.
- Per-Folder Isolation:
use flakein a project's.envrcactivates exactly the toolchain that project needs - Editor Integration: Automatic
.vscode/settings.jsonand.zed/settings.jsongeneration; LSP servers resolve through the project's direnv environment, so they work regardless of how the editor was launched. - Automatic Dependency Management: Detects dependency files and installs/syncs them (poetry/pip, cargo, pub, maven)
- Sane
TERMfallback: Restoresxterm-256colorwhen the parent environment reportsTERM=dumb, so Starship and other prompt tools keep working - Language-Aware Tools: Includes language servers, formatters, and linters
- Project Scaffolding:
nix flake init -t devshell#<lang>creates a ready-to-use project - Cross-Platform: Supports x86_64-linux and aarch64-linux
# Scaffold + direnv allow in one step, then prints the next steps
nix run github:zz0-0/devshell#new -- python myprojOr by hand:
# 1. Scaffold a project (creates flake.nix + .envrc + .gitignore)
nix flake init -t github:zz0-0/devshell#python
# 2. Enable direnv
direnv allowThat's it. Entering the directory now gives you a Python environment with pyright/ruff, auto-venv, and automatic dependency installation โ isolated to that folder.
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devshell.url = "github:zz0-0/devshell";
};
outputs = { self, nixpkgs, devshell }: {
# Supported systems: x86_64-linux, aarch64-linux
devShells.x86_64-linux.default = devshell.lib.x86_64-linux.python { };
};
}echo "use flake" > .envrc && direnv allowOr without direnv: nix develop to enter the shell interactively.
The flake also exposes devShells.default with the Nix tooling (nixd,
nil, nixfmt, statix, deadnix) for editing this repository itself.
Run direnv allow here once if you want it loaded automatically.
| Language | Function | Tools Included |
|---|---|---|
| Python | devshell.lib.<system>.python |
python3, pip, poetry, ruff, basedpyright |
| Rust | devshell.lib.<system>.rust |
cargo, rustc, rust-analyzer, rustfmt, clippy, lldb |
| Bevy | devshell.lib.<system>.bevy |
Rust toolchain + ALSA, udev, Vulkan, X11/Wayland, Mesa, mold, cargo-nextest |
| Flutter | devshell.lib.<system>.flutter |
flutter, android-sdk, jdk17, gradle, cmake, chromium |
| LaTeX | devshell.lib.<system>.latex |
texlive (scheme-medium + latexextra), texlab, pandoc, ghostscript |
| Nix | devshell.lib.<system>.nix |
nil, nixd, statix, nixfmt, deadnix |
| Markdown | devshell.lib.<system>.markdown |
markdown-oxide |
| PostgreSQL | devshell.lib.<system>.postgresql |
postgresql + start_pg/stop_pg/reset_pg helpers |
| Java | devshell.lib.<system>.java |
jdk25, jdt-language-server, maven, gradle |
| Video | devshell.lib.<system>.video |
ffmpeg, Chromium, Node, Python, uv, media CLI, Whisper, Assimp |
| Web | devshell.lib.<system>.web |
node, Chromium, web-check๏ผๆๅ HTML/CSS ็ๆบๆขฐ้๏ผ |
lib.<system>.<lang>โโ ็จณๅฎใๅๆฐ่งๅ่ฏญ่จๆไปถๅคด้จใpackages.<system>.web-checkโโ ๅไธชๆฃๆฅ๏ผๅฏไปฅๆๅฐไปปไฝ่ฏญ่จไธ๏ผextraPackages๏ผ๏ผไธๅฟ ๆๆดๅฅ web ๅทฅๅ ท้พใtemplates/<lang>โโ ็จณๅฎใๆจกๆฟ็ๆ็ๆไปถไน็ฎๆฅๅฃใlanguages/ใscripts/โโ ๅ ้จๅฎ็ฐ๏ผๅฏ่ฝๅใ
ๅ่ฏญ่จๅ ทไฝ่ฃ ไบไปไนใไพ่ตๆไนๅๆญฅ๏ผ่ง docs/languages.mdใ
# Add extra packages to any environment
devShells.x86_64-linux.default = devshell.lib.x86_64-linux.python {
extraPackages = [ pkgs.redis ];
};
# Flutter with emulator support
devShells.x86_64-linux.default = devshell.lib.x86_64-linux.flutter {
withEmulator = true;
};
# Choose a different Python or JDK
devShells.x86_64-linux.default = devshell.lib.x86_64-linux.python {
python = pkgs.python312;
};
devShells.x86_64-linux.default = devshell.lib.x86_64-linux.java {
jdk = pkgs.jdk21;
};.devshell/
โโโ flake.nix # Main flake configuration (lib, formatter, checks, templates)
โโโ languages/
โ โโโ common.nix # Shared helpers (LSP wrappers, settings writers)
โ โโโ python.nix # Python development environment
โ โโโ rust.nix # Rust development environment
โ โโโ bevy.nix # Bevy game development environment
โ โโโ flutter.nix # Flutter development environment
โ โโโ latex.nix # LaTeX development environment
โ โโโ nix.nix # Nix development tools
โ โโโ markdown.nix # Markdown tooling
โ โโโ postgresql.nix # PostgreSQL development environment
โ โโโ java.nix # Java development environment
โ โโโ video.nix # Video production environment
โโโ web.nix # Static web project
โโโ templates/ # `nix flake init -t` scaffolds (one dir per language)
When you enter a devshell, it automatically creates (project-local, gitignored):
.vscode/settings.jsonโ VS Code configuration (language server paths, formatters).zed/settings.jsonโ Zed configuration.zed/lsp/โ LSP wrapper scripts resolving throughdirenv exec.venv/โ Python virtual environment (Python shells).dart_tool/โ Flutter cache and stamp files.postgres/โ PostgreSQL data directory (PostgreSQL shells).bin/โ Symlinks to Nix tools (Nix shell)target/โ Rust build directory
All files are regenerated idempotently: nothing is wiped on updates, and files are only rewritten when their content actually changed.
- direnv +
use flakeis the core mechanism: entering a project directory loads itsdevShells.default, soPATHand environment variables come from the Nix store and are scoped to that folder. - LSP wrappers (
languages/common.nix) resolve the project root from their own location and run the language server viadirenv exec, so Zed/VS Code always use the exact toolchain of the project โ even when launched from outside the shell. - Hash stamps skip expensive operations (venv install,
cargo fetch,flutter pub get, maven fetch) until the dependency files actually change.
Shells can be combined for multi-language projects; each shell writes a Zed
settings fragment (.zed/lsp-config/<lang>.json) and they are deep-merged
into .zed/settings.json:
devShells.${system}.default = pkgs.mkShellNoCC {
buildInputs = nixShell.buildInputs ++ markdownShell.buildInputs;
shellHook = ''
${nixShell.shellHook}
${markdownShell.shellHook}
'';
};Video can be combined the same way:
let
pythonShell = devshell.lib.${system}.python { };
rustShell = devshell.lib.${system}.rust { };
videoShell = devshell.lib.${system}.video { };
in
devShells.${system}.default = pkgs.mkShellNoCC {
buildInputs = pythonShell.buildInputs ++ rustShell.buildInputs ++ videoShell.buildInputs;
shellHook = ''
${pythonShell.shellHook}
${rustShell.shellHook}
${videoShell.shellHook}
'';
};Note: .vscode/settings.json can only hold one language's configuration โ the
last shell in the hook wins there. Zed settings merge correctly for all shells.
nix flake check evaluates every language shell and builds the lightweight
nix and markdown shells. The heavy language shells (Flutter, LaTeX, video,
PostgreSQL, Java) are eval-only so the check stays practical. There is no cloud
CI; pre-push runs the checks locally. A fresh clone needs ./scripts/setup.sh
once to point git at .githooks/.
ๆจกๆฟไนๆฏๅ ฌๅ ฑๆฅๅฃ๏ผๅ็ฌๅ็๏ผๅคๅถๅฐไธดๆถ็ฎๅฝ๏ผ็็่ฟไธๆฌก shell๏ผ๏ผ
./scripts/check-templates.sh # ๅ
จ้จ๏ผ้ฆๆฌก็บฆ 1-2 ๅ้
./scripts/check-templates.sh x86_64-linux rust # ๆๅฎๆจกๆฟ
EVAL_ONLY=1 ./scripts/check-templates.sh # ๅชๅฎไพๅ๏ผไธๆๅปบๅ ฌๅ ฑๆฅๅฃ็ๅๆฐๅไนไธ่ฝๅ๏ผ
./scripts/check-interface.sh # ๅฏนๆฏ interface.json
./scripts/check-interface.sh --update # ็กฎ่ฎคๆฏๆๆ็็ ดๅๆงๅๆดๅ๏ผ้ๅๅบ็บฟๆๆกฃ้็่ทฏๅพๅผ็จ๏ผ
./scripts/check-doc-pointers.shLint ๅฝไปค๏ผ
nix flake check
statix check .
deadnix --fail .
nixfmt --check $(git ls-files "*.nix")- Android Licenses: The Flutter environment attempts to accept Android SDK licenses automatically. If this fails, run
flutter doctor --android-licensesmanually. - Nix Config: This flake sets
allowUnfree = trueandandroid_sdk.accept_license = truefor its own nixpkgs instance; no global config changes required.
To add a new language:
- Create a new file in
languages/following the existing pattern (uses helpers fromcommon.nix) - Add it to the
liboutputs inflake.nix - Add a template directory under
templates/ - Run
./scripts/check-templates.sh x86_64-linux <lang>andnix flake check
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Nix and Nix Flakes