Skip to content

Commit f64ab15

Browse files
different-nameMic92
authored andcommitted
docs: add recursive method for fetching flake input out paths
The previous example would not work for flakes that have inputs with inputs of their own, leading to installation failures when attempting to install without internet access
1 parent 8246829 commit f64ab15

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/disko-install.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,19 @@ Add this to your flake.nix output:
197197
```nix
198198
# `self` here is referring to the flake `self`, you may need to pass it using `specialArgs` or define your NixOS installer configuration
199199
# in the flake.nix itself to get direct access to the `self` flake variable.
200-
{ pkgs, self, ... }:
200+
{ lib, pkgs, self, ... }:
201201
let
202+
flakeOutPaths =
203+
let
204+
collector =
205+
parent:
206+
map (
207+
child:
208+
[ child.outPath ] ++ (if child ? inputs && child.inputs != { } then (collector child) else [ ])
209+
) (lib.attrValues parent.inputs);
210+
in
211+
lib.unique (lib.flatten (collector self));
212+
202213
dependencies = [
203214
self.nixosConfigurations.your-machine.config.system.build.toplevel
204215
self.nixosConfigurations.your-machine.config.system.build.diskoScript
@@ -210,7 +221,7 @@ let
210221
self.nixosConfigurations.your-machine.pkgs.perlPackages.FileSlurp
211222
212223
(self.nixosConfigurations.your-machine.pkgs.closureInfo { rootPaths = [ ]; }).drvPath
213-
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
224+
] ++ flakeOutPaths;
214225
215226
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
216227
in

0 commit comments

Comments
 (0)