mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-09-11 12:05:26 +03:00
release-tools: Split useful Mobile NixOS evaluation tools
This is to be used by the documentation system, without requiring to repeat all of the code.
This commit is contained in:
parent
ae2be46466
commit
9179158645
47
lib/release-tools.nix
Normal file
47
lib/release-tools.nix
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
# This should *never* rely on lib or pkgs.
|
||||
all-devices =
|
||||
builtins.filter
|
||||
(d: builtins.pathExists (../. + "/devices/${d}/default.nix"))
|
||||
(builtins.attrNames (builtins.readDir ../devices))
|
||||
;
|
||||
|
||||
# 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.device.info = {};
|
||||
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; }
|
||||
;
|
||||
};
|
||||
}
|
46
release.nix
46
release.nix
@ -8,11 +8,8 @@
|
||||
# Note:
|
||||
# Verify that .ci/instantiate-all.nix lists the expected paths when adding to this file.
|
||||
let
|
||||
all-devices =
|
||||
builtins.filter
|
||||
(d: builtins.pathExists (./. + "/devices/${d}/default.nix"))
|
||||
(builtins.attrNames (builtins.readDir ./devices))
|
||||
;
|
||||
mobileReleaseTools = (import ./lib/release-tools.nix);
|
||||
inherit (mobileReleaseTools) all-devices;
|
||||
in
|
||||
{ mobile-nixos ? builtins.fetchGit ./.
|
||||
# By default, builds all devices.
|
||||
@ -29,12 +26,13 @@ in
|
||||
let
|
||||
# We require some `lib` stuff in here.
|
||||
# Pick a lib from the ambient <nixpkgs>.
|
||||
inherit (import <nixpkgs> {}) lib releaseTools;
|
||||
|
||||
# Given a device compatible with `default.nix`, eval.
|
||||
evalFor = evalWithConfiguration {};
|
||||
evalWithConfiguration = additionalConfiguration: device:
|
||||
import ./. { inherit device additionalConfiguration; }
|
||||
pkgs' = import <nixpkgs> {};
|
||||
inherit (pkgs') lib releaseTools;
|
||||
inherit (mobileReleaseTools.withPkgs pkgs')
|
||||
evalFor
|
||||
evalWithConfiguration
|
||||
knownSystems
|
||||
specialConfig
|
||||
;
|
||||
|
||||
# Systems we should eval for, per host system.
|
||||
@ -53,14 +51,6 @@ let
|
||||
];
|
||||
};
|
||||
|
||||
# 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.
|
||||
@ -90,24 +80,6 @@ let
|
||||
}
|
||||
;
|
||||
|
||||
specialConfig = {name, buildingForSystem, system, config ? {}}: {
|
||||
special = true;
|
||||
inherit name;
|
||||
config = lib.mkMerge [
|
||||
config
|
||||
{
|
||||
mobile.device.info = {};
|
||||
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};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# 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.
|
||||
|
Loading…
Reference in New Issue
Block a user