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.

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