Jump to the navigation menu

Minimum viable development environment

What is the leanest and most minimal local environment for software development?

I think if you use Linux, the most minimal approach is to install the packages you need, such as PHP and MySQL directly in your operating system.

There's no overhead or complexity added by tools like containers so things will run as quick and efficiently as possible.

This is great if you only work on one project and you can easily keep your installation in sync with production.

But what if you work on multiple projects or with a team of Developers?

You need a way for everyone to have the same software and package versions, and to be able to configure them for each project.

These are the reasons why tools like Vagrant, Docker and Podman became popular, as they made it possible for environments to be easily repeatable and customisable.

What about Nix?

Another tool that can be used to install software is Nix - a package manager with over 100,000 software packages.

I can use it to install the required software for each project and share the files with any team members so they have the same configuration.

This is the flake.nix file that I've been testing with a Drupal codebase:

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

  outputs =
    { nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          mariadb
          php82
          php82Packages.composer
        ];
      };
    };
}

This installs PHP 8.2, Composer and MariaDB, and nothing else.

It also generates a flake.lock file so everyone gets exactly the same package versions.

The downside is that, if everyone isn't using NixOS which handles services, I need to configure the database server for each project, running commands like mysql_install_db and mysqld before creating the database and user to put in the settings.php file.

It's not complicated but devenv is a great option if you want something more fully featured and opinionated that does more out of the box.

Once the database server is running and Drupal is installed, I can run drush runserver to run the website - no need for Apache, Caddy or Nginx.

If you want to see another example, see the flake.nix file for this website.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 18 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.