3
0
Fork 0
forked from mirrors/nixpkgs

nixos/eval-config: Remove statically known mkIf

mkIf is unnecessary when the condition is statically known - that is
knowable before entering the module evaluation.

By changing this to a precomputed module, we support changing the
defined options to readOnly options.
This commit is contained in:
Robert Hensing 2023-05-07 15:33:47 +02:00
parent 6e594fedb3
commit 693e2c3287

View file

@ -38,6 +38,8 @@ let pkgs_ = pkgs;
in in
let let
inherit (lib) optional;
evalModulesMinimal = (import ./default.nix { evalModulesMinimal = (import ./default.nix {
inherit lib; inherit lib;
# Implicit use of feature is noted in implementation. # Implicit use of feature is noted in implementation.
@ -47,15 +49,19 @@ let
pkgsModule = rec { pkgsModule = rec {
_file = ./eval-config.nix; _file = ./eval-config.nix;
key = _file; key = _file;
config = { config = lib.mkMerge (
# Explicit `nixpkgs.system` or `nixpkgs.localSystem` should override (optional (system != null) {
# this. Since the latter defaults to the former, the former should # Explicit `nixpkgs.system` or `nixpkgs.localSystem` should override
# default to the argument. That way this new default could propagate all # this. Since the latter defaults to the former, the former should
# they way through, but has the last priority behind everything else. # default to the argument. That way this new default could propagate all
nixpkgs.system = lib.mkIf (system != null) (lib.mkDefault system); # they way through, but has the last priority behind everything else.
nixpkgs.system = lib.mkDefault system;
_module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_); })
}; ++
(optional (pkgs_ != null) {
_module.args.pkgs = lib.mkForce pkgs_;
})
);
}; };
withWarnings = x: withWarnings = x: