From 3633bf98be70af326056ebc87a9adedd0e8a24c7 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 13 Feb 2023 11:09:35 +0100 Subject: [PATCH] lib/modules.nix: Make some functions private The supposedly public nature of these functions has been holding back module system maintenance, while usages of these functions are expected to be rare. If used anywhere, presumably they're emulating module system behavior because some use case isn't supported properly. We should try to support such a use case directly, if it even exists. --- lib/modules.nix | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index de03b50e2698..0a842aa0063e 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -1215,28 +1215,41 @@ let config = lib.importTOML file; }; + private = lib.mapAttrs + (k: lib.warn "External use of `lib.modules.${k}` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/.") + { + inherit + applyModuleArgsIfFunction + collectModules + dischargeProperties + evalOptionValue + mergeModules + mergeModules' + pushDownProperties + unifyModuleSyntax + ; + }; + in +private // { + # NOTE: not all of these functions are necessarily public interfaces; some + # are just needed by types.nix, but are not meant to be consumed + # externally. inherit - applyModuleArgsIfFunction - collectModules defaultOrderPriority defaultOverridePriority defaultPriority - dischargeProperties doRename evalModules - evalOptionValue filterOverrides filterOverrides' fixMergeModules - fixupOptionType + fixupOptionType # should be private? importJSON importTOML mergeDefinitions - mergeModules - mergeModules' - mergeOptionDecls + mergeOptionDecls # should be private? mkAfter mkAliasAndWrapDefinitions mkAliasAndWrapDefsWithPriority @@ -1262,8 +1275,6 @@ in mkRenamedOptionModule mkRenamedOptionModuleWith mkVMOverride - pushDownProperties setDefaultModuleLocation - sortProperties - unifyModuleSyntax; + sortProperties; }