Use DDEV on Nix and NixOS

10 Aug 2023

NixOS on the Desktop

NixOS on the server is a thing of beauty (check out my last blog post about Hosting Websites on NixOS), but after my Arch installation crapped out, I decided to take it further and also use it on my laptop as a daily driver.

Even though I was aware of the vast number of packages in the Nix repositories, I was still pleasantly surprised to find that almost all of my daily tools were available directly in the stable repository. Even Steam is just one line of configuration away!

However, a crucial work tool of mine, DDEV, was missing from the repositories. DDEV is a tool designed for launching local web development environments for PHP, Node.js and Python projects.

Set up ddev

With a bit of help from a savvy individual named kraftnix in the Jupiter Broadcasting Nix Nerds matrix group, I was able to create a buildable package of ddev on Nix.

The NUR (Nix User Repository) is a neat community and GitHub driven project, evidently inspired by the AUR (Arch user repository). While the NUR is smaller by several orders of magnitude, it can now be used to get ddev working on Nix / NixOS.

Update: I am soon going to phase out the NUR package, as ddev is now part of nixpkgs. I updated the below configuration for setting up ddev either way.

Below are the steps required to run DDEV on Nix / NixOS:


  1. { config, pkgs, ... }:
  2. {
  3. # ...
  5. # Install & enable docker.
  6. virtualisation.docker.enable = true;
  8. # Add your user to the 'docker' group. Change 'MYUSER' to your Linux username.
  9. users.users.MYUSER.extraGroups = [ "docker" ];
  11. # Enable the NUR and install dddev.
  12. # Not needed anymore if you are on the unstable branch of nixpkgs.
  13. # nixpkgs.config.packageOverrides = pkgs: {
  14. # nur = import (builtins.fetchTarball "") {
  15. # inherit pkgs;
  16. # };
  17. # };
  18. #
  19. # Install dddev from the NUR.
  20. # environment.systemPackages = with pkgs; [
  21. # nur.repos.gbytedev.ddev
  22. # ];
  24. # Install ddev.
  25.   environment.systemPackages = with pkgs; [ ddev ];
  28. # Allow Xdebug to use port 9003.
  29. networking.firewall.allowedTCPPorts = [ 9003 ];
  31. # Make it possible for ddev to modify the /etc/hosts file.
  32. # Otherwise you'll have to manually change the
  33. # hosts configuration after creating a new ddev project.
  34. environment.etc.hosts.mode = "0644";
  35. }

Please test and let me know if anything is broken / missing, as I intend to create a merge request on Nixpkgs to ensure this becomes a properly maintained package.



I'm pretty new on NixOs and for my beginning i wanted to stay on stable branch. I try your trick to use ddev and it works perfectly so thanks for the job :)

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang target> <em> <strong> <cite> <blockquote cite> <pre> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Get a quote in 24 hours

Wether a huge commerce system, or a small business website, we will quote the project within 24h of you pressing the following button: Get quote