Generate flake.nix from module options. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ dendrix.oeiuwq.com/Dendritic.html
dendritic nix inputs

Compare changes

Choose any two refs to compare.

+218 -239
-1
.github/FUNDING.yml
··· 1 # These are supported funding model platforms 2 - 3 github: [vic] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 patreon: # Replace with a single Patreon username 5 open_collective: # Replace with a single Open Collective username
··· 1 # These are supported funding model platforms 2 github: [vic] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 3 patreon: # Replace with a single Patreon username 4 open_collective: # Replace with a single Open Collective username
+3 -3
.github/workflows/flake-check.yaml
··· 25 template: ${{ fromJSON(needs.find-templates.outputs.templates) }} 26 steps: 27 - uses: wimpysworld/nothing-but-nix@main 28 - - uses: DeterminateSystems/nix-installer-action@main 29 - uses: DeterminateSystems/magic-nix-cache-action@main 30 - run: | 31 set -uveo pipefail ··· 50 steps: 51 - uses: actions/checkout@v4 52 - uses: wimpysworld/nothing-but-nix@main 53 - - uses: DeterminateSystems/nix-installer-action@main 54 - uses: DeterminateSystems/magic-nix-cache-action@main 55 - run: cd dev && nix flake check && nix flake metadata && nix flake check 56 nix-fmt: ··· 59 steps: 60 - uses: actions/checkout@v4 61 - uses: wimpysworld/nothing-but-nix@main 62 - - uses: DeterminateSystems/nix-installer-action@main 63 - uses: DeterminateSystems/magic-nix-cache-action@main 64 - run: nix run -L ./dev#fmt -- --ci
··· 25 template: ${{ fromJSON(needs.find-templates.outputs.templates) }} 26 steps: 27 - uses: wimpysworld/nothing-but-nix@main 28 + - uses: cachix/install-nix-action@v31 29 - uses: DeterminateSystems/magic-nix-cache-action@main 30 - run: | 31 set -uveo pipefail ··· 50 steps: 51 - uses: actions/checkout@v4 52 - uses: wimpysworld/nothing-but-nix@main 53 + - uses: cachix/install-nix-action@v31 54 - uses: DeterminateSystems/magic-nix-cache-action@main 55 - run: cd dev && nix flake check && nix flake metadata && nix flake check 56 nix-fmt: ··· 59 steps: 60 - uses: actions/checkout@v4 61 - uses: wimpysworld/nothing-but-nix@main 62 + - uses: cachix/install-nix-action@v31 63 - uses: DeterminateSystems/magic-nix-cache-action@main 64 - run: nix run -L ./dev#fmt -- --ci
+12
.tangled/workflows/mirror.yml
···
··· 1 + when: 2 + - event: ["push"] 3 + branch: ["*"] 4 + engine: "nixery" 5 + clone: 6 + skip: true 7 + dependencies: 8 + nixpkgs: 9 + - gh 10 + steps: 11 + - name: mirror 12 + command: gh -R vic/vic issue comment 3 -b flake-file
+50 -27
README.md
··· 1 <!-- Badges --> 2 <p align="right"> 3 - <a href="https://nixos.org/"> <img src="https://img.shields.io/badge/Nix-Flake-informational?logo=nixos&logoColor=white" alt="Nix Flake"/> </a> 4 <a href="https://github.com/vic/flake-file/actions"> 5 <img src="https://github.com/vic/flake-file/workflows/flake-check/badge.svg" alt="CI Status"/> </a> 6 <a href="LICENSE"> <img src="https://img.shields.io/github/license/vic/flake-file" alt="License"/> </a> ··· 8 9 # flake-file โ€” Generate flake.nix from flake-parts modules. 10 11 **flake-file** lets you generate a clean, maintainable `flake.nix` from modular options, using [flake-parts](https://flake.parts/). 12 13 It makes your flake configuration modular and based on the Nix module system. This means you can use 14 `lib.mkDefault` or anything you normally do with Nix modules, and have them reflected in flake schema values. 15 16 <table><tr><td> 17 - 18 ## Features 19 20 - Flake definition aggregated from all flake-parts modules. ··· 99 # That's it! Importing this module will add dendritic-setup inputs to your flake. 100 imports = [ inputs.flake-file.flakeModules.dendritic ]; 101 102 - # Define flake attributes on any flake-pars module: 103 flake-file = { 104 description = "My Awesome Flake"; 105 inputs.nixpkgs.url = lib.mkDefault "github:NixOS/nixpkgs/nixpkgs-unstable"; ··· 138 139 - Includes flakeModules.default. 140 - Includes flakeModules.import-tree. 141 - - Includes flakeModules.nix-auto-follow. 142 - Enables [`flake-parts`](https://github.com/hercules-ci/flake-parts). 143 - - Enables [`flake-aspects`](https://github.com/vic/flake-aspects). 144 - - Enables [`den`](https://github.com/vic/den). 145 - - Sets `output` function to `import-tree ./modules`. 146 - - Adds `treefmt-nix` input. 147 - - Enables formatters: `nixfmt`, `deadnix`, and `nixf-diagnose`. 148 149 ### Flake Templates 150 ··· 190 191 Options use the same attributes as the flake schema. See below for details. 192 193 - | Option | Description | 194 - | ----------------------------------------------- | --------------------------------- | 195 - | `flake-file.description` | Sets the flake description | 196 - | `flake-file.nixConfig` | Attrset for flake-level nixConfig | 197 - | `flake-file.inputs.<name>.url` | URL for a flake input | 198 - | `flake-file.inputs.<name>.flake` | Boolean, is input a flake? | 199 - | `flake-file.inputs.<name>.inputs.<dep>.follows` | Tree of dependencies to follow | 200 201 Example: 202 203 ```nix 204 flake-file = { 205 description = "my awesome flake"; 206 - nixConfig = {}; # an attrset. currently not typed. 207 inputs.<name>.url = "github:foo/bar"; 208 inputs.<name>.flake = false; 209 inputs.<name>.inputs.nixpkgs.follows = "nixpkgs"; ··· 215 216 --- 217 218 - ## About the Flake `output` function 219 220 - The `flake-file.output` option is a literal Nix expression. You cannot convert a Nix function value into a string for including in the generated flake file. 221 222 It defaults to: 223 ··· 269 270 ## Automatic flake.lock flattening 271 272 - You can use the `prune-lock` [options](https://github.com/vic/flake-file/blob/main/modules/options.nix) 273 to specify a command that `flake-file` will use whenever your flake.nix file is generated 274 to flatten your flake.lock dependency tree. 275 ··· 284 imports = [ 285 inputs.flake-file.flakeModules.nix-auto-follow 286 # or optionally 287 - #inputs.flake-file.flakeModules.allfollow 288 ]; 289 } 290 ``` ··· 296 This section outlines the recommended steps for adopting `flake-file` in your own repository. 297 298 1. **Prerequisite:** Ensure you have already adopted [flake-parts](https://flake.parts). 299 - 2. **Add Inputs:** In your current `flake.nix`, add the following input: 300 301 ```nix 302 flake-file.url = "github:vic/flake-file"; 303 ``` 304 305 - 3. **Move Outputs:** Copy the contents of your `outputs` function into a file `./outputs.nix`: 306 307 ```nix 308 # outputs.nix -- this is the contents of your `outputs` function from the original flake.nix file. ··· 315 } 316 ``` 317 318 - 4. **Move Inputs:** Copy your current flake.nix file as a flake-parts module (e.g., `modules/inputs.nix`): 319 320 > [!IMPORTANT] 321 > Make sure you `git add` so that new files are visible to Nix. ··· 339 ``` 340 341 5. **Backup:** Back up your flake.nix into flake.nix.bak before regenerating it. 342 - 6. **Generate:** Execute `nix run .#write-flake` to generate flake.nix. 343 - 7. **Verify:** Check flake.nix and if everything is okay, remove the backup file. 344 345 You are done! Now you can split dependencies from `modules/inputs.nix` into other flake-part modules as you see fit: 346 ··· 378 379 --- 380 381 - Made with <3 by [@vic](https://x.com/oeiuwq)
··· 1 <!-- Badges --> 2 + 3 <p align="right"> 4 + <a href="https://github.com/sponsors/vic"><img src="https://img.shields.io/badge/sponsor-vic-white?logo=githubsponsors&logoColor=white&labelColor=%23FF0000" alt="Sponsor Vic"/> 5 + </a> 6 + <a href="https://vic.github.io/dendrix/Dendritic-Ecosystem.html#vics-dendritic-libraries"> <img src="https://img.shields.io/badge/Dendritic-Nix-informational?logo=nixos&logoColor=white" alt="Dendritic Nix"/> </a> 7 <a href="https://github.com/vic/flake-file/actions"> 8 <img src="https://github.com/vic/flake-file/workflows/flake-check/badge.svg" alt="CI Status"/> </a> 9 <a href="LICENSE"> <img src="https://img.shields.io/github/license/vic/flake-file" alt="License"/> </a> ··· 11 12 # flake-file โ€” Generate flake.nix from flake-parts modules. 13 14 + > `flake-file` and [vic](https://bsky.app/profile/oeiuwq.bsky.social)'s [dendritic libs](https://vic.github.io/dendrix/Dendritic-Ecosystem.html#vics-dendritic-libraries) made for you with Love++ and AI--. If you like my work, consider [sponsoring](https://github.com/sponsors/vic) 15 + 16 **flake-file** lets you generate a clean, maintainable `flake.nix` from modular options, using [flake-parts](https://flake.parts/). 17 18 It makes your flake configuration modular and based on the Nix module system. This means you can use 19 `lib.mkDefault` or anything you normally do with Nix modules, and have them reflected in flake schema values. 20 21 <table><tr><td> 22 + 23 ## Features 24 25 - Flake definition aggregated from all flake-parts modules. ··· 104 # That's it! Importing this module will add dendritic-setup inputs to your flake. 105 imports = [ inputs.flake-file.flakeModules.dendritic ]; 106 107 + # Define flake attributes on any flake-parts module: 108 flake-file = { 109 description = "My Awesome Flake"; 110 inputs.nixpkgs.url = lib.mkDefault "github:NixOS/nixpkgs/nixpkgs-unstable"; ··· 143 144 - Includes flakeModules.default. 145 - Includes flakeModules.import-tree. 146 - Enables [`flake-parts`](https://github.com/hercules-ci/flake-parts). 147 + - Sets `outputs` to `inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules)`. 148 + 149 + > Previously, this module included `flake-aspects` and `den` as dependencies. It now provides a pure flake-parts Dendritic setup. If you need the complete [den](https://github.com/vic/den) functionality, use den's `flakeModules.dendritic` instead. 150 151 ### Flake Templates 152 ··· 192 193 Options use the same attributes as the flake schema. See below for details. 194 195 + | Option | Description | 196 + | ------------------------------------------------- | ----------------------------------------------------------- | 197 + | `flake-file.description` | Sets the flake description | 198 + | `flake-file.nixConfig` | Flake-level `nixConfig` (typed attrset) | 199 + | `flake-file.outputs` | Literal Nix code for `outputs` function | 200 + | `flake-file.formatter` | Function: `pkgs -> program` to format generated `flake.nix` | 201 + | `flake-file.do-not-edit` | Header comment added atop generated file | 202 + | `flake-file.inputs.<name>.url` | Source URL (e.g. `github:owner/repo`) | 203 + | `flake-file.inputs.<name>.type` | Reference type (`github`, `path`, etc.) | 204 + | `flake-file.inputs.<name>.owner` | Owner (for typed VCS refs) | 205 + | `flake-file.inputs.<name>.repo` | Repo name | 206 + | `flake-file.inputs.<name>.path` | Local path reference | 207 + | `flake-file.inputs.<name>.id` | Flake registry id | 208 + | `flake-file.inputs.<name>.dir` | Subdirectory within repo/path | 209 + | `flake-file.inputs.<name>.narHash` | NAR hash pin | 210 + | `flake-file.inputs.<name>.rev` | Commit hash pin | 211 + | `flake-file.inputs.<name>.ref` | Branch or tag pin | 212 + | `flake-file.inputs.<name>.host` | Custom host for git forges | 213 + | `flake-file.inputs.<name>.submodules` | Whether to fetch git submodules | 214 + | `flake-file.inputs.<name>.flake` | Boolean: is it a flake? (default true) | 215 + | `flake-file.inputs.<name>.follows` | Follow another input's value | 216 + | `flake-file.inputs.<name>.inputs.<dep>.follows` | Nested input follow tree | 217 + | `flake-file.inputs.<name>.inputs.<dep>.inputs...` | Recursively follow deeper deps | 218 + | `flake-file.write-hooks` | List of ordered hooks (by `index`) after writing | 219 + | `flake-file.check-hooks` | List of ordered hooks (by `index`) during check | 220 + | `flake-file.prune-lock.enable` | Enable automatic flake.lock pruning | 221 + | `flake-file.prune-lock.program` | Function building pruning executable | 222 223 Example: 224 225 ```nix 226 flake-file = { 227 description = "my awesome flake"; 228 + nixConfig = {}; # attrset (free-form, typed as attrs) 229 inputs.<name>.url = "github:foo/bar"; 230 inputs.<name>.flake = false; 231 inputs.<name>.inputs.nixpkgs.follows = "nixpkgs"; ··· 237 238 --- 239 240 + ## About the Flake `outputs` function 241 242 + The `flake-file.outputs` option is a literal Nix expression. You cannot convert a Nix function value into a string for including in the generated flake file. 243 244 It defaults to: 245 ··· 291 292 ## Automatic flake.lock flattening 293 294 + You can use the `prune-lock` [options](https://github.com/vic/flake-file/blob/main/modules/options/prune-lock.nix) 295 to specify a command that `flake-file` will use whenever your flake.nix file is generated 296 to flatten your flake.lock dependency tree. 297 ··· 306 imports = [ 307 inputs.flake-file.flakeModules.nix-auto-follow 308 # or optionally 309 + # inputs.flake-file.flakeModules.allfollow 310 ]; 311 } 312 ``` ··· 318 This section outlines the recommended steps for adopting `flake-file` in your own repository. 319 320 1. **Prerequisite:** Ensure you have already adopted [flake-parts](https://flake.parts). 321 + 322 + 1. **Add Inputs:** In your current `flake.nix`, add the following input: 323 324 ```nix 325 flake-file.url = "github:vic/flake-file"; 326 ``` 327 328 + 1. **Move Outputs:** Copy the contents of your `outputs` function into a file `./outputs.nix`: 329 330 ```nix 331 # outputs.nix -- this is the contents of your `outputs` function from the original flake.nix file. ··· 338 } 339 ``` 340 341 + 1. **Move Inputs:** Copy your current flake.nix file as a flake-parts module (e.g., `modules/inputs.nix`): 342 343 > [!IMPORTANT] 344 > Make sure you `git add` so that new files are visible to Nix. ··· 362 ``` 363 364 5. **Backup:** Back up your flake.nix into flake.nix.bak before regenerating it. 365 + 1. **Generate:** Execute `nix run .#write-flake` to generate flake.nix. 366 + 1. **Verify:** Check flake.nix and if everything is okay, remove the backup file. 367 368 You are done! Now you can split dependencies from `modules/inputs.nix` into other flake-part modules as you see fit: 369 ··· 401 402 --- 403 404 + Made with \<3 by [@vic](https://x.com/oeiuwq)
+40 -50
dev/flake.lock
··· 1 { 2 "nodes": { 3 - "den": { 4 - "locked": { 5 - "lastModified": 1761530965, 6 - "narHash": "sha256-ieTMY6bsJbl87/XugjWFid6EN9q1C0rFdaPoYCfm1Kk=", 7 - "owner": "vic", 8 - "repo": "den", 9 - "rev": "ef58a62952eaf82f391dbe24ec693996d5abc505", 10 - "type": "github" 11 - }, 12 - "original": { 13 - "owner": "vic", 14 - "repo": "den", 15 - "type": "github" 16 - } 17 - }, 18 "devshell": { 19 "inputs": { 20 "nixpkgs": [ ··· 22 ] 23 }, 24 "locked": { 25 - "lastModified": 1741473158, 26 - "narHash": "sha256-kWNaq6wQUbUMlPgw8Y+9/9wP0F8SHkjy24/mN3UAppg=", 27 "owner": "numtide", 28 "repo": "devshell", 29 - "rev": "7c9e793ebe66bcba8292989a68c0419b737a22a0", 30 "type": "github" 31 }, 32 "original": { ··· 35 "type": "github" 36 } 37 }, 38 - "flake-aspects": { 39 - "locked": { 40 - "lastModified": 1761515738, 41 - "narHash": "sha256-uW/vyyZDt9UvJbC0xghkjZhuuSnJui/fevMbKsvXV6k=", 42 - "owner": "vic", 43 - "repo": "flake-aspects", 44 - "rev": "0fb045faceaeefa83a85173fd0c4ebf4d47a6d9d", 45 - "type": "github" 46 - }, 47 - "original": { 48 - "owner": "vic", 49 - "repo": "flake-aspects", 50 - "type": "github" 51 - } 52 - }, 53 "flake-file": { 54 "locked": { 55 "path": "..", ··· 68 ] 69 }, 70 "locked": { 71 - "lastModified": 1760948891, 72 - "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", 73 "owner": "hercules-ci", 74 "repo": "flake-parts", 75 - "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", 76 "type": "github" 77 }, 78 "original": { ··· 83 }, 84 "import-tree": { 85 "locked": { 86 - "lastModified": 1761120675, 87 - "narHash": "sha256-TEbh9zISiQcU82VwVoEbmXHnSGlUxTwvjJA9g9ErSDA=", 88 "owner": "vic", 89 "repo": "import-tree", 90 - "rev": "a037ed2a58fc0ebed9e93b9ef79b0646e648f719", 91 "type": "github" 92 }, 93 "original": { ··· 116 "type": "github" 117 } 118 }, 119 "nix-unit": { 120 "inputs": { 121 "flake-parts": [ 122 "flake-parts" 123 ], 124 "nixpkgs": [ 125 "nixpkgs" 126 ], ··· 129 ] 130 }, 131 "locked": { 132 - "lastModified": 1757781724, 133 - "narHash": "sha256-DP5SCFx0AsbPnT7KzEl3gQNWPF70Tlcc+jtLkqupabI=", 134 "owner": "nix-community", 135 "repo": "nix-unit", 136 - "rev": "7a952131cbef9cb21953ae70ad09249541848f07", 137 "type": "github" 138 }, 139 "original": { ··· 144 }, 145 "nixpkgs": { 146 "locked": { 147 - "lastModified": 1761349956, 148 - "narHash": "sha256-tH3wHnOJms+U4k/rK2Nn1RfBrhffX92jLP/2VndSn0w=", 149 "owner": "nixos", 150 "repo": "nixpkgs", 151 - "rev": "02f2cb8e0feb4596d20cc52fda73ccee960e3538", 152 "type": "github" 153 }, 154 "original": { ··· 160 }, 161 "root": { 162 "inputs": { 163 - "den": "den", 164 "devshell": "devshell", 165 - "flake-aspects": "flake-aspects", 166 "flake-file": "flake-file", 167 "flake-parts": "flake-parts", 168 "import-tree": "import-tree", ··· 198 ] 199 }, 200 "locked": { 201 - "lastModified": 1761311587, 202 - "narHash": "sha256-Msq86cR5SjozQGCnC6H8C+0cD4rnx91BPltZ9KK613Y=", 203 "owner": "numtide", 204 "repo": "treefmt-nix", 205 - "rev": "2eddae033e4e74bf581c2d1dfa101f9033dbd2dc", 206 "type": "github" 207 }, 208 "original": {
··· 1 { 2 "nodes": { 3 "devshell": { 4 "inputs": { 5 "nixpkgs": [ ··· 7 ] 8 }, 9 "locked": { 10 + "lastModified": 1762521437, 11 + "narHash": "sha256-RXN+lcx4DEn3ZS+LqEJSUu/HH+dwGvy0syN7hTo/Chg=", 12 "owner": "numtide", 13 "repo": "devshell", 14 + "rev": "07bacc9531f5f4df6657c0a02a806443685f384a", 15 "type": "github" 16 }, 17 "original": { ··· 20 "type": "github" 21 } 22 }, 23 "flake-file": { 24 "locked": { 25 "path": "..", ··· 38 ] 39 }, 40 "locked": { 41 + "lastModified": 1762980239, 42 + "narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=", 43 "owner": "hercules-ci", 44 "repo": "flake-parts", 45 + "rev": "52a2caecc898d0b46b2b905f058ccc5081f842da", 46 "type": "github" 47 }, 48 "original": { ··· 53 }, 54 "import-tree": { 55 "locked": { 56 + "lastModified": 1763695721, 57 + "narHash": "sha256-tMfN/JkwWJ129cXDW+lK2gUcjklJ+LpTHj9LlneJRXg=", 58 "owner": "vic", 59 "repo": "import-tree", 60 + "rev": "ca69d64711265c68cf71f6c029ab9f1a55a767f8", 61 "type": "github" 62 }, 63 "original": { ··· 86 "type": "github" 87 } 88 }, 89 + "nix-github-actions": { 90 + "inputs": { 91 + "nixpkgs": [ 92 + "nix-unit", 93 + "nixpkgs" 94 + ] 95 + }, 96 + "locked": { 97 + "lastModified": 1737420293, 98 + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", 99 + "owner": "nix-community", 100 + "repo": "nix-github-actions", 101 + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", 102 + "type": "github" 103 + }, 104 + "original": { 105 + "owner": "nix-community", 106 + "repo": "nix-github-actions", 107 + "type": "github" 108 + } 109 + }, 110 "nix-unit": { 111 "inputs": { 112 "flake-parts": [ 113 "flake-parts" 114 ], 115 + "nix-github-actions": "nix-github-actions", 116 "nixpkgs": [ 117 "nixpkgs" 118 ], ··· 121 ] 122 }, 123 "locked": { 124 + "lastModified": 1762774186, 125 + "narHash": "sha256-hRADkHjNt41+JUHw2EiSkMaL4owL83g5ZppjYUdF/Dc=", 126 "owner": "nix-community", 127 "repo": "nix-unit", 128 + "rev": "1c9ab50554eed0b768f9e5b6f646d63c9673f0f7", 129 "type": "github" 130 }, 131 "original": { ··· 136 }, 137 "nixpkgs": { 138 "locked": { 139 + "lastModified": 1763618868, 140 + "narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=", 141 "owner": "nixos", 142 "repo": "nixpkgs", 143 + "rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942", 144 "type": "github" 145 }, 146 "original": { ··· 152 }, 153 "root": { 154 "inputs": { 155 "devshell": "devshell", 156 "flake-file": "flake-file", 157 "flake-parts": "flake-parts", 158 "import-tree": "import-tree", ··· 188 ] 189 }, 190 "locked": { 191 + "lastModified": 1762938485, 192 + "narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=", 193 "owner": "numtide", 194 "repo": "treefmt-nix", 195 + "rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", 196 "type": "github" 197 }, 198 "original": {
+12 -50
dev/flake.nix
··· 5 outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); 6 7 inputs = { 8 - den = { 9 - url = "github:vic/den"; 10 - }; 11 devshell = { 12 - inputs = { 13 - nixpkgs = { 14 - follows = "nixpkgs"; 15 - }; 16 - }; 17 url = "github:numtide/devshell"; 18 }; 19 - flake-aspects = { 20 - url = "github:vic/flake-aspects"; 21 - }; 22 - flake-file = { 23 - url = "path:.."; 24 - }; 25 flake-parts = { 26 - inputs = { 27 - nixpkgs-lib = { 28 - follows = "nixpkgs-lib"; 29 - }; 30 - }; 31 url = "github:hercules-ci/flake-parts"; 32 }; 33 - import-tree = { 34 - url = "github:vic/import-tree"; 35 - }; 36 nix-auto-follow = { 37 - inputs = { 38 - nixpkgs = { 39 - follows = "nixpkgs"; 40 - }; 41 - }; 42 url = "github:fzakaria/nix-auto-follow"; 43 }; 44 nix-unit = { 45 inputs = { 46 - flake-parts = { 47 - follows = "flake-parts"; 48 - }; 49 - nixpkgs = { 50 - follows = "nixpkgs"; 51 - }; 52 - treefmt-nix = { 53 - follows = "treefmt-nix"; 54 - }; 55 }; 56 url = "github:nix-community/nix-unit"; 57 }; 58 - nixpkgs = { 59 - url = "github:nixos/nixpkgs/nixpkgs-unstable"; 60 - }; 61 - nixpkgs-lib = { 62 - follows = "nixpkgs"; 63 - }; 64 - systems = { 65 - url = "github:nix-systems/default"; 66 - }; 67 treefmt-nix = { 68 - inputs = { 69 - nixpkgs = { 70 - follows = "nixpkgs"; 71 - }; 72 - }; 73 url = "github:numtide/treefmt-nix"; 74 }; 75 };
··· 5 outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); 6 7 inputs = { 8 devshell = { 9 + inputs.nixpkgs.follows = "nixpkgs"; 10 url = "github:numtide/devshell"; 11 }; 12 + flake-file.url = "path:.."; 13 flake-parts = { 14 + inputs.nixpkgs-lib.follows = "nixpkgs-lib"; 15 url = "github:hercules-ci/flake-parts"; 16 }; 17 + import-tree.url = "github:vic/import-tree"; 18 nix-auto-follow = { 19 + inputs.nixpkgs.follows = "nixpkgs"; 20 url = "github:fzakaria/nix-auto-follow"; 21 }; 22 nix-unit = { 23 inputs = { 24 + flake-parts.follows = "flake-parts"; 25 + nixpkgs.follows = "nixpkgs"; 26 + treefmt-nix.follows = "treefmt-nix"; 27 }; 28 url = "github:nix-community/nix-unit"; 29 }; 30 + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 31 + nixpkgs-lib.follows = "nixpkgs"; 32 + systems.url = "github:nix-systems/default"; 33 treefmt-nix = { 34 + inputs.nixpkgs.follows = "nixpkgs"; 35 url = "github:numtide/treefmt-nix"; 36 }; 37 };
+5 -2
dev/modules/_lib/default.nix
··· 41 _: input: 42 mergeNonEmptyAttrs input { 43 follows = { 44 - testEmpty = v: v == null; # allow empty follows string 45 }; 46 inputs = nonEmptyInputs input; 47 } ··· 52 mergeNonEmptyAttrs input { 53 url = { }; 54 type = { }; 55 owner = { }; 56 repo = { }; 57 path = { }; ··· 67 flake = false; 68 }; 69 }; 70 - follows = { }; 71 inputs = nonEmptyInputs input; 72 } 73 );
··· 41 _: input: 42 mergeNonEmptyAttrs input { 43 follows = { 44 + testEmpty = v: !builtins.isString v; 45 }; 46 inputs = nonEmptyInputs input; 47 } ··· 52 mergeNonEmptyAttrs input { 53 url = { }; 54 type = { }; 55 + submodules = { }; 56 owner = { }; 57 repo = { }; 58 path = { }; ··· 68 flake = false; 69 }; 70 }; 71 + follows = { 72 + testEmpty = x: !builtins.isString x; 73 + }; 74 inputs = nonEmptyInputs input; 75 } 76 );
+36 -2
dev/modules/formatter.nix
··· 1 - { inputs, ... }: 2 { 3 - perSystem.treefmt.projectRoot = inputs.flake-file; 4 }
··· 1 + { inputs, lib, ... }: 2 { 3 + 4 + imports = [ 5 + inputs.flake-file.flakeModules.nix-auto-follow 6 + inputs.treefmt-nix.flakeModule 7 + ]; 8 + 9 + flake-file.inputs = { 10 + treefmt-nix.url = lib.mkDefault "github:numtide/treefmt-nix"; 11 + treefmt-nix.inputs.nixpkgs.follows = lib.mkDefault "nixpkgs"; 12 + }; 13 + 14 + perSystem = 15 + { self', ... }: 16 + { 17 + packages.fmt = self'.formatter; 18 + treefmt = { 19 + projectRoot = inputs.flake-file; 20 + programs = { 21 + nixfmt.enable = true; 22 + deadnix.enable = true; 23 + nixf-diagnose.enable = true; 24 + prettier.enable = true; 25 + }; 26 + settings.on-unmatched = lib.mkDefault "fatal"; 27 + settings.global.excludes = [ 28 + "LICENSE" 29 + "flake.lock" 30 + "*/flake.lock" 31 + ".envrc" 32 + ".direnv/*" 33 + "*/.gitignore" 34 + ]; 35 + }; 36 + }; 37 + 38 }
+1 -1
dev/modules/regen.nix
··· 3 perSystem = 4 { pkgs, ... }: 5 let 6 - exe = name: pkgs.lib.getExe inputs.self.packages.${pkgs.system}.${name}; 7 puke = exe "puke"; 8 oneach = exe "oneach"; 9 each = exe "each";
··· 3 perSystem = 4 { pkgs, ... }: 5 let 6 + exe = name: pkgs.lib.getExe inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.${name}; 7 puke = exe "puke"; 8 oneach = exe "oneach"; 9 each = exe "each";
+11
dev/modules/unit-tests/inputsExpr.nix
··· 68 }; 69 }; 70 71 in 72 { 73 flake = { inherit tests; };
··· 68 }; 69 }; 70 71 + tests.inputsExpr."test top-input follows empty" = { 72 + expr = inputsExpr { 73 + foo.url = "foo"; 74 + bar.follows = ""; 75 + }; 76 + expected = { 77 + foo.url = "foo"; 78 + bar.follows = ""; 79 + }; 80 + }; 81 + 82 in 83 { 84 flake = { inherit tests; };
-1
modules/dendritic/basic.nix
··· 4 imports = [ 5 inputs.flake-file.flakeModules.default 6 inputs.flake-file.flakeModules.import-tree 7 - inputs.flake-file.flakeModules.nix-auto-follow 8 ]; 9 10 flake-file.inputs = {
··· 4 imports = [ 5 inputs.flake-file.flakeModules.default 6 inputs.flake-file.flakeModules.import-tree 7 ]; 8 9 flake-file.inputs = {
-1
modules/dendritic/default.nix
··· 3 imports = [ 4 ./dendritic.nix 5 ./basic.nix 6 - ./formatter.nix 7 ./nixpkgs.nix 8 ./systems.nix 9 ];
··· 3 imports = [ 4 ./dendritic.nix 5 ./basic.nix 6 ./nixpkgs.nix 7 ./systems.nix 8 ];
+2 -4
modules/dendritic/dendritic.nix
··· 4 imports = [ 5 (inputs.flake-parts.flakeModules.modules or { }) 6 (inputs.flake-file.flakeModules.import-tree or { }) 7 - (inputs.flake-aspects.flakeModule or { }) 8 - (inputs.den.flakeModule or { }) 9 ]; 10 11 flake-file.inputs = { 12 flake-parts.url = lib.mkDefault "github:hercules-ci/flake-parts"; 13 flake-parts.inputs.nixpkgs-lib.follows = lib.mkDefault "nixpkgs-lib"; 14 - flake-aspects.url = lib.mkDefault "github:vic/flake-aspects"; 15 - den.url = lib.mkDefault "github:vic/den"; 16 }; 17 18 flake-file.outputs = '' 19 inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules) 20 ''; 21 22 }
··· 4 imports = [ 5 (inputs.flake-parts.flakeModules.modules or { }) 6 (inputs.flake-file.flakeModules.import-tree or { }) 7 ]; 8 9 flake-file.inputs = { 10 flake-parts.url = lib.mkDefault "github:hercules-ci/flake-parts"; 11 flake-parts.inputs.nixpkgs-lib.follows = lib.mkDefault "nixpkgs-lib"; 12 }; 13 14 flake-file.outputs = '' 15 inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules) 16 ''; 17 + 18 + flake.modules = { }; 19 20 }
-36
modules/dendritic/formatter.nix
··· 1 - { inputs, lib, ... }: 2 - { 3 - 4 - imports = [ 5 - inputs.treefmt-nix.flakeModule 6 - ]; 7 - 8 - flake-file.inputs = { 9 - treefmt-nix.url = lib.mkDefault "github:numtide/treefmt-nix"; 10 - treefmt-nix.inputs.nixpkgs.follows = lib.mkDefault "nixpkgs"; 11 - }; 12 - 13 - perSystem = 14 - { self', ... }: 15 - { 16 - packages.fmt = self'.formatter; 17 - treefmt = { 18 - programs = { 19 - nixfmt.enable = true; 20 - deadnix.enable = true; 21 - nixf-diagnose.enable = true; 22 - prettier.enable = true; 23 - }; 24 - settings.on-unmatched = lib.mkDefault "fatal"; 25 - settings.global.excludes = [ 26 - "LICENSE" 27 - "flake.lock" 28 - "*/flake.lock" 29 - ".envrc" 30 - ".direnv/*" 31 - "*/.gitignore" 32 - ]; 33 - }; 34 - }; 35 - 36 - }
···
+7 -2
modules/options/inputs.nix
··· 2 let 3 follows-option = lib.mkOption { 4 description = "flake input path to follow"; 5 - default = ""; 6 - type = lib.types.str; 7 }; 8 9 inputs-follow-option = lib.mkOption { ··· 46 "sourcehut" 47 ] 48 ); 49 }; 50 owner = lib.mkOption { 51 description = "owner of the repository";
··· 2 let 3 follows-option = lib.mkOption { 4 description = "flake input path to follow"; 5 + default = null; 6 + type = lib.types.nullOr lib.types.str; 7 }; 8 9 inputs-follow-option = lib.mkOption { ··· 46 "sourcehut" 47 ] 48 ); 49 + }; 50 + submodules = lib.mkOption { 51 + description = "Whether to checkout git submodules"; 52 + default = null; 53 + type = lib.types.nullOr lib.types.bool; 54 }; 55 owner = lib.mkOption { 56 description = "owner of the repository";
+1 -1
modules/options/prune-lock.nix
··· 44 runtimeInputs = [ pkgs.diffutils ]; 45 text = '' 46 ${prune-cmd pkgs} "$1"/flake.lock pruned.lock 47 - diff -u pruned.lock "$1"/flake.lock 48 ''; 49 }; 50
··· 44 runtimeInputs = [ pkgs.diffutils ]; 45 text = '' 46 ${prune-cmd pkgs} "$1"/flake.lock pruned.lock 47 + diff -u "$1"/flake.lock pruned.lock 48 ''; 49 }; 50
+1 -1
modules/prune-lock/allfollow.nix
··· 6 pkgs: 7 pkgs.writeShellApplication { 8 name = "allfollow"; 9 - runtimeInputs = [ inputs.allfollow.packages.${pkgs.system}.default ]; 10 text = '' 11 allfollow prune --pretty "$1" -o "$2" 12 '';
··· 6 pkgs: 7 pkgs.writeShellApplication { 8 name = "allfollow"; 9 + runtimeInputs = [ inputs.allfollow.packages.${pkgs.stdenv.hostPlatform.system}.default ]; 10 text = '' 11 allfollow prune --pretty "$1" -o "$2" 12 '';
+1 -1
modules/prune-lock/nix-auto-follow.nix
··· 10 pkgs: 11 pkgs.writeShellApplication { 12 name = "nix-auto-follow"; 13 - runtimeInputs = [ inputs.nix-auto-follow.packages.${pkgs.system}.default ]; 14 text = '' 15 auto-follow "$1" > "$2" 16 '';
··· 10 pkgs: 11 pkgs.writeShellApplication { 12 name = "nix-auto-follow"; 13 + runtimeInputs = [ inputs.nix-auto-follow.packages.${pkgs.stdenv.hostPlatform.system}.default ]; 14 text = '' 15 auto-follow "$1" > "$2" 16 '';
+21 -2
modules/write-flake.nix
··· 26 addHeader 27 ]; 28 29 # expr to code 30 nixCode = 31 x: ··· 33 lib.strings.escapeNixString x 34 else if lib.isAttrs x then 35 lib.pipe x [ 36 - (lib.mapAttrsToList (name: value: ''${name} = ${nixCode value}; '')) 37 (values: ''{ ${lib.concatStringsSep " " values} }'') 38 ] 39 else if lib.isList x then ··· 125 } 126 '' 127 set -e 128 - diff -u ${formatted pkgs} ${inputs.self}/flake.nix 129 ${hooks} 130 touch $out 131 '';
··· 26 addHeader 27 ]; 28 29 + nixAttr = 30 + name: value: 31 + let 32 + childIsAttr = builtins.isAttrs value; 33 + childIsOne = builtins.length (builtins.attrNames value) == 1; 34 + nested = lib.head (lib.mapAttrsToList nixAttr value); 35 + in 36 + if childIsAttr && childIsOne then 37 + { 38 + name = "${name}.${nested.name}"; 39 + value = nested.value; 40 + } 41 + else 42 + { 43 + inherit name; 44 + value = value; 45 + }; 46 + 47 # expr to code 48 nixCode = 49 x: ··· 51 lib.strings.escapeNixString x 52 else if lib.isAttrs x then 53 lib.pipe x [ 54 + (lib.mapAttrsToList nixAttr) 55 + (map ({ name, value }: ''${name} = ${nixCode value}; '')) 56 (values: ''{ ${lib.concatStringsSep " " values} }'') 57 ] 58 else if lib.isList x then ··· 144 } 145 '' 146 set -e 147 + diff -u ${inputs.self}/flake.nix ${formatted pkgs} 148 ${hooks} 149 touch $out 150 '';
+4 -12
templates/default/flake.nix
··· 5 outputs = inputs: import ./outputs.nix inputs; 6 7 inputs = { 8 - flake-file = { 9 - url = "github:vic/flake-file"; 10 - }; 11 - flake-parts = { 12 - url = "github:hercules-ci/flake-parts"; 13 - }; 14 - nixpkgs = { 15 - url = "github:nixos/nixpkgs/nixpkgs-unstable"; 16 - }; 17 - systems = { 18 - url = "github:nix-systems/default"; 19 - }; 20 }; 21 22 }
··· 5 outputs = inputs: import ./outputs.nix inputs; 6 7 inputs = { 8 + flake-file.url = "github:vic/flake-file"; 9 + flake-parts.url = "github:hercules-ci/flake-parts"; 10 + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 11 + systems.url = "github:nix-systems/default"; 12 }; 13 14 }
+6 -27
templates/dendritic/flake.nix
··· 5 outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); 6 7 inputs = { 8 - den = { 9 - url = "github:vic/den"; 10 - }; 11 - flake-aspects = { 12 - url = "github:vic/flake-aspects"; 13 - }; 14 - flake-file = { 15 - url = "github:vic/flake-file"; 16 - }; 17 flake-parts = { 18 url = "github:hercules-ci/flake-parts"; 19 }; 20 - import-tree = { 21 - url = "github:vic/import-tree"; 22 - }; 23 - nix-auto-follow = { 24 - url = "github:fzakaria/nix-auto-follow"; 25 - }; 26 - nixpkgs = { 27 - url = "github:nixos/nixpkgs/nixpkgs-unstable"; 28 - }; 29 - nixpkgs-lib = { 30 - follows = "nixpkgs"; 31 - }; 32 - systems = { 33 - url = "github:nix-systems/default"; 34 - }; 35 - treefmt-nix = { 36 - url = "github:numtide/treefmt-nix"; 37 - }; 38 }; 39 40 }
··· 5 outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); 6 7 inputs = { 8 + flake-file.url = "github:vic/flake-file"; 9 flake-parts = { 10 + inputs.nixpkgs-lib.follows = "nixpkgs-lib"; 11 url = "github:hercules-ci/flake-parts"; 12 }; 13 + import-tree.url = "github:vic/import-tree"; 14 + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 15 + nixpkgs-lib.follows = "nixpkgs"; 16 + systems.url = "github:nix-systems/default"; 17 }; 18 19 }
+5 -15
templates/parts/flake.nix
··· 10 }; 11 12 inputs = { 13 - flake-file = { 14 - url = "github:vic/flake-file"; 15 - }; 16 - flake-parts = { 17 - url = "github:hercules-ci/flake-parts"; 18 - }; 19 - nixpkgs = { 20 - url = "github:nixos/nixpkgs/nixpkgs-unstable"; 21 - }; 22 - systems = { 23 - url = "github:nix-systems/default"; 24 - }; 25 - treefmt-nix = { 26 - url = "github:numtide/treefmt-nix"; 27 - }; 28 }; 29 30 }
··· 10 }; 11 12 inputs = { 13 + flake-file.url = "github:vic/flake-file"; 14 + flake-parts.url = "github:hercules-ci/flake-parts"; 15 + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 16 + systems.url = "github:nix-systems/default"; 17 + treefmt-nix.url = "github:numtide/treefmt-nix"; 18 }; 19 20 }