Merge pull request #292487 from jmbaur/nixos-cross-check

nixos/nixpkgs: fix determination for cross-compiled nixos system
This commit is contained in:
Robert Hensing
2024-03-01 18:19:58 +01:00
committed by GitHub
2 changed files with 11 additions and 1 deletions
+5 -1
View File
@@ -208,7 +208,11 @@ in
example = { system = "x86_64-linux"; };
# Make sure that the final value has all fields for sake of other modules
# referring to this.
apply = lib.systems.elaborate;
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 = literalExpression
''config.nixpkgs.hostPlatform'';
description = lib.mdDoc ''
+6
View File
@@ -12,6 +12,10 @@ let
nixpkgs.hostPlatform = "aarch64-linux";
nixpkgs.buildPlatform = "aarch64-darwin";
};
withSameHostAndBuild = eval {
nixpkgs.hostPlatform = "aarch64-linux";
nixpkgs.buildPlatform = "aarch64-linux";
};
ambiguous = {
_file = "ambiguous.nix";
nixpkgs.hostPlatform = "aarch64-linux";
@@ -81,6 +85,8 @@ lib.recurseIntoAttrs {
assert withHost._module.args.pkgs.stdenv.buildPlatform.system == "aarch64-linux";
assert withHostAndBuild._module.args.pkgs.stdenv.hostPlatform.system == "aarch64-linux";
assert withHostAndBuild._module.args.pkgs.stdenv.buildPlatform.system == "aarch64-darwin";
assert withSameHostAndBuild.config.nixpkgs.buildPlatform == withSameHostAndBuild.config.nixpkgs.hostPlatform;
assert withSameHostAndBuild._module.args.pkgs.stdenv.buildPlatform == withSameHostAndBuild._module.args.pkgs.stdenv.hostPlatform;
assert builtins.trace (lib.head (getErrors ambiguous))
getErrors ambiguous ==
[''