diff options
author | Jared Baur <jaredbaur@fastmail.com> | 2024-02-29 19:22:33 -0800 |
---|---|---|
committer | Jared Baur <jaredbaur@fastmail.com> | 2024-03-01 09:05:08 -0800 |
commit | 3794246066409d7baac72e3fdfb0e4f66ef4a013 (patch) | |
tree | 384e1bd97c44dc4d23401b0b50f99db8064bcba0 /nixos | |
parent | 244ee5631a7a39b0c6bd989cdf9a1326cd3c5819 (diff) | |
download | nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.tar nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.tar.gz nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.tar.bz2 nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.tar.lz nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.tar.xz nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.tar.zst nixlib-3794246066409d7baac72e3fdfb0e4f66ef4a013.zip |
nixos/nixpkgs: fix determination for cross-compiled nixos system
Since the output of `lib.systems.elaborate` contains functions, an equality check with `==` does not suffice, `lib.systems.equals` should be used instead.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/misc/nixpkgs.nix | 6 | ||||
-rw-r--r-- | nixos/modules/misc/nixpkgs/test.nix | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index da321a923449..10f800cd741a 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -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 '' diff --git a/nixos/modules/misc/nixpkgs/test.nix b/nixos/modules/misc/nixpkgs/test.nix index 0536cfc9624a..be9a88a07788 100644 --- a/nixos/modules/misc/nixpkgs/test.nix +++ b/nixos/modules/misc/nixpkgs/test.nix @@ -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 == ['' |