Skip to main content

Nix and the Dendritic pattern

As I wrote yesterday, no two Nix configurations are the same.

As well as having different packages and configuration options, Nix configurations can all be structured differently - similar to Drupal websites.

Some are simple and others are very complex and manage many systems.

A lot of people will publish their dotfiles/Nix/NixOS configurations online for others to read and take inspiration from.

I was reading someone's code yesterday and found a pattern they wrote about called the Dendritic pattern.

Using the flake-parts module system, every file when using this pattern is a flake-parts module.

This is different to most configurations, where only some files are modules and others are imported as needed within other files.

From another perspective, having consistency and following a strict convention makes things like auto-importing modules possible.

I like it solves a problem, making configurations easier to maintain as each file is responsible for adding one feature and are self-contained so things can easily be re-organised.

If I was writing my configuration from scratch, this is the approach I'd take.

Or, I may start looking to refactor my current configuration soon to be based on this pattern.

Was this interesting?

Subscribe to my daily newsletter for software professionals on software development and delivery, Drupal, DevOps, community, and open-source.

About me

Picture of Oliver

I'm a certified Drupal Triple Expert and former Drupal Association staff member with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.