diff --git a/nixos/doc/manual/configuration/modularity.xml b/nixos/doc/manual/configuration/modularity.xml index 298ffd661f6780..cda36eba25c1f0 100644 --- a/nixos/doc/manual/configuration/modularity.xml +++ b/nixos/doc/manual/configuration/modularity.xml @@ -127,4 +127,23 @@ nix-repl> map (x: x.hostName) config. + + + While abstracting your configuration, you may find it useful to generate + modules using code, instead of writing files. The example + below would have the same effect as importing a file which sets those + options. + + { config, pkgs, ... }: + + let netConfig = { hostName }: { + networking.hostName = hostName; + networking.useDHCP = false; + }; + + in + + { imports = [ (netConfig "nixos.localdomain") ]; } + +