2020-11-11 15:01:40 +03:00
|
|
|
{ pkgs ? import <nixpkgs> {} }:
|
|
|
|
|
|
|
|
let
|
|
|
|
# Original `evalConfig`
|
2021-01-29 05:31:45 +03:00
|
|
|
evalConfig = import "${toString pkgs.path}/nixos/lib/eval-config.nix";
|
2020-11-11 15:01:40 +03:00
|
|
|
in
|
2020-04-04 21:36:23 +03:00
|
|
|
{
|
|
|
|
# This should *never* rely on lib or pkgs.
|
|
|
|
all-devices =
|
|
|
|
builtins.filter
|
|
|
|
(d: builtins.pathExists (../. + "/devices/${d}/default.nix"))
|
|
|
|
(builtins.attrNames (builtins.readDir ../devices))
|
|
|
|
;
|
|
|
|
|
2020-04-06 23:28:10 +03:00
|
|
|
# Evaluates NixOS, mobile-nixos and the device config with the given
|
|
|
|
# additional modules.
|
|
|
|
# Note that we can receive a "special" configuration, used internally by
|
|
|
|
# `release.nix` and not part of the public API.
|
|
|
|
evalWith =
|
|
|
|
{ modules
|
|
|
|
, device
|
|
|
|
, additionalConfiguration ? {}
|
2020-11-11 15:01:40 +03:00
|
|
|
, baseModules ? (
|
|
|
|
(import ../modules/module-list.nix)
|
|
|
|
++ (import "${toString pkgs.path}/nixos/modules/module-list.nix")
|
|
|
|
)
|
|
|
|
}: evalConfig {
|
2020-04-06 23:28:10 +03:00
|
|
|
inherit baseModules;
|
|
|
|
modules =
|
|
|
|
(if device ? special
|
|
|
|
then [ device.config ]
|
2020-06-06 06:24:12 +03:00
|
|
|
else if builtins.isPath device then [ { imports = [ device ]; } ]
|
2020-05-24 23:00:42 +03:00
|
|
|
else [ { imports = [(../. + "/devices/${device}")]; } ])
|
2020-04-06 23:28:10 +03:00
|
|
|
++ modules
|
|
|
|
++ [ additionalConfiguration ]
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
2020-04-04 21:36:23 +03:00
|
|
|
# These can rely freely on lib, avoir depending on pkgs.
|
|
|
|
withPkgs = pkgs:
|
|
|
|
let
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
specialConfig = {name, buildingForSystem, system, config ? {}}: {
|
|
|
|
special = true;
|
|
|
|
inherit name;
|
|
|
|
config = lib.mkMerge [
|
|
|
|
config
|
|
|
|
{
|
|
|
|
mobile.system.type = "none";
|
|
|
|
mobile.hardware.soc = {
|
|
|
|
x86_64-linux = "generic-x86_64";
|
|
|
|
aarch64-linux = "generic-aarch64";
|
|
|
|
armv7l-linux = "generic-armv7l";
|
|
|
|
}.${buildingForSystem};
|
|
|
|
nixpkgs.localSystem = knownSystems.${system};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Shortcuts from a simple system name to the structure required for
|
|
|
|
# localSystem and crossSystem
|
|
|
|
knownSystems = {
|
|
|
|
x86_64-linux = lib.systems.examples.gnu64;
|
|
|
|
aarch64-linux = lib.systems.examples.aarch64-multiplatform;
|
|
|
|
armv7l-linux = lib.systems.examples.armv7l-hf-multiplatform;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Given a device compatible with `default.nix`, eval.
|
|
|
|
evalFor = evalWithConfiguration {};
|
|
|
|
evalWithConfiguration = additionalConfiguration: device:
|
|
|
|
import ../. { inherit device additionalConfiguration; }
|
|
|
|
;
|
|
|
|
};
|
|
|
|
}
|