1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-09-11 12:05:26 +03:00
mobile-nixos/release.nix
Samuel Dionne-Riel 3f377dd275 release.nix: Init, for hydra consumption
This release.nix is intended to provide:

 * Builds for our overlay
 * Builds for all devices
2020-03-13 18:06:00 -04:00

108 lines
3.2 KiB
Nix

{ mobile-nixos ? builtins.fetchGit ./.
# By default, builds all devices.
, devices ? (import ./all-devices.nix)
# By default, assume we eval only for currentSystem
, systems ? [ builtins.currentSystem ]
# nixpkgs is also an input, used as `<nixpkgs>` in the system configuration.
}:
let
# We require some `lib` stuff in here.
# Pick a lib from the ambient <nixpkgs>.
inherit (import <nixpkgs> {}) lib;
# Given a device compatible with `default.nix`, eval.
evalFor = device: (import ./. { inherit device; });
# Systems we should eval for, per host system.
# Non-native will be assumed cross.
shouldEvalOn = {
x86_64-linux = [
"armv7l-linux"
"aarch64-linux"
"x86_64-linux"
];
aarch64-linux = [
"aarch64-linux"
];
armv7l-linux = [
"armv7l-linux"
];
};
# 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 an evaluated "device", filters `pkgs` down to only our packages
# unique to the overaly.
# Also removes some non-packages from the overlay.
overlayForEval =
let
# Trick the overlay in giving us its attributes.
# Using the values is likely to fail. Thank lazyness!
overlay = import ./overlay/overlay.nix {} {};
in
eval:
(lib.genAttrs (builtins.attrNames overlay) (name: eval.pkgs.${name})) //
{
# We only "monkey patch" over top of the main nixos one.
xorg = {
xf86videofbdev = eval.pkgs.xorg.xf86videofbdev;
};
# lib-like attributes...
# How should we handle these?
imageBuilder = null;
kernel-builder = null;
kernel-builder-gcc49 = null;
kernel-builder-gcc6 = null;
# Also lib-like, but a "global" like attribute :/
defaultKernelPatches = null;
}
;
# Given a system builds run on, this will return a set of further systems
# this builds in, either native or cross.
# The values are `overlayForEval` applied for the pair local/cross systems.
evalForSystem = system: builtins.listToAttrs
(builtins.map (
buildingForSystem:
let
# "device" name for the eval *and* key used for the set.
name = if system == buildingForSystem then buildingForSystem else "${buildingForSystem}-cross";
# "device" eval for our dummy device.
eval = evalFor {
special = true;
inherit name;
config = {
mobile.hardware.soc = {
x86_64-linux = "generic-x86_64";
aarch64-linux = "generic-aarch64";
armv7l-linux = "generic-armv7l";
}.${buildingForSystem};
nixpkgs.localSystem = knownSystems.${system};
};
};
overlay = overlayForEval eval;
in {
inherit name;
value = overlay;
}) shouldEvalOn.${system}
)
;
in
{
overlay =
lib.genAttrs systems (system:
(evalForSystem system)
)
;
device = lib.genAttrs devices (device: (evalFor device).build.default);
}