oliverdavies.uk/source/_posts/2025-07-17.md

1.5 KiB

date title permalink
2025-07-17 Nix and the Dendritic pattern /daily/2025/07/17/nix-and-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.