2021-05-07 02:30:46 +03:00
|
|
|
args@{ config, lib, pkgs, baseModules, modules, ... }:
|
2021-01-29 05:31:45 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
# Keep modules from this eval around
|
|
|
|
modules' = modules;
|
|
|
|
|
|
|
|
inherit (config.nixpkgs.localSystem) system;
|
|
|
|
|
|
|
|
# We can make use the normal NixOS evalConfig here.
|
|
|
|
evalConfig = import "${toString pkgs.path}/nixos/lib/eval-config.nix";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
lib = {
|
|
|
|
mobile-nixos = {
|
|
|
|
# `config.lib.mobile-nixos.composeConfig` is the supported method used to
|
|
|
|
# re-evaluate a configuration with additional configuration.
|
|
|
|
# Can be used exactly like `evalConfig`, with one additional param.
|
|
|
|
# The `config` param directly takes a module (attrset or function).
|
|
|
|
composeConfig = { config ? {}, modules ? [], ... }@args:
|
|
|
|
let
|
|
|
|
filteredArgs = lib.filterAttrs (k: v: k != "config") args;
|
|
|
|
in
|
|
|
|
evalConfig (
|
|
|
|
filteredArgs // {
|
|
|
|
# Needed for hermetic eval, otherwise `eval-config.nix` will try
|
|
|
|
# to use `builtins.currentSystem`.
|
|
|
|
inherit system;
|
|
|
|
inherit baseModules;
|
2021-05-07 02:30:46 +03:00
|
|
|
# Newer versions of module system pass specialArgs to modules, so try
|
|
|
|
# to pass that to eval if possible.
|
|
|
|
specialArgs = args.specialArgs or { };
|
2021-01-29 05:31:45 +03:00
|
|
|
# Merge in this eval's modules with the argument's modules, and finally
|
|
|
|
# with the given config.
|
|
|
|
modules = modules' ++ modules ++ [ config ];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|