Migrating From Homebrew Scripts and Version Managers to Nix-Powered Environments in One Afternoon
A committed flake and lock file replace machine-specific installs.

Migrating from Homebrew scripts and version managers to Nix-powered environments in one afternoon is achievable because the main change is conceptual. With a committed manifest and lock file, declared package inputs take the place of the installation state built up on a machine. The direct flake approach requires writing Nix once, but teammates can use the resulting environment without authoring Nix themselves.
Why Homebrew and version managers leave your environment in an unknown state
A Brewfile records package names with exact versions left unspecified. Running brew bundle install six months later installs what is current then, so the same file can give different systems. Version managers narrow part of that uncertainty by selecting language runtimes, but nvm, pyenv, and rbenv operate independently. None keeps a record of the whole environment around those runtimes. OS upgrades can disrupt that arrangement even when the project files have not changed.
One person has Node 18, another has Node 20, and CI has something else, with no single source of truth connecting them. Version ranges, transitive dependencies, and system libraries introduce further differences beyond the runtime version. A working machine is therefore not a complete specification. The flaw is structural because imperative installs accumulate state that an installation manifest cannot fully reconstruct.
The mental model shift: from imperative installs to pure functions of inputs
Nix changes the unit of reasoning from installation commands to package inputs. Its model treats a package as a pure function of its source, dependencies, build instructions, and compilation settings. Rather than asking what commands made a machine work, the developer asks what inputs define the environment. That is the central shift in the migration. A shell script changes an existing system, while a Nix declaration describes what should be available.
The Nix store makes that distinction concrete. Packages live under /nix/store at input-addressed paths whose hashes show how the packages were built, with their dependencies and build settings. Multiple versions can therefore coexist at distinct paths. Choosing one environment leaves another project's copy of the same tool in place.
Flakes extend this model to a project declaration. The flake.lock that comes with it records the exact input revisions, so developers on the same platform use the same package inputs and store paths. Platform is an important qualification because Linux and macOS do not use identical binaries. But one shared declaration can still describe both systems without a separate installation script for each. Reproducibility comes from the locked inputs.
What you are actually migrating: packages, versions, and the gap Brewfile cannot see
Run brew list --formula and brew list --cask to separate installed command-line packages from casks. Then inspect active version managers with nvm ls, pyenv versions, and rbenv versions, as applicable. The Brewfile is only the starting point. It does not capture the runtime state those managers maintain or the full transitive dependency set.
Write down the versions the project needs, including entries in .nvmrc, .python-version, and similar files. This keeps the project's dependency declaration from becoming a list of everything installed on the machine. For this afternoon, the migration targets are CLI tools and language runtimes. GUI Mac applications can stay in Homebrew. Browsers, communication tools, and media players do not need Nix equivalents before the project can gain a reproducible development environment.
Installing Nix and enabling flakes on macOS and Linux
Install Nix using the official installer for macOS or Linux. The installation takes one command, and the official documentation covers cases where a platform needs more. If flakes are not already enabled, add experimental-features = nix-command flakes to ~/.config/nix/nix.conf. Then run nix --version to inspect the installation. The modern commands, including nix develop, nix shell, and nix build, were introduced in Nix 2.4.
This step installs the environment machinery before the project's tools. Those belong in the declaration written next.
Writing a flake.nix that replaces your Brewfile and version managers in one file
The flake turns the audit into one environment that belongs to the project. Its inputs.nixpkgs.url selects the package catalog, while the generated lock file fixes the exact revision. The outputs expression defines a default development shell for each supported system through pkgs.mkShell. Inside that shell, buildInputs names the tools that were chosen through Homebrew and version managers. An optional shellHook handles activation commands, including environment variable exports or project setup.
A short example can use Node and Python and still work as a guide for other languages. The following complete expression belongs in flake.nix, with the package list adjusted to match the audit.
{ inputs.nixpkgs.url = "github:NixOS/nixpkgs"; outputs = { self, nixpkgs }: let systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; in { devShells = nixpkgs.lib.genAttrs systems (system: let pkgs = import nixpkgs { inherit system; }; in { default = pkgs.mkShell { buildInputs = [ pkgs.nodejs_20 pkgs.python312 ]; }; }); }; }
The system list covers Linux and macOS on both architectures named in the declaration. The package entries translate a Node 20 requirement from .nvmrc into pkgs.nodejs_20 and a Python version requirement into pkgs.python312. Other audited CLI tools belong in the same list. No language-manager shim configuration is needed for these runtimes. The shell selects them as part of the project environment.
The first invocation generates flake.lock, which must be committed with flake.nix. Committing only the manifest leaves the package catalog without its exact recorded revision. Now run nix develop from the project directory. The shell activates with the declared tools available, making the inventory executable.
Making the shell activate automatically with direnv so developers never think about it again
Automatic activation removes the need to remember nix develop every day. Install direnv with nix profile install nixpkgs#direnv, then add eval "$(direnv hook bash)" to the shell configuration, using the corresponding hook for zsh or fish. Put use flake in the project's .envrc and run direnv allow once. This connects directory entry to environment activation. Leaving the directory deactivates the project environment.
With Nix and the direnv integration in place, contributors do not need to select runtimes manually. A new contributor clones the repository, enters the directory, and runs direnv allow once to activate the environment.
What to do with the packages nixpkgs does not cover: keeping Homebrew for GUI casks
Keeping Homebrew for GUI casks is a stable division of responsibility. Nix owns project CLI tools and runtimes, while Homebrew retains Mac applications whose signing and update integration fit its cask model better. Complete replacement is not the objective here. The useful rule of thumb is to leave menu bar applications in Homebrew and put terminal tools in the flake. This preserves native application management without leaving project tooling dependent on global installs.
When nixpkgs contains a tool but the selected catalog revision is too old, a separate pinned nixpkgs input can supply that tool. The remaining packages can continue using the stable channel. The declaration keeps a record of that tool's separate input, so it stays out of undocumented local installations. Perfect catalog coverage is therefore not a prerequisite for starting.
How the flake.lock makes the same environment reproducible in CI without extra configuration
CI can consume the same committed flake.nix and flake.lock as the developer's laptop. With Nix installed on the runner, the job enters the environment through nix develop and runs the project's build and test commands there. A separate runtime-version inventory is no longer necessary. When the platforms match, both use the same locked package inputs, so package names need no separate resolution when the job starts.
This changes tool provisioning in CI: Docker can continue orchestrating services while Nix supplies the build and test environment. Binary caches let jobs use builds that are already available, so they can skip compiling those packages from source. The Atuin project merged PR #4829 on November 26, 2026, adding Nix builds and Cachix uploads for aarch64 Linux and Apple Silicon macOS. That provides a concrete example of the multi-architecture build-and-cache pattern.
Rollbacks, environment history, and what happens when an upgrade breaks something
An environment upgrade changes the declared inputs rather than modifying existing store packages in place. For a team, updating a tool means updating the flake input for that tool and committing the lock file that comes from the change. Suppose that update breaks the project's tests. Reverting the lock-file change restores the previous input selection, and the next environment activation uses that selection. If the manifest changed too, its matching revision belongs in the same reversion.
Existing store packages are immutable and can be reused when still available. But getting back to a working system after brew upgrade may take a cached formula or manual pin, and the full dependency state may still be lost. The project does not need a separate account of which commands produced each environment. The manifest and lock file in Git are its history.
Supply chain visibility the Nix model provides without additional tooling
The same input model also makes dependencies inspectable. Nix derivations describe dependencies, patches, and build steps, providing a construction record rather than requiring all relationships to be inferred from a finished artifact. This is visibility built into the package model. Tools built for the task can then use that record to produce a formal software bill of materials or provenance attestation.
TIIUAE, the research institute behind the Ghaf Framework, demonstrates that connection through its sbomnix toolchain. Its sbomnix utility generates SBOMs from a flake reference or store path, while nixgraph visualizes dependency graphs. The same toolchain includes vulnxscan for vulnerability scanning and provenance for SLSA v1.0-compliant provenance attestations. These are concrete uses of the dependency model. They extend the foundation established by a locked environment.
The NixOS Foundation's Hydra build farm compiles packages, signs successful builds, and publishes them to a binary cache. Organizations with stricter requirements can rebuild from source and sign packages with their own keys. The architecture supports either chain of trust. A hosted control plane can extend this foundation with named, versioned environments, complete-stack retrieval, and deterministic SBOM generation. Those organizational capabilities build on declared inputs, but they are not prerequisites for the afternoon migration.
What the afternoon migration actually looks like end to end

The first block is the 20-minute audit of Homebrew packages, version-manager state, and project version files. Separate GUI casks from terminal tools and identify the versions the project needs. The next block turns that inventory into flake.nix. Run nix develop, confirm the declared tools and versions, and commit the manifest with its generated lock file. Some package names will require a lookup in nixpkgs, which is the main practical work.
The following block connects direnv to the shell and adds the project's .envrc. Confirm that entering and leaving the directory activates and deactivates the environment. Use the remaining time to add the Nix environment to CI, push the changes, and confirm the pipeline passes. Homebrew remains responsible for GUI casks. The migrated project no longer depends on its previous version-manager setup.
The afternoon leaves the project with its own environment. Teammates can consume it without writing Nix, because the declaration work is already committed. For the next contributor with Nix and direnv configured, onboarding is a repository clone, a directory change, and one direnv allow.


