1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-13 04:04:35 +03:00

Fix attribute 'selectBySystem' missing with lib.systems.elaborate

Closes #252.

This uses the `lib.systems.elaborate` function which builds the
complete attrset as preferred by Nixpkgs by using
`lib.systems.elaborate`, rather than building a partial equivalent.

@noneucat originally implemented it the simplest way possible, re-using
parts of the now unneeded custom functions. We can, instead, simply
pass a system name to `elaborate`, which ends up doing the right thing.

Co-authored-by: Andy Chun <andy@lolc.at>
Co-authored-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
This commit is contained in:
Andy Chun 2020-12-23 20:10:11 -08:00 committed by Samuel Dionne-Riel
parent 21f662ac08
commit 692544a5ef

View File

@ -5,32 +5,18 @@ let
cfg = config.mobile.system;
inherit (config.nixpkgs) localSystem;
# Mapping from system types to config types
# A simplified view of <nixpkgs/lib/systems/examples.nix>
config_types = {
aarch64-linux = "aarch64-unknown-linux-gnu";
armv7l-linux = "armv7l-unknown-linux-gnueabihf";
x86_64-linux = "x86_64-unknown-linux-gnu";
};
# Derived from config_types
target_types = lib.attrNames config_types;
# Builds the expected "platform" set for cross-compilation from the given
# system name.
selectPlatform = system: {
inherit system;
platform = lib.systems.platforms.selectBySystem system;
config = config_types.${system};
};
# The platform selected by the configuration
selectedPlatform = selectPlatform cfg.system;
selectedPlatform = lib.systems.elaborate cfg.system;
in
{
options.mobile = {
system.system = mkOption {
type = types.enum target_types;
# Known supported target types for Mobile NixOS
type = types.enum [
"aarch64-linux"
"armv7l-linux"
"x86_64-linux"
];
description = ''
Defines the kind of target architecture system the device is.