154 lines
6.9 KiB
YAML
154 lines
6.9 KiB
YAML
uuid:
|
|
- value: ebcaf7c3-e103-448b-aa74-6bb469be0c2d
|
|
langcode:
|
|
- value: en
|
|
type:
|
|
- target_id: daily_email
|
|
target_type: node_type
|
|
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
|
|
revision_timestamp:
|
|
- value: '2025-05-11T09:00:02+00:00'
|
|
revision_uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
revision_log: { }
|
|
status:
|
|
- value: true
|
|
uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
title:
|
|
- value: 'Minimum viable development environment'
|
|
created:
|
|
- value: '2025-01-19T00:00:00+00:00'
|
|
changed:
|
|
- value: '2025-05-11T09:00:02+00:00'
|
|
promote:
|
|
- value: false
|
|
sticky:
|
|
- value: false
|
|
default_langcode:
|
|
- value: true
|
|
revision_translation_affected:
|
|
- value: true
|
|
path:
|
|
- alias: /daily/2025/01/19/minimum-viable-development-environment
|
|
langcode: en
|
|
body:
|
|
- value: |
|
|
<p>What is the leanest and most minimal local environment for software development?</p>
|
|
|
|
<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>
|
|
|
|
<p>There's no overhead or complexity added by tools like containers so things will run as quick and efficiently as possible.</p>
|
|
|
|
<p>This is great if you only work on one project and you can easily keep your installation in sync with production.</p>
|
|
|
|
<p>But what if you work on multiple projects or with a team of Developers?</p>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<h2 id="what-about-nix%3F">What about Nix?</h2>
|
|
|
|
<p>Another tool that can be used to install software is Nix - a package manager with over 100,000 software packages.</p>
|
|
|
|
<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>
|
|
|
|
<p>This is the <code>flake.nix</code> file that I've been testing with a Drupal codebase:</p>
|
|
|
|
<pre><code class="nix">{
|
|
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
|
|
];
|
|
};
|
|
};
|
|
}
|
|
</code></pre>
|
|
|
|
<p>This installs PHP 8.2, Composer and MariaDB, and nothing else.</p>
|
|
|
|
<p>It also generates a <code>flake.lock</code> file so everyone gets exactly the same package versions.</p>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
|
|
format: full_html
|
|
processed: |
|
|
<p>What is the leanest and most minimal local environment for software development?</p>
|
|
|
|
<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>
|
|
|
|
<p>There's no overhead or complexity added by tools like containers so things will run as quick and efficiently as possible.</p>
|
|
|
|
<p>This is great if you only work on one project and you can easily keep your installation in sync with production.</p>
|
|
|
|
<p>But what if you work on multiple projects or with a team of Developers?</p>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<h2 id="what-about-nix%3F">What about Nix?</h2>
|
|
|
|
<p>Another tool that can be used to install software is Nix - a package manager with over 100,000 software packages.</p>
|
|
|
|
<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>
|
|
|
|
<p>This is the <code>flake.nix</code> file that I've been testing with a Drupal codebase:</p>
|
|
|
|
<pre><code class="nix">{
|
|
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
|
|
];
|
|
};
|
|
};
|
|
}
|
|
</code></pre>
|
|
|
|
<p>This installs PHP 8.2, Composer and MariaDB, and nothing else.</p>
|
|
|
|
<p>It also generates a <code>flake.lock</code> file so everyone gets exactly the same package versions.</p>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
|
|
summary: null
|
|
field_daily_email_cta: { }
|