summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2016-08-28 13:57:34 +0200
committerGitHub <noreply@github.com>2016-08-28 13:57:34 +0200
commite01e92f12f5e768e5bd5ef84a969b978fb501186 (patch)
tree2ea53d8580dd79c3fd9e37354e9b0100010654b8 /lib/modules.nix
parent4af09e00311b3c024395b59261a32a5a6a43e3fa (diff)
parent4cdfeb78f9b7397304a58b83d2746fd417e00e3c (diff)
downloadnixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.tar
nixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.tar.gz
nixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.tar.bz2
nixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.tar.lz
nixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.tar.xz
nixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.tar.zst
nixpkgs-e01e92f12f5e768e5bd5ef84a969b978fb501186.zip
Merge pull request #15025 from ericsagnes/modules/manual
manual: automatically generate modules documentation
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 080974a6130..6f08a49399a 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -105,8 +105,12 @@ rec {
   /* Massage a module into canonical form, that is, a set consisting
      of ‘options’, ‘config’ and ‘imports’ attributes. */
   unifyModuleSyntax = file: key: m:
+    let metaSet = if m ? meta 
+      then { meta = m.meta; }
+      else {};
+    in
     if m ? config || m ? options then
-      let badAttrs = removeAttrs m ["imports" "options" "config" "key" "_file"]; in
+      let badAttrs = removeAttrs m ["imports" "options" "config" "key" "_file" "meta"]; in
       if badAttrs != {} then
         throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'."
       else
@@ -114,14 +118,14 @@ rec {
           key = toString m.key or key;
           imports = m.imports or [];
           options = m.options or {};
-          config = m.config or {};
+          config = mkMerge [ (m.config or {}) metaSet ];
         }
     else
       { file = m._file or file;
         key = toString m.key or key;
         imports = m.require or [] ++ m.imports or [];
         options = {};
-        config = removeAttrs m ["key" "_file" "require" "imports"];
+        config = mkMerge [ (removeAttrs m ["key" "_file" "require" "imports"]) metaSet ];
       };
 
   applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then