{"id":49670854,"url":"https://github.com/denful/den","last_synced_at":"2026-05-23T12:00:41.666Z","repository":{"id":320310298,"uuid":"1081607251","full_name":"denful/den","owner":"denful","description":"Aspect-oriented, context-driven Dendritic Nix configurations. [maintainer = @vic, @sini, @HeitorAugustoLN, @Gwenodai, @theutz, @DylanRJohnston]","archived":false,"fork":false,"pushed_at":"2026-05-20T13:48:12.000Z","size":2277,"stargazers_count":373,"open_issues_count":21,"forks_count":35,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-05-20T18:32:53.608Z","etag":null,"topics":["aspect-oriented","context-driven","den","dendritic","flake","home-manager","nix","nix-build","nix-darwin","nixos","os-configuration","unflake"],"latest_commit_sha":null,"homepage":"http://den.denful.dev/","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denful.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["vic","sini"],"patreon":null,"open_collective":null,"ko_fi":"oeiuwq","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-10-23T02:56:00.000Z","updated_at":"2026-05-20T13:50:04.000Z","dependencies_parsed_at":"2025-10-23T05:22:13.165Z","dependency_job_id":"b9e258c9-9c27-4f8b-a894-da63b6fed490","html_url":"https://github.com/denful/den","commit_stats":null,"previous_names":["vic/den","denful/den"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/denful/den","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denful%2Fden","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denful%2Fden/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denful%2Fden/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denful%2Fden/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denful","download_url":"https://codeload.github.com/denful/den/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denful%2Fden/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33394672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aspect-oriented","context-driven","den","dendritic","flake","home-manager","nix","nix-build","nix-darwin","nixos","os-configuration","unflake"],"created_at":"2026-05-06T23:00:23.399Z","updated_at":"2026-05-23T12:00:41.649Z","avatar_url":"https://github.com/denful.png","language":"Nix","funding_links":["https://github.com/sponsors/vic","https://github.com/sponsors/sini","https://ko-fi.com/oeiuwq"],"categories":["Nix"],"sub_categories":[],"readme":"\u003cp align=\"right\"\u003e\n  \u003ca href=\"https://denful.dev/sponsor\"\u003e\u003cimg src=\"https://img.shields.io/badge/sponsor-vic-white?logo=githubsponsors\u0026logoColor=white\u0026labelColor=%23FF0000\" alt=\"Sponsor Vic\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://deepwiki.com/denful/den\"\u003e\u003cimg src=\"https://deepwiki.com/badge.svg\" alt=\"Ask DeepWiki\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/denful/den/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/denful/den?style=plastic\u0026logo=github\u0026color=purple\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://denful.dev\"\u003e\u003cimg src=\"https://img.shields.io/badge/Dendritic-Nix-informational?logo=nixos\u0026logoColor=white\" alt=\"Dendritic Nix\"/\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/denful/den\" alt=\"License\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/denful/den/actions\"\u003e\u003cimg src=\"https://github.com/denful/den/actions/workflows/test.yml/badge.svg\" alt=\"CI Status\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e den and [vic](https://bsky.app/profile/oeiuwq.bsky.social)'s [dendritic libs](https://denful.dev) made for you with Love++ and AI--. If you like my work, consider [sponsoring](https://denful.dev/sponsor)\n\n# den - Aspect-oriented, Context-driven Dendritic Nix configurations.\n\n### Den allows creating parametric configurations by taking the Dendritic pattern to the function-level.\n\nThese configurations become specific when applied to your particular infra entities (hosts/users),\nwhile allowing re-usable aspects to be shared between hosts, users, or across other flakes and non-flake projects.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```nix\n# An aspect is a function taking context and\n# returning modules of different Nix classes\nden.aspects.gaming = { host, user }: {\n  nixos = { pkgs, ... }: ...;\n  darwin = ...;\n  hjem = ...;\n  homeManager = ...;\n\n  # aspects can depend on other aspects\n  includes = [ den.aspects.performance ];\n\n  # aspects can be organized in sub-aspects\n  provides.emulation = {\n    nixos = { pkgs, ... }: ... ;\n  };\n}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```nix\n# These three lines is how Den instantiates a configuration.\n# Other Nix configuration domains outside NixOS/nix-Darwin\n# can use the same pattern. demo: templates/nvf-standalone\n\n# Den resolves entities declared in den.hosts automatically.\n# Policies drive topology (host-\u003e[users]-\u003e[homes]).\n# The pipeline collects all aspects and produces per-class modules.\n\n# For manual resolution outside the pipeline:\naspect = den.lib.aspects.resolve \"nixos\"\n  (den.aspects.my-aspect { host = den.hosts.x86_64-linux.my-laptop; });\nnixosConfigurations.my-laptop = lib.nixosSystem {\n  modules = [ aspect ];\n};\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nDen has Zero Dependencies. `den.lib` is domain agnostic, it can be used to configure anything Nix-configurable.\n\nOn top of `den.lib`, Den also provides a [framework](https://den.denful.dev/explanation/context-pipeline/) for the NixOS/nix-Darwin/Home-Manager Nix domains.\n\nDen embraces your Nix choices and does not impose itself. All parts of Den are optional and replaceable. Works with your current setup, with/without flakes, flake-parts or any other Nix module system.\n\n\u003e [Den is a declarative data transformation pipeline](https://github.com/denful/den/discussions/355). Infra entities are traversed via `den.policies` and configurations for them are generated when `den.aspects` are applied at each entity resolution.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cdiv style=\"max-width: 320px;\"\u003e\n\n\u003cimg width=\"300\" height=\"300\" alt=\"den\" src=\"https://github.com/user-attachments/assets/af9c9bca-ab8b-4682-8678-31a70d510bbb\" /\u003e\n\n## [Documentation](https://den.denful.dev)\n\n- [From Zero To Den](https://den.denful.dev/guides/from-zero-to-den/)\n\n- [From Flake To Den](https://den.denful.dev/guides/from-flake-to-den/)\n\n- [Core Principles](https://den.denful.dev/explanation/core-principles/)\n\n- [Custom Nix Classes](https://den.denful.dev/guides/custom-classes/)\n\n- [Homes Integration](https://den.denful.dev/guides/home-manager/)\n\n- [Batteries](https://den.denful.dev/guides/batteries/)\n\n- [Mutual Providers](https://den.denful.dev/guides/mutual/)\n\n- [Sharing Namespaces](https://den.denful.dev/guides/namespaces/)\n\n- [`\u003cangle/brackets\u003e`](https://den.denful.dev/guides/angle-brackets/)\n\n- [Tests as Code Examples](https://den.denful.dev/tutorials/ci/)\n\n## Project\n\n- [Versioning](https://den.denful.dev/releases/)\n\n- [Motivation](https://den.denful.dev/motivation/)\n\n- [Community](https://den.denful.dev/community/)\n\n- [Contributing](https://den.denful.dev/contributing/)\n\n\u003c/div\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\n### Templates:\n\n[default](https://den.denful.dev/tutorials/default/): +flake-file +flake-parts +home-manager\n\n[minimal](https://den.denful.dev/tutorials/minimal): +flakes -flake-parts -home-manager\n\n[noflake](https://den.denful.dev/tutorials/noflake): -flakes +npins +lib.evalModules +nix-maid\n\n[nvf-standalone](https://den.denful.dev/tutorials/nvf-standalone): Standalone neovim apps, showcasing Den without NixOS/Darwin.\n\n[microvm](https://den.denful.dev/tutorials/microvm): MicroVM runnable-pkg and guests. custom ctx-pipeline.\n\n[flake-parts-modules](https://den.denful.dev/tutorials/flake-parts-modules): Den forward classes for third-party perSystem submodules: nix-unit on aspects, mightyiam/files generation, devshells, etc.\n\n[example](https://den.denful.dev/tutorials/example): cross-platform\n\n[ci](https://den.denful.dev/tutorials/ci): Each feature tested as code examples\n\n[bogus](https://den.denful.dev/tutorials/bogus): Isolated test for bug reproduction\n\n### Examples:\n\n\u003e Want yours featured? send me a DM via matrix or zulip (links at GH Discussions)\n\n[`@vic`](https://github.com/vic/vix): Fleet sharing user, author spends more time in Den itself. (-flakes +npins +auto-update +ci)\n\n[`@quasigod`](https://tangled.org/quasigod.xyz/nixconfig): Beautiful organization, uses custom Den namespaces and Den angle brackets (+flake-parts)\n\n[`@Gwenodai`](https://github.com/Gwenodai/nixos): Clever organization with path-naming conventions, custom guarded and forwarding classes\n\n[`@adda`](https://codeberg.org/Adda/nixos-config): Multiple hosts (+flake-parts +flake-file +home-manager +files)\n\n\u003e Den is also being used on internal infra at The European Commission.\n\nGrowing community adoption: [Usage Search](https://github.com/search?q=den.aspects+language%3ANix\u0026type=code)\n\n**❄️ Try it:**\n\n```console\n# Run virtio MicroVM from templates/microvm\nnix run github:denful/den?dir=templates/microvm#runnable-microvm\n```\n\n```console\n# Run NVF-Standalone neovim from templates/nvf-standalone\nnix run github:denful/den?dir=templates/nvf-standalone#my-neovim\n```\n\n```console\n# Run qemu VM from templates/example\nnix run github:denful/den\n```\n\n\u003c/td\u003e\n\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Testimonials\n\n\u003e Den takes the Dendritic pattern to a whole new level, and I cannot imagine going back.\\\n\u003e — `@adda` - Very early Den adopter after using Dendritic flake-parts and Unify.\n\n\u003e I’m super impressed with den so far, I’m excited to try out some new patterns that Unify couldn’t easily do.\\\n\u003e — `@quasigod` - Author of [Unify](https://codeberg.org/quasigod/unify) dendritic-framework, on adopting Den.\n\n\u003e Massive work you did here!\\\n\u003e — `@drupol` - Author of [“Flipping the Configuration Matrix”](https://not-a-number.io/2025/refactoring-my-infrastructure-as-code-configurations/#flipping-the-configuration-matrix) Dendritic blog post.\n\n\u003e Thanks for the awesome library and the support for non-flakes… it’s positively brilliant!. I really hope this gets wider adoption.\\\n\u003e — `@vczf` - At [`#den-lib:matrix.org`](https://matrix.to/#/#den-lib:matrix.org) channel.\n\n\u003e Den is a playground for some very advanced concepts. I’m convinced that some of its ideas will play a role in future Nix areas. In my opinion there are some raw diamonds in Den.\\\n\u003e — `@Doc-Steve` - Author of [Dendritic Design Guide](https://github.com/Doc-Steve/dendritic-design-with-flake-parts)\n\n## Code examples (OS configuration framework)\n\n### Defining hosts, users and homes.\n\nSimplest example, one-liner definitions.\n\n```nix\nden.hosts.x86_64-linux.lap.users.vic = {};\nden.hosts.aarch64-darwin.mac.users.vic = {};\nden.homes.aarch64-darwin.\"vic@mac\" = {};\n```\n\nThe `den.aspects.vic` aspect is shared between\nthese two hosts and standalone home-manager.\n\nThe `vic@mac` homeConfiguration has `osConfig = mac.config`.\n\nActivate with:\n\n```console\n$ nixos-rebuild  switch --flake .#lap\n$ darwin-rebuild switch --flake .#mac\n$ home-manager   switch --flake .#vic\n```\n\n### Extensible Schemas for hosts, users and homes.\n\nThese allow meta-configuration on entities, akin to\nwhat Dendritic flake-parts users do with top-level\noptions, but here scoped to each entity type.\n\nPeople use this for declaring host or user capabilities\nthat will later be used by aspects to implement configurations.\n\n```nix\n# extensible base modules for common, typed schemas\nden.schema.user = { user, lib, ... }: {\n  config.classes =\n    if user.userName == \"vic\" then [ \"hjem\" \"maid\" ]\n    else lib.mkDefault [ \"homeManager\" ];\n\n  options.mainGroup = lib.mkOption { default = user.userName; };\n};\n```\n\n### Dendritic Multi-Platform Hosts\n\nA single aspect like `den.aspects.workstation` can be\nshared between (included-at) NixOS/nix-Darwin/WSL hosts.\n\nEach aspect uses several Nix classes to define behaviour.\n\n```nix\n# modules/workstation.nix\n{ den, inputs, ... }: {\n  den.aspects.workstation = {\n    # re-usable configuration aspects. Den batteries and yours.\n    includes = [ den.batteries.hostname den.aspects.work-vpn ];\n\n    # regular nixos/darwin modules or any other Nix class\n    nixos  = { pkgs, ... }: { imports = [ inputs.disko.nixosModules.disko ]; };\n    darwin = { pkgs, ... }: { imports = [ inputs.nix-homebrew.darwinModules.nix-homebrew ]; };\n\n    # Custom Nix classes. `os` applies to both nixos and darwin.\n    # Contributed by @Risa-G.\n    # See https://den.denful.dev/guides/custom-classes/#user-contributed-examples\n    os = { pkgs, ... }: {\n      environment.systemPackages = [ pkgs.direnv ];\n    };\n\n    # host can contribute default home environments\n    # to all its users.\n    provides.to-users = {\n      homeManager = { pkgs, ... }: {\n        programs.vim.enable = true;\n        home.packages = [ pkgs.neovide ];\n      };\n    };\n  };\n}\n```\n\n### Multiple User Home Environments\n\nEach user can define configurations for different\nhome environments, aiding with migration from\nhomeManager to hjem or others.\n\n```nix\n# modules/vic.nix\n{ den, ... }: {\n\n  den.aspects.vic = {\n    # supports multiple home environments\n    homeManager = { pkgs, ... }: { };\n    hjem.files.\".envrc\".text = \"use flake ~/hk/home\";\n    maid.kconfig.settings.kwinrc.Desktops.Number = 3;\n\n    # user can contribute OS-configurations\n    # to all hosts it lives on\n    darwin.services.karabiner-elements.enable = true;\n\n    # user can specify config for specific host\n    provides.rog-tower = {\n      nixos = ...; # enable CUDA and gaming profile\n    };\n\n    # user class forwards into\n    # {nixos/darwin}.users.users.\u003cuserName\u003e\n    user = { pkgs, ... }: {\n      packages = [ pkgs.helix ];\n      description = \"oeiuwq\";\n    };\n\n    includes = [\n      den.batteries.primary-user        # re-usable batteries\n      (den.batteries.user-shell \"fish\") # parametric aspects\n      den.aspects.tiling-wm            # your own aspects\n      den.aspects.gaming.provides.emulators\n    ];\n  };\n}\n```\n\n### Custom Dendritic Nix Classes\n\n[Custom classes](https://den.denful.dev/guides/custom-classes) is how Den implements `user`, `homeManager`, `hjem`, `wsl`, `microvm` support. You can use the very same mechanism to create your own Nix classes.\n\nThe `den.batteries.forward` battery is the core of it.\n\n```nix\n# Example: A class for role-based configuration between users and hosts\n\nroleClass =\n  { host, user }:\n  { class, aspect-chain }:\n  den.batteries.forward {\n    each = lib.intersectLists (host.roles or []) (user.roles or []);\n    fromClass = lib.id;\n    intoClass = _: host.class;\n    intoPath = _: [ ];\n    fromAspect = _: lib.head aspect-chain;\n  };\n\nden.schema.user.includes = [ roleClass ];\n\nden.hosts.x86_64-linux.igloo = {\n  roles = [ \"devops\" \"gaming\" ];\n  users = {\n    alice.roles = [ \"gaming\" ];\n    bob.roles = [ \"devops\" ];\n  };\n};\n\nden.aspects.alice = {\n  # enabled when both support gaming role\n  gaming = { pkgs, ... }: { programs.steam.enable = true; };\n};\n\nden.aspects.bob = {\n  # enabled when both support devops role\n  devops = { pkgs, ... }: { virtualisation.podman.enable = true; };\n\n  # not enabled at igloo host (bob missing gaming role on that host)\n  gaming = {};\n};\n```\n\n### Guarded Forwarding Classes\n\nAny module/file can contribute to any aspects directly\ninto their feature-concern Nix classes, without\nhaving to deal with feature-detection or having\n`mkIf`/`mkMerge` clutterring on all the codebase.\n\nThe logic (guard) for conditional inclusion of a\nforwarded-class configuration is defined at a\nsingle place.\n\n#### Example: Platform Aware `homeManager` classes\n\nThis uses `pkgs.stdenv.isXYZ` to define `hmXYZ` classes,\nbecause some hm configurations might be only available\non specific platforms.\n\n```nix\n# aspect `tux` is used on both platforms\nden.hosts.x86_64-linux.igloo.users.tux = { };\nden.hosts.aarch64-darwin.apple.users.tux = { };\n\nden.aspects.hmPlatforms =\n  { class, aspect-chain }:\n  den.batteries.forward {\n    each = [ \"Linux\" \"Darwin\" ];\n    fromClass = platform: \"hm${platform}\";\n    intoClass = _: \"homeManager\";\n    intoPath = _: [ ];\n    fromAspect = _: lib.head aspect-chain;\n    guard = { pkgs, ... }: platform: lib.mkIf pkgs.stdenv.\"is${platform}\";\n    adaptArgs = { config, ... }: { osConfig = config; };\n  };\n\nden.aspects.tux = {\n  includes = [ den.aspects.hmPlatforms ];\n\n  hmDarwin = { pkgs, ... }: { home.packages = [ pkgs.iterm2 ]; };\n\n  hmLinux = { pkgs, ... }: { home.packages = [ pkgs.wl-clipboard-rs ]; };\n};\n```\n\n#### Example: Class for Impermanence Capability\n\nModules define configurations at aspects using the\n`persys` class directly, without any conditional.\n\nThe guard guarantees they are applied **only**\nwhen impermanence module is enabled at host.\n\n\u003e Inspired by @Doc-Steve\n\n```nix\npersys = { host }: den.batteries.forward {\n  each = lib.singleton true;\n  fromClass = _: \"persys\";\n  intoClass = _: host.class;\n  intoPath = _: [ \"environment\" \"persistence\" \"/nix/persist/system\" ];\n  fromAspect = _: den.aspects.${host.aspect};\n  guard = { options, config, ... }: options ? environment.persistence;\n};\n\n# enable on all hosts\nden.schema.host.includes = [ persys ];\n\n# aspects just attach config to custom class\nden.aspects.my-laptop.persys.hideMounts = true;\n```\n\n### User-defined Extensions to Den context pipeline.\n\nSee example [`template/microvm`](https://den.denful.dev/tutorials/microvm) for an example\nof custom `den.schema` and `den.policies` extensions for supporting\nDeclarative [MicroVM](https://microvm-nix.github.io/microvm.nix/declarative.html) guests with automatic host-shared `/nix/store`.\n\n```nix\nden.hosts.x86_64-linux.guest = {};\nden.hosts.x86_64-linux.host = {\n  microvm.guests = [ den.hosts.x86_64-linux.guest ];\n};\n\nden.aspects.guest = {\n  # propagated into host.nixos.microvm.vms.\u003cname\u003e;\n  microvm.autostart = true;\n\n  # guest supports all Den features.\n  includes = [ den.batteries.hostname ];\n  # As MicroVM guest propagated into host.nixos.microvm.vms.\u003cname\u003e.config;\n  nixos = { pkgs, ... }: { environment.systemPackages = [ pkgs.hello ]; };\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenful%2Fden","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenful%2Fden","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenful%2Fden/lists"}