diff options
author | Eric Sagnes <eric.sagnes@gmail.com> | 2016-05-09 14:53:27 +0900 |
---|---|---|
committer | Eric Sagnes <eric.sagnes@gmail.com> | 2016-08-11 00:29:48 +0900 |
commit | 4cdfeb78f9b7397304a58b83d2746fd417e00e3c (patch) | |
tree | 8d908622b68db5a3856cff8ae034715d5d986b1a /lib/modules.nix | |
parent | 898435d16e14e18e73e00f4618e6e88bedb91399 (diff) | |
download | nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.tar nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.tar.gz nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.tar.bz2 nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.tar.lz nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.tar.xz nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.tar.zst nixlib-4cdfeb78f9b7397304a58b83d2746fd417e00e3c.zip |
modules: move meta at top level
Diffstat (limited to 'lib/modules.nix')
-rw-r--r-- | lib/modules.nix | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index e2fa3d7fbf0c..2b0d03ef6e81 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 |