···263263 default = [];
264264 description = lib.mdDoc ''
265265 A list of packages that should be included in the system
266266- closure but not otherwise made available to users. This is
267267- primarily used by the installation tests.
266266+ closure but generally not visible to users.
267267+268268+ This option has also been used for build-time checks, but the
269269+ `system.checks` option is more appropriate for that purpose as checks
270270+ should not leave a trace in the built system configuration.
271271+ '';
272272+ };
273273+274274+ system.checks = mkOption {
275275+ type = types.listOf types.package;
276276+ default = [];
277277+ description = lib.mdDoc ''
278278+ Packages that are added as dependencies of the system's build, usually
279279+ for the purpose of validating some part of the configuration.
280280+281281+ Unlike `system.extraDependencies`, these store paths do not
282282+ become part of the built system configuration.
268283 '';
269284 };
270285···363378 fi
364379 '';
365380366366- system.systemBuilderArgs = lib.optionalAttrs (config.system.forbiddenDependenciesRegex != "") {
381381+ system.systemBuilderArgs = {
382382+ # Not actually used in the builder. `passedChecks` is just here to create
383383+ # the build dependencies. Checks are similar to build dependencies in the
384384+ # sense that if they fail, the system build fails. However, checks do not
385385+ # produce any output of value, so they are not used by the system builder.
386386+ # In fact, using them runs the risk of accidentally adding unneeded paths
387387+ # to the system closure, which defeats the purpose of the `system.checks`
388388+ # option, as opposed to `system.extraDependencies`.
389389+ passedChecks = concatStringsSep " " config.system.checks;
390390+ }
391391+ // lib.optionalAttrs (config.system.forbiddenDependenciesRegex != "") {
367392 inherit (config.system) forbiddenDependenciesRegex;
368393 closureInfo = pkgs.closureInfo { rootPaths = [
369394 # override to avoid infinite recursion (and to allow using extraDependencies to add forbidden dependencies)
370395 (config.system.build.toplevel.overrideAttrs (_: { extraDependencies = []; closureInfo = null; }))
371396 ]; };
372397 };
398398+373399374400 system.build.toplevel = if config.system.includeBuildDependencies then systemWithBuildDeps else system;
375401