2019-09-25 03:29:44 +03:00
|
|
|
let
|
|
|
|
# Selection of the device can be made either through the environment or through
|
|
|
|
# using `--argstr device [...]`.
|
|
|
|
deviceFromEnv = builtins.getEnv "MOBILE_NIXOS_DEVICE";
|
2019-09-21 22:40:46 +03:00
|
|
|
|
2019-09-25 03:29:44 +03:00
|
|
|
# Selection of the configuration can by made either through NIX_PATH,
|
2020-03-14 01:13:24 +03:00
|
|
|
# through local.nix or as a parameter.
|
2019-09-25 03:29:44 +03:00
|
|
|
default_configuration =
|
|
|
|
let
|
|
|
|
configPathFromNixPath = (builtins.tryEval <mobile-nixos-configuration>).value;
|
|
|
|
in
|
|
|
|
if configPathFromNixPath != false then [ configPathFromNixPath ]
|
2020-03-14 01:13:24 +03:00
|
|
|
else if (builtins.pathExists ./local.nix) then builtins.trace "WARNING: evaluation includes ./local.nix" [ (import ./local.nix) ]
|
2019-09-25 03:29:44 +03:00
|
|
|
else []
|
|
|
|
;
|
2019-09-22 05:40:24 +03:00
|
|
|
|
2019-09-25 03:29:44 +03:00
|
|
|
# "a" nixpkgs we're using for its lib.
|
|
|
|
pkgs' = import <nixpkgs> {};
|
2020-03-13 05:08:40 +03:00
|
|
|
inherit (pkgs'.lib) optional strings;
|
|
|
|
inherit (strings) concatStringsSep stringAsChars;
|
2019-09-25 03:29:44 +03:00
|
|
|
in
|
|
|
|
{
|
2019-09-22 05:40:24 +03:00
|
|
|
# The identifier of the device this should be built for.
|
2019-09-25 03:29:44 +03:00
|
|
|
# (This gets massaged later on)
|
|
|
|
# This allows using `default.nix` as a pass-through function.
|
|
|
|
# See usage in examples folder.
|
|
|
|
device ? null
|
|
|
|
, configuration ? default_configuration
|
2020-03-14 01:17:18 +03:00
|
|
|
# Internally used to tack on configuration by release.nix
|
2020-03-14 07:34:27 +03:00
|
|
|
, additionalConfiguration ? {}
|
2018-06-17 02:21:41 +03:00
|
|
|
}:
|
|
|
|
let
|
2019-09-25 03:29:44 +03:00
|
|
|
# Either use:
|
|
|
|
# The given `device`.
|
|
|
|
# The environment variable.
|
2020-03-13 21:55:22 +03:00
|
|
|
final_device =
|
|
|
|
if device != null then device
|
2019-09-25 03:29:44 +03:00
|
|
|
else if deviceFromEnv == "" then
|
|
|
|
throw "Please pass a device name or set the MOBILE_NIXOS_DEVICE environment variable."
|
|
|
|
else deviceFromEnv
|
|
|
|
;
|
|
|
|
|
2020-04-06 23:28:10 +03:00
|
|
|
inherit (import ./lib/release-tools.nix) evalWith;
|
2019-09-22 05:40:24 +03:00
|
|
|
|
2019-09-25 03:29:44 +03:00
|
|
|
# The "default" eval.
|
2020-04-06 23:28:10 +03:00
|
|
|
eval = evalWith {
|
|
|
|
device = final_device;
|
|
|
|
modules = configuration;
|
2020-04-08 06:13:07 +03:00
|
|
|
inherit additionalConfiguration;
|
2020-04-06 23:28:10 +03:00
|
|
|
};
|
2019-09-22 05:45:41 +03:00
|
|
|
|
|
|
|
# This is used by the `-A installer` shortcut.
|
2020-04-06 23:28:10 +03:00
|
|
|
installer-eval = evalWith {
|
|
|
|
modules = [
|
|
|
|
./profiles/installer.nix
|
|
|
|
];
|
|
|
|
};
|
2020-03-13 00:57:57 +03:00
|
|
|
|
|
|
|
# Makes a mostly useless header.
|
|
|
|
# This is mainly useful for batch evals.
|
|
|
|
header = str:
|
|
|
|
let
|
|
|
|
str' = "* ${str} *";
|
|
|
|
line = stringAsChars (x: "*") str';
|
|
|
|
in
|
|
|
|
builtins.trace (concatStringsSep "\ntrace: " [line str' line])
|
|
|
|
;
|
2018-06-17 02:21:41 +03:00
|
|
|
in
|
2020-03-13 21:55:22 +03:00
|
|
|
(
|
|
|
|
if device ? special
|
|
|
|
then header "Evaluating: ${device.name}"
|
|
|
|
else header "Evaluating device: ${device}"
|
|
|
|
)
|
|
|
|
{
|
2019-09-22 05:40:24 +03:00
|
|
|
# The build artifacts from the modules system.
|
|
|
|
inherit (eval.config.system) build;
|
|
|
|
|
|
|
|
# The evaluated config
|
|
|
|
inherit (eval) config;
|
|
|
|
|
|
|
|
# The final pkgs set, usable as -A pkgs.[...] on the CLI.
|
|
|
|
inherit (eval) pkgs;
|
|
|
|
|
|
|
|
# The whole (default) eval
|
2019-09-21 22:40:46 +03:00
|
|
|
inherit eval;
|
2018-06-24 00:11:07 +03:00
|
|
|
|
|
|
|
# Shortcut to allow building `nixos` from the same channel revision.
|
|
|
|
# This is used by `./nixos/default.nix`
|
|
|
|
# Any time `nix-build nixos` is used upstream, it can be used here.
|
2019-09-22 05:40:24 +03:00
|
|
|
nixos = import <nixpkgs/nixos>;
|
|
|
|
|
2019-09-22 05:45:41 +03:00
|
|
|
# `mobile-installer` will, when possible, contain the installer build for the
|
|
|
|
# given system. It usually is an alias for a disk-image type build.
|
|
|
|
installer = installer-eval.config.system.build.mobile-installer;
|
|
|
|
|
2019-09-22 05:40:24 +03:00
|
|
|
# Evaluating this whole set is counter-productive.
|
|
|
|
# It'll put a *bunch* of build products from the misc. inherits we added.
|
|
|
|
|
|
|
|
# (We're also using `device` to force the other throw to happen first.)
|
|
|
|
# TODO : We may want to produce an internal list of available outputs, so that
|
|
|
|
# each platform can document what it makes available. This would allow
|
|
|
|
# the message to be more user-friendly by displaying a choice.
|
|
|
|
__please-fail = throw ''
|
2019-09-25 03:29:44 +03:00
|
|
|
Cannot directly build for ${final_device}...
|
2019-09-22 05:40:24 +03:00
|
|
|
|
|
|
|
Building this whole set is counter-productive, and not likely to be what
|
|
|
|
is desired.
|
|
|
|
|
2019-09-22 05:45:41 +03:00
|
|
|
You can try to build the `installer` attribute (-A installer) if your system
|
|
|
|
provides an installer.
|
|
|
|
|
2019-09-22 05:40:24 +03:00
|
|
|
Please refer to your platform's documentation for usage.
|
|
|
|
'';
|
2018-06-17 02:21:41 +03:00
|
|
|
}
|