Source: Dev.to | Jan 10, 2026 (UTC)
“It works on my machine” is a phrase that has haunted software development for decades. Whether it’s a teammate having a different version of Python, a CI server missing a specific C library, or your global Node.js version conflicting with a legacy project, environment drift is a silent productivity killer.
I resolved this by moving my entire development workflow to Nix Flakes.
Nix guarantees that if a project works today, it will work exactly the same way six months from now, or on a completely different machine, without manual installation steps.
In modern software development, we don’t just write code; we manage a fleet of tools. Nix provides a declarative way to handle:
- Isolation: No more polluting your global
/usr/local/bin. Every tool stays within the project. - Reproducibility: Every dependency is pinned. If I use Python 3.12.1, everyone on the team uses 3.12.1.
- Automation: Using the
shellHook, we can automate the startup of services, credential helpers, and environment variables.
The Project Orchestrator: flake.nix
I use a flake.nix in every repository. This specific configuration handles a complex stack: Python (managed by uv), AWS (with ECR automation), Docker, and various security tools.
{ description = "DevShell con Terraform, Docker, Python y ECR login"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; pythonEnv = pkgs.python312.withPackages (ps: with ps; [ pip ]); commonDeps = with pkgs; [ pythonEnv uv git terraform python312 awscli gcc stdenv.cc.cc.lib httpie go go-task docker amazon-ecr-credential-helper jq nodejs_20 nodePackages.lerna google-chrome subfinder amass imagemagick yarn ]; in { devShells.default = pkgs.mkShell { packages = commonDeps; shellHook = '' # 1. Python & uv Setup pyenv global system export pythonEnv=${pythonEnv} export PATH=$PATH:${pythonEnv}/bin # Ensure uv uses the Nix-provided Python interpreter export UV_PYTHON=${pythonEnv}/bin/python # 2. Service Orchestration docker compose up --build -d docker compose ps -a task dependencies # 3. AWS & Docker Credential Automation mkdir -p ~/.docker echo '{ "credsStore": "ecr-login" }' > ~/.docker/config.json echo "Docker config set to use docker-credential-ecr-login" ''; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ]; }; }); }
Enter fullscreen mode
Exit fullscreen mode



Залишити відповідь