Why Nix?

Nix is a purely functional package manager designed for reproducibility, declarative environments, and build isolation. It’s not just a package manager - it’s a paradigm shift for building and managing systems, environments, and infrastructure.

Whether you’re building CI pipelines, container images, or local development environments - Nix gives you full control over versions, dependencies, and the build process.

Key Benefits

Reproducible Builds

  • Builds are content-addressed: identical inputs yield identical outputs.
  • No surprises between “it worked on my machine” and production.

Isolated Environments

  • Dependencies are never installed globally.
  • Every build or shell gets its own clean environment.

Atomic Changes & Rollbacks

  • All installations are transactional.
  • Rollback with a single command.
  • Unused packages can be garbage-collected.

Declarative Infrastructure

  • With NixOS, your entire system config is in a Git repo.
  • CI pipelines, Docker images, and VMs can be defined identically across stages.

Build Caching & Remote Builds

  • Efficient reuse of build artifacts.
  • Works with remote builders and binary caches like Cachix.

Go DevShell Example

Create a self-contained dev environment for a Go project - no Go installation required on the host.

flake.nix

{
  description = "Go DevShell with Nix";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

  outputs =
    { nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      formatter.${system} = pkgs.nixfmt;

      devShells.${system}.default = pkgs.mkShell {
        packages = with pkgs; [
          go
          gopls
          git
          nix-tree
        ];

        shellHook = ''
          echo "Go DevShell ready. Run 'go build' or use your editor with gopls."
        '';
      };
    };
}

Usage

nix develop

You now have:

  • Go compiler
  • gopls language server
  • Git
  • No global installations or manual setup

Final Thoughts

Nix has a learning curve, but the payoff is significant:

  • Faster, cacheable builds
  • Deterministic deployments
  • Clean, isolated development environments
  • No more “it works on my laptop”

Once you understand Nix, you’ll wonder how you managed infrastructure without it.

Learn more: nixos.org/learn.html