mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
modules: Extract mkAliasDefinition from the rename.nix NixOS module.
This commit is contained in:
parent
4e558732e7
commit
d7f29acd48
@ -356,6 +356,31 @@ rec {
|
|||||||
mkBefore = mkOrder 500;
|
mkBefore = mkOrder 500;
|
||||||
mkAfter = mkOrder 1500;
|
mkAfter = mkOrder 1500;
|
||||||
|
|
||||||
|
# Convenient property used to transfer all definitions and their
|
||||||
|
# properties from one option to another. This property is useful for
|
||||||
|
# renaming options, and also for including properties from another module
|
||||||
|
# system, including sub-modules.
|
||||||
|
#
|
||||||
|
# { config, options, ... }:
|
||||||
|
#
|
||||||
|
# {
|
||||||
|
# # 'bar' might not always be defined in the current module-set.
|
||||||
|
# config.foo.enable = mkAliasDefinitions (options.bar.enable or {});
|
||||||
|
#
|
||||||
|
# # 'barbaz' has to be defined in the current module-set.
|
||||||
|
# config.foobar.paths = mkAliasDefinitions options.barbaz.paths;
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# Note, this is different than taking the value of the option and using it
|
||||||
|
# as a definition, as the new definition will not keep the mkOverride /
|
||||||
|
# mkDefault properties of the previous option.
|
||||||
|
#
|
||||||
|
mkAliasDefinitions = mkAliasAndWrapDefinitions id;
|
||||||
|
mkAliasAndWrapDefinitions = wrap: option:
|
||||||
|
mkMerge
|
||||||
|
(optional (isOption option && option.isDefined)
|
||||||
|
(wrap (mkMerge option.definitions)));
|
||||||
|
|
||||||
|
|
||||||
/* Compatibility. */
|
/* Compatibility. */
|
||||||
fixMergeModules = modules: args: evalModules { inherit modules args; check = false; };
|
fixMergeModules = modules: args: evalModules { inherit modules args; check = false; };
|
||||||
|
@ -55,8 +55,8 @@ let
|
|||||||
apply = x: use (toOf config);
|
apply = x: use (toOf config);
|
||||||
inherit visible;
|
inherit visible;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
{ config = setTo (mkMerge (if (fromOf options).isDefined then [ (define (mkMerge (fromOf options).definitions)) ] else []));
|
config = setTo (mkAliasAndWrapDefinitions define (fromOf options));
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user