mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-11-12 13:13:02 +03:00
Replace evalConfig
with config.lib.mobile-nixos.composeConfig
This commit is contained in:
parent
b57495c363
commit
34b033330f
@ -1,19 +1,8 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
let
|
||||
|
||||
# Original `evalConfig`
|
||||
evalConfig' = import "${pkgs.path}/nixos/lib/eval-config.nix";
|
||||
|
||||
# Specialized `evalConfig` which injects the _mobile-nixos special arg.
|
||||
evalConfig = args@{ specialArgs ? {}, ... }: evalConfig' (args // {
|
||||
specialArgs = specialArgs // {
|
||||
_mobile-nixos = {
|
||||
inherit evalConfig;
|
||||
path = ../.;
|
||||
};
|
||||
};
|
||||
});
|
||||
evalConfig = import "${toString pkgs.path}/nixos/lib/eval-config.nix";
|
||||
in
|
||||
{
|
||||
# This should *never* rely on lib or pkgs.
|
||||
|
35
modules/lib.nix
Normal file
35
modules/lib.nix
Normal file
@ -0,0 +1,35 @@
|
||||
{ config, lib, pkgs, baseModules, modules, ... }:
|
||||
|
||||
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;
|
||||
# Merge in this eval's modules with the argument's modules, and finally
|
||||
# with the given config.
|
||||
modules = modules' ++ modules ++ [ config ];
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
@ -32,6 +32,7 @@
|
||||
./initrd-vendor.nix
|
||||
./initrd.nix
|
||||
./internal.nix
|
||||
./lib.nix
|
||||
./luks.nix
|
||||
./mobile-device.nix
|
||||
./nixpkgs.nix
|
||||
|
Loading…
Reference in New Issue
Block a user