"value":"\n <p>What is the leanest and most minimal local environment for software development?<\/p>\n\n<p>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.<\/p>\n\n<p>There's no overhead or complexity added by tools like containers so things will run as quick and efficiently as possible.<\/p>\n\n<p>This is great if you only work on one project and you can easily keep your installation in sync with production.<\/p>\n\n<p>But what if you work on multiple projects or with a team of Developers?<\/p>\n\n<p>You need a way for everyone to have the same software and package versions, and to be able to configure them for each project.<\/p>\n\n<p>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.<\/p>\n\n<h2 id=\"what-about-nix%3F\">What about Nix?<\/h2>\n\n<p>Another tool that can be used to install software is Nix - a package manager with over 100,000 software packages.<\/p>\n\n<p>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.<\/p>\n\n<p>This is the <code>flake.nix<\/code> file that I've been testing with a Drupal codebase:<\/p>\n\n<pre><code class=\"nix\">{\n inputs.nixpkgs.url = \"github:nixos\/nixpkgs\/nixos-unstable\";\n\n outputs =\n { nixpkgs, ... }:\n let\n system = \"x86_64-linux\";\n pkgs = nixpkgs.legacyPackages.${system};\n in\n {\n devShells.${system}.default = pkgs.mkShell {\n buildInputs = with pkgs; [\n mariadb\n php82\n php82Packages.composer\n ];\n };\n };\n}\n<\/code><\/pre>\n\n<p>This installs PHP 8.2, Composer and MariaDB, and nothing else.<\/p>\n\n<p>It also generates a <code>flake.lock<\/code> file so everyone gets exactly the same package versions.<\/p>\n\n<p>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 <code>mysql_install_db<\/code> and <code>mysqld<\/code> before creating the database and user to put in the <code>settings.php<\/code> file.<\/p>\n\n<p>It's not complicated but <a href=\"\/daily\/2024\/11\/11\/could-nix-and-devenv-replace-docker-compose\">devenv is a great option<\/a> if you want something more fully featured and opinionated that does more out of the box.<\/p>\n\n<p>Once the database server is running and Drupal is installed, I can run <code>drush runserver<\/code> to run the website - no need for Apache, Caddy or Nginx.<\/p>\n\n<p>If you want to see another example, see the <a href=\"https:\/\/code.oliverdavies.uk\/opdavies\/oliverdavies.uk\/src\/commit\/4350852406e9556b63a1df448f225abbd7883651\/flake.nix\">flake.nix file for this website<\/a>.<\/p>\n\n ",
"processed":"\n <p>What is the leanest and most minimal local environment for software development?<\/p>\n\n<p>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.<\/p>\n\n<p>There's no overhead or complexity added by tools like containers so things will run as quick and efficiently as possible.<\/p>\n\n<p>This is great if you only work on one project and you can easily keep your installation in sync with production.<\/p>\n\n<p>But what if you work on multiple projects or with a team of Developers?<\/p>\n\n<p>You need a way for everyone to have the same software and package versions, and to be able to configure them for each project.<\/p>\n\n<p>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.<\/p>\n\n<h2 id=\"what-about-nix%3F\">What about Nix?<\/h2>\n\n<p>Another tool that can be used to install software is Nix - a package manager with over 100,000 software packages.<\/p>\n\n<p>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.<\/p>\n\n<p>This is the <code>flake.nix<\/code> file that I've been testing with a Drupal codebase:<\/p>\n\n<pre><code class=\"nix\">{\n inputs.nixpkgs.url = \"github:nixos\/nixpkgs\/nixos-unstable\";\n\n outputs =\n { nixpkgs, ... }:\n let\n system = \"x86_64-linux\";\n pkgs = nixpkgs.legacyPackages.${system};\n in\n {\n devShells.${system}.default = pkgs.mkShell {\n buildInputs = with pkgs; [\n mariadb\n php82\n php82Packages.composer\n ];\n };\n };\n}\n<\/code><\/pre>\n\n<p>This installs PHP 8.2, Composer and MariaDB, and nothing else.<\/p>\n\n<p>It also generates a <code>flake.lock<\/code> file so everyone gets exactly the same package versions.<\/p>\n\n<p>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 <code>mysql_install_db<\/code> and <code>mysqld<\/code> before creating the database and user to put in the <code>settings.php<\/code> file.<\/p>\n\n<p>It's not complicated but <a href=\"http:\/\/default\/daily\/2024\/11\/11\/could-nix-and-devenv-replace-docker-compose\">devenv is a great option<\/a> if you want something more fully featured and opinionated that does more out of the box.<\/p>\n\n<p>Once the database server is running and Drupal is installed, I can run <code>drush runserver<\/code> to run the website - no need for Apache, Caddy or Nginx.<\/p>\n\n<p>If you want to see another example, see the <a href=\"https:\/\/code.oliverdavies.uk\/opdavies\/oliverdavies.uk\/src\/commit\/4350852406e9556b63a1df448f225abbd7883651\/flake.nix\">flake.nix file for this website<\/a>.<\/p>\n\n ",