2020-03-31 21:59:20 +03:00
|
|
|
# What's release.nix?
|
|
|
|
# ===================
|
|
|
|
#
|
|
|
|
# This is mainly intended to be run by the build farm at the foundation's Hydra
|
|
|
|
# instance. Though you can use it to run your builds, it is not as ergonomic as
|
|
|
|
# using `nix-build` on `./default.nix`.
|
|
|
|
#
|
2021-08-26 23:48:09 +03:00
|
|
|
# Also note that *by design* it still relies on NIX_PATH being used for the
|
|
|
|
# input Nixpkgs.
|
|
|
|
#
|
2020-03-29 05:44:01 +03:00
|
|
|
# Note:
|
|
|
|
# Verify that .ci/instantiate-all.nix lists the expected paths when adding to this file.
|
2020-03-14 02:59:26 +03:00
|
|
|
let
|
2021-08-26 23:48:09 +03:00
|
|
|
# An ambiant arbitrary Nixpkgs package set.
|
|
|
|
# This is assumed to be used for e.g. Hydra evals where <nixpkgs> is an input.
|
|
|
|
# This pkgs' is used as an input to release-tools, *and* to get a `lib`.
|
|
|
|
# Named pkgs' to reduce confusion with fully evaluated `pkgs`.
|
|
|
|
pkgs' = import <nixpkgs> {};
|
|
|
|
|
|
|
|
mobileReleaseTools = (import ./lib/release-tools.nix {
|
|
|
|
pkgs = pkgs';
|
|
|
|
});
|
2020-04-04 21:36:23 +03:00
|
|
|
inherit (mobileReleaseTools) all-devices;
|
2020-03-14 02:59:26 +03:00
|
|
|
in
|
2020-03-14 01:06:00 +03:00
|
|
|
{ mobile-nixos ? builtins.fetchGit ./.
|
|
|
|
# By default, builds all devices.
|
2020-03-14 02:59:26 +03:00
|
|
|
, devices ? all-devices
|
2020-03-14 01:06:00 +03:00
|
|
|
# By default, assume we eval only for currentSystem
|
|
|
|
, systems ? [ builtins.currentSystem ]
|
|
|
|
# nixpkgs is also an input, used as `<nixpkgs>` in the system configuration.
|
2020-03-31 06:33:31 +03:00
|
|
|
|
|
|
|
# Some additional configuration will be made with this.
|
|
|
|
# Mainly to work with some limitations (output size).
|
|
|
|
, inNixOSHydra ? false
|
2020-03-14 01:06:00 +03:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# We require some `lib` stuff in here.
|
2021-08-26 23:48:09 +03:00
|
|
|
# Pick a lib from the arbitrary package set.
|
2020-04-04 21:36:23 +03:00
|
|
|
inherit (pkgs') lib releaseTools;
|
|
|
|
inherit (mobileReleaseTools.withPkgs pkgs')
|
|
|
|
evalFor
|
|
|
|
evalWithConfiguration
|
|
|
|
knownSystems
|
|
|
|
specialConfig
|
2020-03-14 01:21:58 +03:00
|
|
|
;
|
2020-03-14 01:06:00 +03:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-03-01 08:17:51 +03:00
|
|
|
onlyDerivations = lib.filterAttrs (k: v: lib.isDerivation v);
|
|
|
|
onlyDerivationsAndAttrsets = lib.filterAttrs (k: v: lib.isDerivation v || (lib.isAttrs v && !lib.isFunction v));
|
|
|
|
|
2020-03-14 01:06:00 +03:00
|
|
|
# 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!
|
2021-02-25 01:43:39 +03:00
|
|
|
overlayAttrNames = builtins.attrNames (import ./overlay/overlay.nix {} {});
|
2020-03-14 01:06:00 +03:00
|
|
|
in
|
2021-02-25 01:43:39 +03:00
|
|
|
eval: let overlay = (lib.genAttrs overlayAttrNames (name: eval.pkgs.${name})); in
|
|
|
|
overlay // {
|
2020-03-14 01:06:00 +03:00
|
|
|
# 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;
|
2021-03-01 08:17:51 +03:00
|
|
|
mobile-nixos = (onlyDerivationsAndAttrsets overlay.mobile-nixos) // {
|
|
|
|
# The cross canaries attrsets will be used as constituents.
|
|
|
|
# Filter out `override` and `overrideAttrs` early.
|
|
|
|
cross-canary-test = onlyDerivations overlay.mobile-nixos.cross-canary-test;
|
|
|
|
cross-canary-test-static = onlyDerivations overlay.mobile-nixos.cross-canary-test-static;
|
2021-02-25 01:43:39 +03:00
|
|
|
};
|
2020-03-14 01:06:00 +03:00
|
|
|
|
|
|
|
# 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.
|
2020-03-29 06:28:36 +03:00
|
|
|
eval = evalFor (specialConfig {inherit name buildingForSystem system;});
|
2020-03-14 01:06:00 +03:00
|
|
|
overlay = overlayForEval eval;
|
|
|
|
in {
|
|
|
|
inherit name;
|
|
|
|
value = overlay;
|
|
|
|
}) shouldEvalOn.${system}
|
|
|
|
)
|
|
|
|
;
|
2020-03-14 01:21:58 +03:00
|
|
|
|
|
|
|
# `device` here is indexed by the system it's being built on first.
|
|
|
|
# FIXME: can we better filter this?
|
|
|
|
device = lib.genAttrs devices (device:
|
|
|
|
lib.genAttrs systems (system:
|
|
|
|
(evalWithConfiguration {
|
|
|
|
nixpkgs.localSystem = knownSystems.${system};
|
2021-08-27 06:50:32 +03:00
|
|
|
} device).config.mobile.outputs.default
|
2020-03-14 01:21:58 +03:00
|
|
|
)
|
|
|
|
);
|
2020-03-29 06:28:36 +03:00
|
|
|
|
2021-12-04 01:05:50 +03:00
|
|
|
# `kernel` here is indexed by the system it's being built on first.
|
|
|
|
# FIXME: can we better filter this?
|
|
|
|
kernel = lib.genAttrs devices (device:
|
|
|
|
lib.genAttrs systems (system:
|
|
|
|
(evalWithConfiguration {
|
|
|
|
nixpkgs.localSystem = knownSystems.${system};
|
|
|
|
} device).config.mobile.boot.stage-1.kernel.package
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2022-09-30 23:24:44 +03:00
|
|
|
evalExample =
|
|
|
|
{ example
|
|
|
|
, system
|
|
|
|
, targetSystem ? system
|
|
|
|
}:
|
|
|
|
import example {
|
|
|
|
device = specialConfig {
|
|
|
|
name =
|
|
|
|
if system == targetSystem
|
|
|
|
then system
|
|
|
|
else "${targetSystem}-built-on-${system}"
|
|
|
|
;
|
|
|
|
inherit system;
|
|
|
|
buildingForSystem = targetSystem;
|
|
|
|
config = {
|
|
|
|
# Ensures outputs are digestible by Hydra
|
|
|
|
mobile._internal.compressLargeArtifacts = inNixOSHydra;
|
|
|
|
# Build a generic rootfs
|
|
|
|
mobile.rootfs.shared.enabled = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2022-10-14 06:01:21 +03:00
|
|
|
evalInstaller =
|
|
|
|
{ device
|
|
|
|
, localSystem
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
eval = evalWithConfiguration {
|
|
|
|
imports = [
|
|
|
|
./examples/installer/configuration.nix
|
|
|
|
];
|
|
|
|
nixpkgs.localSystem = knownSystems.${localSystem};
|
|
|
|
} device;
|
|
|
|
in
|
|
|
|
eval // { inherit (eval.config.mobile) outputs; }
|
|
|
|
;
|
|
|
|
|
2022-09-30 21:31:22 +03:00
|
|
|
doc = import ./doc {
|
|
|
|
pkgs = pkgs';
|
|
|
|
};
|
2020-03-14 01:47:11 +03:00
|
|
|
in
|
2021-02-21 23:25:36 +03:00
|
|
|
rec {
|
2020-03-14 01:47:11 +03:00
|
|
|
inherit device;
|
2021-12-04 01:05:50 +03:00
|
|
|
inherit kernel;
|
2021-08-26 23:48:30 +03:00
|
|
|
inherit doc;
|
2020-03-14 01:47:11 +03:00
|
|
|
|
2022-09-30 23:24:44 +03:00
|
|
|
# Some example systems to build.
|
|
|
|
# They track breaking changes, and ensures dependencies are built.
|
|
|
|
# They may or may not work as-they-are on devices. YMMV.
|
|
|
|
examples = {
|
|
|
|
hello = {
|
2022-10-26 02:22:26 +03:00
|
|
|
x86_64-linux.toplevel = (evalExample { example = ./examples/hello; system = "x86_64-linux"; }).outputs.toplevel;
|
|
|
|
aarch64-linux.toplevel = (evalExample { example = ./examples/hello; system = "aarch64-linux"; }).outputs.toplevel;
|
|
|
|
cross-x86-aarch64.toplevel = (evalExample { example = ./examples/hello; system = "x86_64-linux"; targetSystem = "aarch64-linux"; }).outputs.toplevel;
|
|
|
|
cross-x86-armv7l.toplevel = (evalExample { example = ./examples/hello; system = "x86_64-linux"; targetSystem = "armv7l-linux"; }).outputs.toplevel;
|
2022-09-30 23:24:44 +03:00
|
|
|
};
|
|
|
|
phosh = {
|
2022-10-26 02:22:26 +03:00
|
|
|
x86_64-linux.toplevel = (evalExample { example = ./examples/phosh; system = "x86_64-linux"; }).outputs.toplevel;
|
|
|
|
aarch64-linux.toplevel = (evalExample { example = ./examples/phosh; system = "aarch64-linux"; }).outputs.toplevel;
|
|
|
|
cross-x86-aarch64.toplevel = (evalExample { example = ./examples/phosh; system = "x86_64-linux"; targetSystem = "aarch64-linux"; }).outputs.toplevel;
|
2022-09-30 23:24:44 +03:00
|
|
|
};
|
2022-10-01 06:40:42 +03:00
|
|
|
plasma-mobile = {
|
2022-10-26 02:22:26 +03:00
|
|
|
x86_64-linux.toplevel = (evalExample { example = ./examples/plasma-mobile; system = "x86_64-linux"; }).outputs.toplevel;
|
|
|
|
aarch64-linux.toplevel = (evalExample { example = ./examples/plasma-mobile; system = "aarch64-linux"; }).outputs.toplevel;
|
|
|
|
cross-x86-aarch64.toplevel = (evalExample { example = ./examples/plasma-mobile; system = "x86_64-linux"; targetSystem = "aarch64-linux"; }).outputs.toplevel;
|
2022-10-01 06:40:42 +03:00
|
|
|
};
|
2022-09-30 23:24:44 +03:00
|
|
|
};
|
|
|
|
|
2022-10-14 06:01:21 +03:00
|
|
|
installer = {
|
2022-11-17 01:50:59 +03:00
|
|
|
lenovo-krane = (evalInstaller { device = "lenovo-krane"; localSystem = "aarch64-linux"; }).outputs.default;
|
2023-01-24 04:09:40 +03:00
|
|
|
lenovo-wormdingler = (evalInstaller { device = "lenovo-wormdingler"; localSystem = "aarch64-linux"; }).outputs.default;
|
2022-10-14 06:01:21 +03:00
|
|
|
pine64-pinephone = (evalInstaller { device = "pine64-pinephone"; localSystem = "aarch64-linux"; }).outputs.default;
|
|
|
|
};
|
|
|
|
|
2020-03-14 01:47:11 +03:00
|
|
|
# Overlays build native, and cross, according to shouldEvalOn
|
|
|
|
overlay = lib.genAttrs systems (system:
|
|
|
|
(evalForSystem system)
|
|
|
|
);
|
|
|
|
|
2021-03-04 04:42:17 +03:00
|
|
|
cross-canaries = lib.genAttrs ["aarch64-linux" "armv7l-linux"] (system:
|
|
|
|
releaseTools.aggregate {
|
|
|
|
name = "cross-canaries-${system}";
|
|
|
|
constituents =
|
|
|
|
let
|
|
|
|
overlay' = overlay.x86_64-linux."${system}-cross";
|
|
|
|
in
|
|
|
|
(builtins.attrValues overlay'.mobile-nixos.cross-canary-test)
|
|
|
|
++ (builtins.attrValues overlay'.mobile-nixos.cross-canary-test-static)
|
|
|
|
;
|
|
|
|
meta = {
|
|
|
|
description = "Useful checks for cross-compilation.";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-10-14 06:01:21 +03:00
|
|
|
cross-compiled = {
|
|
|
|
installer = {
|
2022-11-17 01:50:59 +03:00
|
|
|
lenovo-krane = (evalInstaller { device = "lenovo-krane"; localSystem = "x86_64-linux"; }).outputs.default;
|
2023-01-24 04:09:40 +03:00
|
|
|
lenovo-wormdingler = (evalInstaller { device = "lenovo-wormdingler"; localSystem = "x86_64-linux"; }).outputs.default;
|
2022-10-14 06:01:21 +03:00
|
|
|
pine64-pinephone = (evalInstaller { device = "pine64-pinephone"; localSystem = "x86_64-linux"; }).outputs.default;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-03-14 01:47:11 +03:00
|
|
|
tested = let
|
|
|
|
hasSystem = name: lib.lists.any (el: el == name) systems;
|
|
|
|
|
|
|
|
constituents =
|
2021-03-04 04:42:17 +03:00
|
|
|
cross-canaries.aarch64-linux.constituents
|
2021-02-25 05:43:34 +03:00
|
|
|
++ lib.optionals (hasSystem "x86_64-linux") [
|
2020-12-11 07:24:29 +03:00
|
|
|
device.uefi-x86_64.x86_64-linux # UEFI system
|
2022-09-30 23:24:44 +03:00
|
|
|
|
2020-03-14 01:47:11 +03:00
|
|
|
# Cross builds
|
|
|
|
device.asus-z00t.x86_64-linux # Android
|
|
|
|
device.asus-dumo.x86_64-linux # Depthcharge
|
2021-02-28 01:49:30 +03:00
|
|
|
|
2022-09-30 23:24:44 +03:00
|
|
|
# Example systems
|
2022-10-26 02:22:26 +03:00
|
|
|
examples.hello.x86_64-linux.toplevel
|
|
|
|
examples.hello.cross-x86-aarch64.toplevel
|
|
|
|
examples.phosh.x86_64-linux.toplevel
|
|
|
|
examples.plasma-mobile.x86_64-linux.toplevel
|
2022-09-30 23:24:44 +03:00
|
|
|
|
2021-02-28 01:49:30 +03:00
|
|
|
# Flashable zip binaries are universal for a platform.
|
|
|
|
overlay.x86_64-linux.aarch64-linux-cross.mobile-nixos.android-flashable-zip-binaries
|
2020-03-14 01:47:11 +03:00
|
|
|
]
|
|
|
|
++ lib.optionals (hasSystem "aarch64-linux") [
|
|
|
|
device.asus-z00t.aarch64-linux # Android
|
|
|
|
device.asus-dumo.aarch64-linux # Depthcharge
|
2021-02-28 01:49:30 +03:00
|
|
|
|
2022-09-30 23:24:44 +03:00
|
|
|
# Example systems
|
2022-10-26 02:22:26 +03:00
|
|
|
examples.hello.aarch64-linux.toplevel
|
|
|
|
examples.phosh.aarch64-linux.toplevel
|
|
|
|
examples.plasma-mobile.aarch64-linux.toplevel
|
2022-09-30 23:24:44 +03:00
|
|
|
|
2022-10-14 06:01:21 +03:00
|
|
|
installer.pine64-pinephone
|
|
|
|
|
2021-02-28 01:49:30 +03:00
|
|
|
# Flashable zip binaries are universal for a platform.
|
|
|
|
overlay.aarch64-linux.aarch64-linux.mobile-nixos.android-flashable-zip-binaries
|
2020-03-14 01:47:11 +03:00
|
|
|
];
|
|
|
|
in
|
|
|
|
releaseTools.aggregate {
|
|
|
|
name = "mobile-nixos-tested";
|
|
|
|
inherit constituents;
|
|
|
|
meta = {
|
|
|
|
description = "Representative subset of devices that have to succeed.";
|
|
|
|
};
|
|
|
|
};
|
2021-02-21 23:25:36 +03:00
|
|
|
|
|
|
|
# Uses the constituents of tested
|
|
|
|
testedPlus = let
|
|
|
|
hasSystem = name: lib.lists.any (el: el == name) systems;
|
|
|
|
|
|
|
|
constituents = tested.constituents
|
2021-03-04 04:42:17 +03:00
|
|
|
++ cross-canaries.armv7l-linux.constituents
|
2021-02-21 23:25:36 +03:00
|
|
|
++ lib.optionals (hasSystem "x86_64-linux") [
|
|
|
|
device.asus-flo.x86_64-linux
|
2021-02-28 01:49:30 +03:00
|
|
|
overlay.x86_64-linux.armv7l-linux-cross.mobile-nixos.android-flashable-zip-binaries
|
2022-10-26 02:22:26 +03:00
|
|
|
examples.hello.cross-x86-armv7l.toplevel
|
2021-02-21 23:25:36 +03:00
|
|
|
]
|
|
|
|
++ lib.optionals (hasSystem "aarch64-linux") [
|
|
|
|
]
|
|
|
|
++ lib.optionals (hasSystem "armv7l-linux") [
|
|
|
|
device.asus-flo.armv7l-linux
|
2021-02-28 01:49:30 +03:00
|
|
|
overlay.armv7l-linux.armv7l-linux.mobile-nixos.android-flashable-zip-binaries
|
2021-02-21 23:25:36 +03:00
|
|
|
]
|
|
|
|
;
|
|
|
|
in
|
|
|
|
releaseTools.aggregate {
|
2021-02-25 05:43:34 +03:00
|
|
|
name = "mobile-nixos-tested-plus";
|
2021-02-21 23:25:36 +03:00
|
|
|
inherit constituents;
|
|
|
|
meta = {
|
|
|
|
description = ''
|
|
|
|
Other targets that may be failing more often than `tested`.
|
|
|
|
This contains more esoteric and less tested platforms.
|
|
|
|
|
|
|
|
For a future release, `testedPlus` shoud also pass.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-03-14 01:06:00 +03:00
|
|
|
}
|