mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00
Revert "nixos/nixpkgs: make config.nixpkgs.{localSystem,crossSystem,buildPlatform,hostPlatform} write only"
This reverts commit 0a19371146
.
This commit is contained in:
parent
692a57e61d
commit
0b47fba230
6 changed files with 46 additions and 37 deletions
|
@ -73,10 +73,7 @@ let
|
|||
defaultPkgs =
|
||||
if opt.hostPlatform.isDefined then
|
||||
let
|
||||
isCross =
|
||||
!(lib.systems.equals (lib.systems.elaborate cfg.buildPlatform) (
|
||||
lib.systems.elaborate cfg.hostPlatform
|
||||
));
|
||||
isCross = cfg.buildPlatform != cfg.hostPlatform;
|
||||
systemArgs =
|
||||
if isCross then
|
||||
{
|
||||
|
@ -198,10 +195,13 @@ in
|
|||
};
|
||||
|
||||
hostPlatform = lib.mkOption {
|
||||
type = lib.types.either lib.types.str lib.types.attrs;
|
||||
type = lib.types.either lib.types.str lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
example = {
|
||||
system = "aarch64-linux";
|
||||
};
|
||||
# Make sure that the final value has all fields for sake of other modules
|
||||
# referring to this. TODO make `lib.systems` itself use the module system.
|
||||
apply = lib.systems.elaborate;
|
||||
defaultText = lib.literalExpression ''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
|
||||
description = ''
|
||||
Specifies the platform where the NixOS configuration will run.
|
||||
|
@ -213,13 +213,22 @@ in
|
|||
};
|
||||
|
||||
buildPlatform = lib.mkOption {
|
||||
type = lib.types.either lib.types.str lib.types.attrs;
|
||||
type = lib.types.either lib.types.str lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
default = cfg.hostPlatform;
|
||||
example = {
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
# Make sure that the final value has all fields for sake of other modules
|
||||
# referring to this.
|
||||
apply =
|
||||
inputBuildPlatform:
|
||||
let
|
||||
elaborated = lib.systems.elaborate inputBuildPlatform;
|
||||
in
|
||||
if lib.systems.equals elaborated cfg.hostPlatform then
|
||||
cfg.hostPlatform # make identical, so that `==` equality works; see https://github.com/NixOS/nixpkgs/issues/278001
|
||||
else
|
||||
elaborated;
|
||||
defaultText = lib.literalExpression ''config.nixpkgs.hostPlatform'';
|
||||
description = ''
|
||||
Specifies the platform on which NixOS should be built.
|
||||
|
@ -236,11 +245,14 @@ in
|
|||
};
|
||||
|
||||
localSystem = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
type = lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
default = { inherit (cfg) system; };
|
||||
example = {
|
||||
system = "aarch64-linux";
|
||||
};
|
||||
# Make sure that the final value has all fields for sake of other modules
|
||||
# referring to this. TODO make `lib.systems` itself use the module system.
|
||||
apply = lib.systems.elaborate;
|
||||
defaultText = lib.literalExpression ''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
|
||||
description = ''
|
||||
Systems with a recently generated `hardware-configuration.nix`
|
||||
|
@ -268,7 +280,7 @@ in
|
|||
# is a relation between at least 2 systems in the context of a
|
||||
# specific build step, not a single system.
|
||||
crossSystem = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.attrs;
|
||||
type = lib.types.nullOr lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
default = null;
|
||||
example = {
|
||||
system = "aarch64-linux";
|
||||
|
@ -404,18 +416,6 @@ in
|
|||
${lib.concatMapStringsSep "\n" (file: " - ${file}") opt.config.files}
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
(opt.hostPlatform.isDefined -> builtins.isAttrs cfg.buildPlatform -> !(cfg.buildPlatform ? parsed))
|
||||
&& (opt.hostPlatform.isDefined -> builtins.isAttrs cfg.hostPlatform -> !(cfg.hostPlatform ? parsed))
|
||||
&& (builtins.isAttrs cfg.localSystem -> !(cfg.localSystem ? parsed))
|
||||
&& (builtins.isAttrs cfg.crossSystem -> !(cfg.crossSystem ? parsed));
|
||||
message = ''
|
||||
Passing fully elaborated systems to `nixpkgs.localSystem`, `nixpkgs.crossSystem`, `nixpkgs.buildPlatform`
|
||||
or `nixpkgs.hostPlatform` will break composability of package sets in nixpkgs. For example, pkgs.pkgsStatic
|
||||
would not work in modules anymore.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
@ -40,11 +40,20 @@ in
|
|||
The Nixpkgs overlays that `pkgs` was initialized with.
|
||||
'';
|
||||
};
|
||||
# buildPlatform and hostPlatform left out on purpose:
|
||||
# - They are not supposed to be changed with this read-only module.
|
||||
# - They are not supposed to be read either, according to the description
|
||||
# of "system" in the traditional nixpkgs module.
|
||||
#
|
||||
hostPlatform = mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
description = ''
|
||||
The platform of the machine that is running the NixOS configuration.
|
||||
'';
|
||||
};
|
||||
buildPlatform = mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
description = ''
|
||||
The platform of the machine that built the NixOS configuration.
|
||||
'';
|
||||
};
|
||||
# NOTE: do not add the legacy options such as localSystem here. Let's keep
|
||||
# this module simple and let module authors upgrade their code instead.
|
||||
};
|
||||
|
@ -52,8 +61,12 @@ in
|
|||
config = {
|
||||
_module.args.pkgs =
|
||||
# find mistaken definitions
|
||||
builtins.seq cfg.config builtins.seq cfg.overlays cfg.pkgs;
|
||||
builtins.seq cfg.config builtins.seq cfg.overlays builtins.seq cfg.hostPlatform builtins.seq
|
||||
cfg.buildPlatform
|
||||
cfg.pkgs;
|
||||
nixpkgs.config = cfg.pkgs.config;
|
||||
nixpkgs.overlays = cfg.pkgs.overlays;
|
||||
nixpkgs.hostPlatform = cfg.pkgs.stdenv.hostPlatform;
|
||||
nixpkgs.buildPlatform = cfg.pkgs.stdenv.buildPlatform;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue