From 9afb04f765bba1015314efb723a58ed68c393021 Mon Sep 17 00:00:00 2001 From: Bobby Rong Date: Sat, 3 Jul 2021 22:18:41 +0800 Subject: [PATCH] nixos: nixos/doc/manual/development/importing-modules.xml to CommonMark --- .../development/importing-modules.section.md | 46 +++++++++++++++ .../manual/development/importing-modules.xml | 56 ------------------- .../manual/development/writing-modules.xml | 2 +- .../development/importing-modules.section.xml | 47 ++++++++++++++++ 4 files changed, 94 insertions(+), 57 deletions(-) create mode 100644 nixos/doc/manual/development/importing-modules.section.md delete mode 100644 nixos/doc/manual/development/importing-modules.xml create mode 100644 nixos/doc/manual/from_md/development/importing-modules.section.xml 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 000000000000..65d78959b8e0 --- /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 1c6a5671eda8..000000000000 --- a/nixos/doc/manual/development/importing-modules.xml +++ /dev/null @@ -1,56 +0,0 @@ -
- Importing Modules - - - Sometimes NixOS modules need to be used in configuration but exist outside of - Nixpkgs. These modules can be imported: - - - -{ 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: - - - -# ./module-list/default.nix -[ - ./example-module1 - ./example-module2 -] - - - -# ./extra-module/default.nix -{ imports = import ./module-list.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/writing-modules.xml b/nixos/doc/manual/development/writing-modules.xml index ff59dd074db7..bb108d183750 100644 --- a/nixos/doc/manual/development/writing-modules.xml +++ b/nixos/doc/manual/development/writing-modules.xml @@ -184,7 +184,7 @@ in { - + diff --git a/nixos/doc/manual/from_md/development/importing-modules.section.xml b/nixos/doc/manual/from_md/development/importing-modules.section.xml new file mode 100644 index 000000000000..cb04dde67c83 --- /dev/null +++ b/nixos/doc/manual/from_md/development/importing-modules.section.xml @@ -0,0 +1,47 @@ +
+ Importing Modules + + Sometimes NixOS modules need to be used in configuration but exist + outside of Nixpkgs. These modules can be imported: + + +{ 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: + + +# ./module-list/default.nix +[ + ./example-module1 + ./example-module2 +] + + +# ./extra-module/default.nix +{ imports = import ./module-list.nix; } + + +# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module +{ config, lib, pkgs, ... }: + +{ + # No `imports` needed + + services.exampleModule1.enable = true; +} + +