Master Nix Fundamentals Through Practical Examples

Major Changes in Nix (2015-2025) Link to heading

Core System Changes Link to heading

  • Nix Flakes - Introduced with Nix 2.4 in November 2021, providing uniform structure for projects and version-pinned dependencies
  • New nix command - Unified command interface replacing separate utilities like nix-build, nix-shell
  • Improved error messages - Nix 2.4 brought significantly better error reporting with location information
  • nix-repl deprecation - The standalone nix-repl is now nix repl in the unified command structure

Package Ecosystem Growth Link to heading

  • Massive package expansion - Nixpkgs grew to over 80,000 packages as of 2024
  • Package management tools - New utilities like nix-update for automated package maintenance
  • Channels evolution - Channel system enhanced with better versioning (nixos-23.05 style naming)

Development Workflow Changes Link to heading

  • Flakes adoption - Despite experimental status, flakes gained widespread community adoption for enhanced capabilities
  • Reproducibility improvements - Lock files provide better version pinning and reproducible installations
  • Development environments - Enhanced nix-shell workflows and development tooling

Tooling and Ecosystem Link to heading

  • NixOS modules system - Enhanced configuration management since 2009
  • Community resources - Wiki maintenance issues led to documentation reorganization
  • Integration tools - Better support for non-NixOS systems and package managers

Breaking Changes Link to heading

  • Command interface - Many traditional nix-* commands moved under unified nix command
  • Configuration syntax - Flakes introduced new configuration patterns
  • Channel management - Updated approaches to channel subscriptions and updates

Original post with minor updates:

Getting comfortable with Nix can feel overwhelming after reading the manual. You understand the concepts, but how do you actually use them? This cookbook bridges that gap with practical examples you can run and modify.

What You’ll Learn Link to heading

This guide assumes you’ve read the Nix Manual but need hands-on practice with:

  • Nix - The functional package manager
  • NixOS - The Linux distribution built on Nix
  • NixOps - Deployment tool for NixOS systems

Setup Requirements Link to heading

You’ll need Nix 1.9 or later. Most examples work with 1.8, but newer versions provide better error messages and performance.

Install the interactive REPL for testing expressions:

$ nix-env -i nix-repl

Or use the provided development environment:

$ nix-shell

This loads all necessary tools automatically.

Core Language Elements Link to heading

Master these fundamental data types and operations through interactive examples. Each section builds on previous concepts, so work through them in order.

Start your learning journey with nix-repl open.

Data Types You’ll Master Link to heading

  • Integers - Math operations and number handling
  • TODO Booleans - Logic operations and conditional expressions
  • Strings - Text manipulation and interpolation
  • TODO Paths - File system navigation and path operations

Advanced Operations Link to heading

  • TODO Files - Reading and processing file content
  • Lists - Collection operations and transformations
  • Lambdas - Function creation and application
  • Concatenation - Combining data structures
  • Importing - Code organization and module system

Your Next Steps Link to heading

Each example includes exercises to reinforce learning. Work through them systematically - the concepts build on each other.

Found something confusing? Submit [issues]({{ site.github.repo }}/issues) for clarification.

Have improvements? Send [pull requests]({{ site.github.repo }}/pulls) to help other learners.

The examples provide a foundation for real-world Nix usage. Once you’re comfortable with these basics, you’ll be ready to tackle complex system configurations and package definitions.