2021-04-05 13:05:02 +00:00
|
|
|
{ lib }:
|
2020-10-18 10:46:59 +00:00
|
|
|
|
2021-04-05 13:05:02 +00:00
|
|
|
{ system ? builtins.currentSystem or "x86_64-darwin"
|
2022-02-04 10:32:40 +00:00
|
|
|
, pkgs ? null
|
2021-04-05 13:05:02 +00:00
|
|
|
, modules
|
2020-10-18 10:46:59 +00:00
|
|
|
, inputs
|
|
|
|
, baseModules ? import ./modules/module-list.nix
|
2021-04-05 13:05:02 +00:00
|
|
|
, specialArgs ? { }
|
2021-12-08 23:13:24 +00:00
|
|
|
, check ? true
|
2020-10-18 10:46:59 +00:00
|
|
|
}@args:
|
|
|
|
|
|
|
|
let
|
2021-12-20 19:29:59 +00:00
|
|
|
argsModule = {
|
2020-10-18 10:46:59 +00:00
|
|
|
_file = ./eval-config.nix;
|
|
|
|
config = {
|
2021-12-20 19:29:59 +00:00
|
|
|
_module.args = {
|
|
|
|
inherit baseModules inputs modules;
|
|
|
|
};
|
2020-10-18 10:46:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
pkgsModule = { config, inputs, ... }: {
|
|
|
|
_file = ./eval-config.nix;
|
|
|
|
config = {
|
2022-02-04 10:32:40 +00:00
|
|
|
assertions = [ {
|
|
|
|
# Ensure that nixpkgs.* options are not set when pkgs is set
|
|
|
|
assertion = pkgs == null || (config.nixpkgs.config == { } && config.nixpkgs.overlays == [ ]);
|
|
|
|
message = ''
|
|
|
|
`nixpkgs` options are disabled when `pkgs` is supplied through `darwinSystem`.
|
|
|
|
'';
|
|
|
|
} ];
|
|
|
|
|
|
|
|
_module.args.pkgs = if pkgs != null then pkgs else import inputs.nixpkgs config.nixpkgs;
|
2021-04-05 13:05:02 +00:00
|
|
|
|
|
|
|
# This permits the configuration to override the passed-in
|
|
|
|
# system.
|
|
|
|
nixpkgs.system = lib.mkDefault system;
|
2020-10-18 10:46:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-10-23 13:05:52 +00:00
|
|
|
libExtended = lib.extend (self: super: {
|
|
|
|
# Added in nixpkgs #136909, adds forward compatibility until 22.03 is deprecated.
|
|
|
|
literalExpression = super.literalExpression or super.literalExample;
|
|
|
|
literalDocBook = super.literalDocBook or super.literalExample;
|
|
|
|
});
|
|
|
|
|
2022-02-04 10:32:40 +00:00
|
|
|
eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "pkgs" "system" ] // {
|
2021-12-20 19:29:59 +00:00
|
|
|
modules = modules ++ [ argsModule pkgsModule ] ++ baseModules;
|
2020-10-18 10:46:59 +00:00
|
|
|
specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs;
|
|
|
|
});
|
|
|
|
|
|
|
|
# Was moved in nixpkgs #82751, so both need to be handled here until 20.03 is deprecated.
|
|
|
|
# https://github.com/NixOS/nixpkgs/commits/dcdd232939232d04c1132b4cc242dd3dac44be8c
|
|
|
|
_module = eval._module or eval.config._module;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
inherit (_module.args) pkgs;
|
|
|
|
inherit (eval) options config;
|
|
|
|
|
|
|
|
system = eval.config.system.build.toplevel;
|
|
|
|
}
|