{"id":29644078,"url":"https://github.com/mightyiam/dendritic","last_synced_at":"2025-07-22T00:02:40.355Z","repository":{"id":292107177,"uuid":"979819414","full_name":"mightyiam/dendritic","owner":"mightyiam","description":"A Nix flake-parts usage pattern in which every Nix file is a flake-parts module","archived":false,"fork":false,"pushed_at":"2025-07-19T08:12:32.000Z","size":183,"stargazers_count":52,"open_issues_count":1,"forks_count":3,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-07-19T13:22:11.408Z","etag":null,"topics":["flake-parts","nix","nix-flake","pattern","template"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mightyiam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"mightyiam","custom":"https://wise.com/pay/me/shaharo"}},"created_at":"2025-05-08T05:50:44.000Z","updated_at":"2025-07-19T11:48:07.000Z","dependencies_parsed_at":"2025-06-26T15:36:15.038Z","dependency_job_id":null,"html_url":"https://github.com/mightyiam/dendritic","commit_stats":null,"previous_names":["mightyiam/whiteout","mightyiam/dendritic"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mightyiam/dendritic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mightyiam%2Fdendritic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mightyiam%2Fdendritic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mightyiam%2Fdendritic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mightyiam%2Fdendritic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mightyiam","download_url":"https://codeload.github.com/mightyiam/dendritic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mightyiam%2Fdendritic/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266404492,"owners_count":23923447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flake-parts","nix","nix-flake","pattern","template"],"created_at":"2025-07-22T00:02:38.909Z","updated_at":"2025-07-22T00:02:40.309Z","avatar_url":"https://github.com/mightyiam.png","language":null,"funding_links":["https://github.com/sponsors/mightyiam","https://wise.com/pay/me/shaharo"],"categories":["others","Others","Related Patterns, Frameworks, Utilities and Libraries"],"sub_categories":["Community Modules"],"readme":"![logo](./logo.jpg)\n\n# The Dendritic Pattern\n\nA [Nix](https://nix.dev) [flake-parts](https://flake.parts) usage pattern in which _every_ Nix file is a flake-parts module\n\n## Testimonials\n\n\u003e I adore this idea by @mightyiam of every file is a flake parts module and I think I will adopt it everywhere.\n\n—Daniel Firth ([source](https://x.com/locallycompact/status/1909188620038046038))\n\n\u003e Massive, very interesting!\n\n—Pol Dellaiera ([source](https://discourse.nixos.org/t/pattern-every-file-is-a-flake-parts-module/61271/2?u=mightyiam))\n\n\u003e I’ve adopted your method. Really preferring it.\n\n—gerred ([source](https://x.com/devgerred/status/1909206297532117469))\n\n## Background\n\n[NixOS](https://nixos.org/manual/nixos/unstable/),\n[home-manager](https://github.com/nix-community/home-manager) and\n[nix-darwin](https://github.com/nix-darwin/nix-darwin)\nare popular projects that allow the user to produce [derivations](https://nix.dev/tutorials/nix-language.html#derivations)\nthat can be customized by evaluating a [Nixpkgs module system](https://nix.dev/tutorials/module-system/) configuration.\n\nFiguring out a practical and expressive architecture for a codebase that provides configurations had proven to cost many a Nix user protracted periods and multiple refactorings.\n\nFactors contributing to the complexity of such an architecture:\n\n- Multiple configurations\n- Sharing of some modules across some configurations\n- Multiple configuration classes (NixOS \u0026 home-manager)\n- Configuration nesting such as home-manager [within NixOS](https://nix-community.github.io/home-manager/index.xhtml#sec-install-nixos-module) or [within nix-darwin](https://nix-community.github.io/home-manager/index.xhtml#sec-install-nix-darwin-module)\n- Existence of concerns that span multiple configuration classes (\"cross-cutting concerns\")\n- Accessing values such as functions, constants and packages across files\n\n## The pattern\n\nThe dendritic pattern reconciles these factors using yet another application of the Nixpkgs module system: [flake-parts](https://flake.parts).\nEspecially its option [`flake.modules`](https://flake.parts/options/flake-parts-modules.html).\n\nEach and every file:\n- is a flake-parts module\n- implements a single feature\n- ...across all module classes it applies to\n- is at a path that serves to name the feature\n\n## Usage in the wild\n\n- [Shahar \"Dawn\" Or (@mightyiam)](https://github.com/mightyiam/infra) ([adoption commit](https://github.com/mightyiam/infra/commit/b45e9e13759017fe18950ccc3b6deee2347e9175))\n- [Victor Borja (@vic)](https://github.com/vic/vix) ([adoption pull request](https://github.com/vic/vix/pull/115)) ([forum answer](https://discourse.nixos.org/t/how-do-you-structure-your-nixos-configs/65851/8))\n- [Pol Dellaiera](https://github.com/drupol/nixos-x260) ([adoption pull request](https://github.com/drupol/nixos-x260/pull/83)) ([blog post](https://not-a-number.io/2025/refactoring-my-infrastructure-as-code-configurations/))\n- [Horizon Haskell](https://gitlab.horizon-haskell.net/nix/gitlab-ci)\n- [Gaétan Lepage](https://github.com/GaetanLepage/nix-config) ([acknowledgment commit](https://github.com/GaetanLepage/nix-config/commit/3ed89eae1a8e13c1910eac5f89f2cdb4f48756ff))\n- [bivsk](https://github.com/bivsk/nix-iv) ([adoption pull request](https://github.com/bivsk/nix-iv/pull/2))\n\n## Community\n\n- [GitHub Discussions](https://github.com/mightyiam/dendritic/discussions)\n\n- [Matrix room: `#dendritic:matrix.org`](https://matrix.to/#/#dendritic:matrix.org)\n\n## Anti patterns\n\n### `specialArgs` pass-thru\n\nIn a non-dendritic pattern some Nix files may be modules that are other than flake-parts\n(such as NixOS or home-manager).\nOften they require access to values that are defined outside of their config evaluation.\nThose values are often passed through to such evaluations\nvia the `specialArgs` argument of `lib.evalModules` wrappers like `lib.nixosSystem`.\n\nFor example, `scripts/foo.nix` defines a script called `script-foo`\nwhich is then included in `environment.systemPackages` in `nixos/laptop.nix`.\n`script-foo` is made available in `nixos/laptop.nix` by injecting it\n(or a superset of it, such as the flake `self` may be) via `specialArgs`.\nThis might occur even once deeper from the NixOS evaluation into a nested home-manager evaluation\n(this time via `extraSpecialArgs`).\n\nIn the dendritic pattern\nevery file is a flake-parts module and can therefore add values to the flake-parts `config`.\nIn turn, every file can also read from the flake-parts `config`.\nThis makes the sharing of values between files seem trivial in comparison.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmightyiam%2Fdendritic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmightyiam%2Fdendritic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmightyiam%2Fdendritic/lists"}