oliverdavies.uk/content/node.d0ee1aae-f2fc-49d2-8865-d4912209eeea.yml

122 lines
4.1 KiB
YAML

uuid:
- value: d0ee1aae-f2fc-49d2-8865-d4912209eeea
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: 'Making ddev reproducible'
created:
- value: '2025-01-21T00: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/21/ddev
langcode: en
body:
- value: |
<p>I sometimes work on projects that already has an existing environment configuration, usually using a tool like DDEV.</p>
<p>Similar to using Nix, DDEV makes environments more consistent by standardising versions of PHP, nodejs, etc for each project.</p>
<p>This is great, but how do you know everyone has the same version of DDEV?</p>
<p>Different people having different versions of DDEV could introduce its own issues and bugs, such as pulling different images with different default package versions.</p>
<h2 id="enter-nix">Enter Nix</h2>
<p>The Nix package manager has over 100,000 packages, including DDEV.</p>
<p>This means I can install DDEV via Nix and because of the flake.nix file, anyone using the same configuration will get the same version of DDEV.</p>
<p>Here's a simple <code>flake.nix</code> file to install DDEV:</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; [ ddev ];
};
};
}
</code></pre>
<p>This approach also means I can have different versions of DDEV installed at once so I can use different versions for different projects as needed.</p>
<p>I also don't need it installed globally, so this only makes it available to the projects that need it.</p>
<p>It's a bit meta, but it works.</p>
format: full_html
processed: |
<p>I sometimes work on projects that already has an existing environment configuration, usually using a tool like DDEV.</p>
<p>Similar to using Nix, DDEV makes environments more consistent by standardising versions of PHP, nodejs, etc for each project.</p>
<p>This is great, but how do you know everyone has the same version of DDEV?</p>
<p>Different people having different versions of DDEV could introduce its own issues and bugs, such as pulling different images with different default package versions.</p>
<h2 id="enter-nix">Enter Nix</h2>
<p>The Nix package manager has over 100,000 packages, including DDEV.</p>
<p>This means I can install DDEV via Nix and because of the flake.nix file, anyone using the same configuration will get the same version of DDEV.</p>
<p>Here's a simple <code>flake.nix</code> file to install DDEV:</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; [ ddev ];
};
};
}
</code></pre>
<p>This approach also means I can have different versions of DDEV installed at once so I can use different versions for different projects as needed.</p>
<p>I also don't need it installed globally, so this only makes it available to the projects that need it.</p>
<p>It's a bit meta, but it works.</p>
summary: null
field_daily_email_cta: { }