git.iko.soy/typeable/nixpkgs
on master help sign in
top-level: Deprecate top-level `{build,host,target}Platform`

I don't know when we can/should remove them, but this at least gets people to stop using them. The preferred alternatives also date back to 17.09 so writing forward-compatable code without extra conditions is easy. Beginning with these as they are the least controversial.

commite51f736076548459f36a1250de4bf6867f880b66 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateMon 27 Aug 2018, 14:39 (8 years ago) parent51907d2
2 files changed+14−12
doc/cross-compilation.xml+3−7 pkgs/top-level/stage.nix+11−5
doc/cross-compilation.xml+3−7
@@ -47,13 +47,9 @@
4747
4848 <para>
4949 In Nixpkgs, these three platforms are defined as attribute sets under the
50− names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>,
51− and <literal>targetPlatform</literal>. All three are always defined as
52− attributes in the standard environment, and at the top level. That means
53− one can get at them just like a dependency in a function that is imported
54− with <literal>callPackage</literal>:
55−<programlisting>{ stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...buildPlatform...</programlisting>
56− , or just off <varname>stdenv</varname>:
50+ names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>, and
51+ <literal>targetPlatform</literal>. They are always defined as attributes in
52+ the standard environment. That means one can access them like:
5753<programlisting>{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...</programlisting>
5854 .
5955 </para>
pkgs/top-level/stage.nix+11−5
@@ -79,11 +79,17 @@ let
7979
8080 # The old identifiers for cross-compiling. These should eventually be removed,
8181 # and the packages that rely on them refactored accordingly.
82− platformCompat = self: super: let
83− inherit (super.stdenv) buildPlatform hostPlatform targetPlatform;
84− in {
85− inherit buildPlatform hostPlatform targetPlatform;
86− inherit (buildPlatform) system;
82+ platformCompat = self: super: {
83+ buildPlatform = lib.warn
84+ "top-level `buildPlatform` is deprecated since 18.09. Please use `stdenv.buildPlatform`."
85+ super.stdenv.buildPlatform;
86+ hostPlatform = lib.warn
87+ "top-level `hostPlatform` is deprecated since 18.09. Please use `stdenv.hostPlatform`."
88+ super.stdenv.hostPlatform;
89+ targetPlatform = lib.warn
90+ "top-level `targetPlatform` is deprecated since 18.09. Please use `stdenv.targetPlatform`."
91+ super.stdenv.targetPlatform;
92+ inherit (super.stdenv.buildPlatform) system;
8793 };
8894
8995 splice = self: super: import ./splice.nix lib self (buildPackages != null);