Set Up a Reproducible Development Environment with Nix

github repo

A fully reproducible development workstation built with Nix flakes and Home Manager. This setup provides a consistent, declarative environment for shell, editor, and essential development tools.


Features

  • Zsh with Oh-My-Zsh and Powerlevel10k prompt
  • Autosuggestions and syntax highlighting for shell
  • Neovim configured with lazy.nvim, Treesitter, and multiple language servers
  • Common development utilities: Git, Bat, Eza, Fd, Ripgrep, Fzf, Tmux, Lazygit
  • Node.js 22 and Python 3.12 environments
  • Prettier, Terraform, Docker, AWS CLI
  • ChatGPT CLI alias (chat) using npx
  • Integration of Direnv with Nix flakes and Home Manager

Tech Stack

  • Nix with flakes for reproducible package management
  • Home Manager for declarative user environment management
  • Shell scripting (Zsh)
  • Neovim configured with Lua plugins

Getting Started

Prerequisites

Install Nix with flakes support:

sh <(curl -L https://nixos.org/nix/install) --no-daemon
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf

Clone the repository

git clone https://github.com/justin-napolitano/nix-tools.git
cd nix-tools

Activate Home Manager configuration

nix run home-manager/master -- switch --flake .#cobra@linux

Start your new shell

exec zsh

The Powerlevel10k prompt will launch its initial setup wizard.

Development Shell

To enter the pinned development environment:

nix develop

This shell includes Node.js, npm, pip, language servers (TypeScript, Python, Bash, Lua, YAML), Terraform, kubectl, AWS CLI, and configured aliases.

Exit with:

exit

Project Structure

  • flake.nix and flake.lock: Nix flake configuration and lock file
  • home/: Home Manager user configurations
  • dotfiles/: User dotfiles managed declaratively
  • scripts/: Utility scripts for installation, updates, and maintenance
  • install.sh: Script to bootstrap the environment
  • README.MD: This documentation
  • index.md: Blog post and extended documentation
  • Makefile: Build and maintenance commands

Future Work / Roadmap

  • Expand support for additional platforms beyond Linux
  • Add more language servers and tooling configurations
  • Automate OpenAI API key setup and integration
  • Enhance Neovim setup with more plugins and customizations
  • Improve documentation and onboarding experience

For issues and contributions, please open a GitHub issue or pull request on the repository.


Note: Remember to keep your OpenAI API key private and do not commit it to version control.


OpenAI API Key Setup

Create a private key file:

echo 'export OPENAI_API_KEY="sk-...your-key..."' > ~/.openai_api_key
echo 'export TOKEN="$OPENAI_API_KEY"' >> ~/.openai_api_key
chmod 600 ~/.openai_api_key

Reload your shell:

exec zsh

Test ChatGPT CLI:

chat "Write a Nix expression that prints hello world"
hjkl / arrows · / search · :family · :tag · :datefrom · :dateto · ~/entries/slug · Ctrl+N/Ctrl+P for suggestions · Ctrl+C/Ctrl+G to cancel
entries 201/201 · entry -/-
:readyentries 201/201 · entry -/-