Skip to content

Commit

Permalink
Merge pull request #46146 from obsidiansystems/deprecate-top-level-pl…
Browse files Browse the repository at this point in the history
…atform-aliases

top-level: Deprecate top-level `{build,host,target}Platform` for 18.09
  • Loading branch information
John Ericson committed Sep 6, 2018
2 parents 77a56c9 + e51f736 commit 5e3f2d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
10 changes: 3 additions & 7 deletions doc/cross-compilation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@

<para>
In Nixpkgs, these three platforms are defined as attribute sets under the
names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>,
and <literal>targetPlatform</literal>. All three are always defined as
attributes in the standard environment, and at the top level. That means
one can get at them just like a dependency in a function that is imported
with <literal>callPackage</literal>:
<programlisting>{ stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...buildPlatform...</programlisting>
, or just off <varname>stdenv</varname>:
names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>, and
<literal>targetPlatform</literal>. They are always defined as attributes in
the standard environment. That means one can access them like:
<programlisting>{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...</programlisting>
.
</para>
Expand Down
16 changes: 11 additions & 5 deletions pkgs/top-level/stage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ let

# The old identifiers for cross-compiling. These should eventually be removed,
# and the packages that rely on them refactored accordingly.
platformCompat = self: super: let
inherit (super.stdenv) buildPlatform hostPlatform targetPlatform;
in {
inherit buildPlatform hostPlatform targetPlatform;
inherit (buildPlatform) system;
platformCompat = self: super: {
buildPlatform = lib.warn
"top-level `buildPlatform` is deprecated since 18.09. Please use `stdenv.buildPlatform`."
super.stdenv.buildPlatform;
hostPlatform = lib.warn
"top-level `hostPlatform` is deprecated since 18.09. Please use `stdenv.hostPlatform`."
super.stdenv.hostPlatform;
targetPlatform = lib.warn
"top-level `targetPlatform` is deprecated since 18.09. Please use `stdenv.targetPlatform`."
super.stdenv.targetPlatform;
inherit (super.stdenv.buildPlatform) system;
};

splice = self: super: import ./splice.nix lib self (buildPackages != null);
Expand Down

0 comments on commit 5e3f2d4

Please sign in to comment.