From 24865963f0e7886e1a42d8aa112306d7cc6cfbd8 Mon Sep 17 00:00:00 2001 From: Svein Ove Aas Date: Wed, 28 Nov 2018 11:39:51 +0000 Subject: [PATCH] modularity: Document the ability to use non-files in imports (#50503) * modularity: Document the ability to use non-files in imports * Update nixos/doc/manual/configuration/modularity.xml Co-Authored-By: Baughn --- nixos/doc/manual/configuration/modularity.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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") ]; } + +