1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-10-26 13:03:04 +03:00
mobile-nixos/lib/release-tools.nix
Samuel Dionne-Riel 1ba61f1860 release-tools: Remove usage of removed option
Recent changes in Nixpkgs makes it more strict.

This is a change that wasn't caught as needed from the migration to
structured options for device infos.
2020-08-18 17:45:03 -04:00

68 lines
2.1 KiB
Nix

{
# This should *never* rely on lib or pkgs.
all-devices =
builtins.filter
(d: builtins.pathExists (../. + "/devices/${d}/default.nix"))
(builtins.attrNames (builtins.readDir ../devices))
;
# 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 ? {}
, baseModules ? ((import ../modules/module-list.nix) ++ [ ../modules/_nixos-integration.nix ])
}: import ./eval-config.nix {
inherit baseModules;
modules =
(if device ? special
then [ device.config ]
else if builtins.isPath device then [ { imports = [ device ]; } ]
else [ { imports = [(../. + "/devices/${device}")]; } ])
++ modules
++ [ additionalConfiguration ]
;
};
# 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; }
;
};
}