diff options
author | Bobby Rong <rjl931189261@126.com> | 2021-07-03 22:18:41 +0800 |
---|---|---|
committer | Bobby Rong <rjl931189261@126.com> | 2021-07-03 22:20:55 +0800 |
commit | 9afb04f765bba1015314efb723a58ed68c393021 (patch) | |
tree | 196219a4e43e11c264e72155dc2dc00353ea0561 /nixos/doc/manual/development | |
parent | c0853101833136590811a8c3cf30a989dd40a586 (diff) | |
download | nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.tar nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.tar.gz nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.tar.bz2 nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.tar.lz nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.tar.xz nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.tar.zst nixpkgs-9afb04f765bba1015314efb723a58ed68c393021.zip |
nixos: nixos/doc/manual/development/importing-modules.xml to CommonMark
Diffstat (limited to 'nixos/doc/manual/development')
-rw-r--r-- | nixos/doc/manual/development/importing-modules.section.md | 46 | ||||
-rw-r--r-- | nixos/doc/manual/development/importing-modules.xml | 56 | ||||
-rw-r--r-- | nixos/doc/manual/development/writing-modules.xml | 2 |
3 files changed, 47 insertions, 57 deletions
diff --git a/nixos/doc/manual/development/importing-modules.section.md b/nixos/doc/manual/development/importing-modules.section.md new file mode 100644 index 00000000000..65d78959b8e --- /dev/null +++ b/nixos/doc/manual/development/importing-modules.section.md @@ -0,0 +1,46 @@ +# Importing Modules {#sec-importing-modules} + +Sometimes NixOS modules need to be used in configuration but exist +outside of Nixpkgs. These modules can be imported: + +```nix +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Use a locally-available module definition in + # ./example-module/default.nix + ./example-module + ]; + + services.exampleModule.enable = true; +} +``` + +The environment variable `NIXOS_EXTRA_MODULE_PATH` is an absolute path +to a NixOS module that is included alongside the Nixpkgs NixOS modules. +Like any NixOS module, this module can import additional modules: + +```nix +# ./module-list/default.nix +[ + ./example-module1 + ./example-module2 +] +``` + +```nix +# ./extra-module/default.nix +{ imports = import ./module-list.nix; } +``` + +```nix +# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module +{ config, lib, pkgs, ... }: + +{ + # No `imports` needed + + services.exampleModule1.enable = true; +} +``` diff --git a/nixos/doc/manual/development/importing-modules.xml b/nixos/doc/manual/development/importing-modules.xml deleted file mode 100644 index 1c6a5671eda..00000000000 --- a/nixos/doc/manual/development/importing-modules.xml +++ /dev/null @@ -1,56 +0,0 @@ -<section xmlns="http://docbook.org/ns/docbook" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:xi="http://www.w3.org/2001/XInclude" - version="5.0" - xml:id="sec-importing-modules"> - <title>Importing Modules</title> - - <para> - Sometimes NixOS modules need to be used in configuration but exist outside of - Nixpkgs. These modules can be imported: - </para> - -<programlisting> -{ config, lib, pkgs, ... }: - -{ - imports = - [ # Use a locally-available module definition in - # ./example-module/default.nix - ./example-module - ]; - - services.exampleModule.enable = true; -} -</programlisting> - - <para> - The environment variable <literal>NIXOS_EXTRA_MODULE_PATH</literal> is an - absolute path to a NixOS module that is included alongside the Nixpkgs NixOS - modules. Like any NixOS module, this module can import additional modules: - </para> - -<programlisting> -# ./module-list/default.nix -[ - ./example-module1 - ./example-module2 -] -</programlisting> - -<programlisting> -# ./extra-module/default.nix -{ imports = import ./module-list.nix; } -</programlisting> - -<programlisting> -# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module -{ config, lib, pkgs, ... }: - -{ - # No `imports` needed - - services.exampleModule1.enable = true; -} -</programlisting> -</section> diff --git a/nixos/doc/manual/development/writing-modules.xml b/nixos/doc/manual/development/writing-modules.xml index ff59dd074db..bb108d18375 100644 --- a/nixos/doc/manual/development/writing-modules.xml +++ b/nixos/doc/manual/development/writing-modules.xml @@ -184,7 +184,7 @@ in { <xi:include href="../from_md/development/option-def.section.xml" /> <xi:include href="../from_md/development/assertions.section.xml" /> <xi:include href="../from_md/development/meta-attributes.section.xml" /> - <xi:include href="importing-modules.xml" /> + <xi:include href="../from_md/development/importing-modules.section.xml" /> <xi:include href="replace-modules.xml" /> <xi:include href="freeform-modules.xml" /> <xi:include href="settings-options.xml" /> |