Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs for flake outputs from aspects

+54 -6
+54 -6
docs/src/content/docs/reference/output.mdx
··· 3 3 description: How Den builds flake outputs from host and home declarations. 4 4 --- 5 5 6 - import { Aside } from '@astrojs/starlight/components'; 6 + import { Aside, Steps } from '@astrojs/starlight/components'; 7 7 8 8 <Aside title="Source" icon="github"> 9 - [`modules/config.nix`](https://github.com/vic/den/blob/main/modules/config.nix) -- 10 - [`modules/output.nix`](https://github.com/vic/den/blob/main/modules/output.nix) 9 + [`modules/outputs/*.nix`](https://github.com/vic/den/blob/main/modules/outputs) -- 10 + [`modules/outputs.nix`](https://github.com/vic/den/blob/main/modules/outputs.nix) -- 11 + [`per system tests`](https://github.com/vic/den/blob/main/templates/ci/modules/features/forward-flake-level.nix) 11 12 </Aside> 12 13 13 14 ## Build pipeline ··· 55 56 56 57 The result lands at `flake.homeConfigurations.<name>` by default. 57 58 58 - ## `output.nix` -- flake-parts compatibility 59 + ## `outputs.nix` -- flake-parts compatibility 59 60 60 61 When `inputs.flake-parts` is absent, Den defines its own `options.flake` 61 - option (adapted from flake-parts, MIT licensed) so that output generation 62 - works identically with or without flake-parts. 62 + option so that output generation works identically with or without flake-parts. 63 63 64 64 This means Den can produce `nixosConfigurations`, `darwinConfigurations`, 65 65 `homeConfigurations`, and any custom output attribute regardless of ··· 75 75 }; 76 76 ``` 77 77 78 + Use `intoAttr = [ ]` to skip placing the configuration. 79 + 78 80 ## Custom instantiation 79 81 80 82 Override `instantiate` to use a different builder or add `specialArgs`: ··· 84 86 instantiate = inputs.nixos-unstable.lib.nixosSystem; 85 87 }; 86 88 ``` 89 + 90 + ## Flake outputs like `packages`, `checks`, etc. 91 + 92 + Den aspects can directly contribute to `packages` and similar flake outputs. 93 + 94 + The following example are for `packages` but same applies for `checks`, `devShells`, 95 + `legacyPackages` and other per system outputs. 96 + 97 + <Steps> 98 + 99 + 1. Define `flake.packages` output. 100 + 101 + This is only needed if you don't use flake-parts and will have more than one package, 102 + because the Nix module system needs to know how to merge both output definitions: 103 + 104 + ```nix 105 + # modules/outputs.nix 106 + { inputs, ... }: 107 + { 108 + imports = [ inputs.den.flakeOutputs.packages ]; 109 + } 110 + ``` 111 + 112 + 2. Allow aspects to produce `packages`. 113 + 114 + ```nix 115 + # ANY Host or User aspect can produce outputs: 116 + den.ctx.flake-system.into.host = { system }: 117 + map (host: { inherit host; }) 118 + (lib.attrValues den.hosts.${system}); 119 + 120 + # ONLY foo aspect can produce packages: 121 + den.ctx.flake-packages.includes = [ den.aspects.foo ]; 122 + ``` 123 + 124 + 3. Use the `packages` class on your aspects: 125 + 126 + ```nix 127 + den.aspects.foo = { 128 + packages = { pkgs, ... }: { inherit (pkgs) hello; }; 129 + }; 130 + ``` 131 + 132 + </Steps> 133 + 134 + See [`forward-flake-level.nix`](https://github.com/vic/den/blob/main/templates/ci/modules/features/forward-flake-level.nix) for all examples.