summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-04 23:31:08 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-05 00:06:10 +0100
commita2cbc77e4f1cf55a9c142d07377f67b0f83985ec (patch)
tree81934d578f6fd86d09443bdc9b3ce2c0cd42aeef
parent8867304b5e8bab1741b5b32d7a503d58fccf055e (diff)
downloadnixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.tar
nixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.tar.gz
nixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.tar.bz2
nixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.tar.lz
nixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.tar.xz
nixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.tar.zst
nixpkgs-a2cbc77e4f1cf55a9c142d07377f67b0f83985ec.zip
Only show/build a package on the platforms listed in meta.platforms
The function ‘mkDerivation’ now checks whether the current platform
type is included in a package's meta.platform field.  If not, it
throws an exception:

  $ nix-build -A linux --argstr system x86_64-darwin
  error: user-thrown exception: the package ‘linux-3.10.15’ is not supported on ‘x86_64-darwin’

These packages also no longer show up in ‘nix-env -qa’ output.  This
means, for instance, that the number of packages shown on
x86_64-freebsd has dropped from 9268 to 4764.

Since meta.platforms was also used to prevent Hydra from building some
packages, there now is a new attribute meta.hydraPlatforms listing the
platforms on which Hydra should build the package (which defaults to
meta.platforms).
-rw-r--r--doc/meta.xml41
-rw-r--r--pkgs/applications/version-management/darcs/default.nix9
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix3
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/default.nix5
-rw-r--r--pkgs/stdenv/generic/default.nix2
-rw-r--r--pkgs/top-level/release-lib.nix8
6 files changed, 55 insertions, 13 deletions
diff --git a/doc/meta.xml b/doc/meta.xml
index df84915cc09..00e9b8ac67a 100644
--- a/doc/meta.xml
+++ b/doc/meta.xml
@@ -119,6 +119,47 @@ interpretation:</para>
   </varlistentry>
 
   <varlistentry>
+    <term><varname>platforms</varname></term>
+    <listitem><para>The list of Nix platform types on which the
+    package is supported.  If this attribute is set, the package will
+    refuse to build, and won’t show up in <literal>nix-env
+    -qa</literal> output, on any platform not listed
+    here.  An example is:
+
+<programlisting>
+meta.platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
+</programlisting>
+
+    The set <varname>lib.platforms</varname> defines various common
+    lists of platforms types, so it’s more typical to write:
+
+<programlisting>
+meta.platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+</programlisting>
+
+    </para></listitem>
+  </varlistentry>
+
+  <varlistentry>
+    <term><varname>hydraPlatforms</varname></term>
+    <listitem><para>The list of Nix platform types for which the Hydra
+    instance at <literal>hydra.nixos.org</literal> should build the
+    package.  (Hydra is the Nix-based continuous build system.)  It
+    defaults to the value of <varname>meta.platforms</varname>.  Thus,
+    the only reason to set <varname>meta.hydraPlatforms</varname> is
+    if you want <literal>hydra.nixos.org</literal> to build the
+    package on a subset of <varname>meta.platforms</varname>, or not
+    at all, e.g.
+
+<programlisting>
+meta.platforms = stdenv.lib.platforms.linux;
+meta.hydraPlatforms = [];
+</programlisting>
+
+    </para></listitem>
+  </varlistentry>
+
+  <varlistentry>
     <term><varname>broken</varname></term>
     <listitem><para>If set to <literal>true</literal>, the package is
     marked as “broken”, meaning that it won’t show up in
diff --git a/pkgs/applications/version-management/darcs/default.nix b/pkgs/applications/version-management/darcs/default.nix
index f33e479b3ad..8ec65e50adf 100644
--- a/pkgs/applications/version-management/darcs/default.nix
+++ b/pkgs/applications/version-management/darcs/default.nix
@@ -21,10 +21,13 @@ cabal.mkDerivation (self: {
     mv contrib/darcs_completion $out/etc/bash_completion.d/darcs
   '';
   meta = {
-    homepage = "http://darcs.net/";
-    description = "a distributed, interactive, smart revision control system";
+    homepage = http://darcs.net/;
+    description = "A distributed, interactive, smart revision control system";
     license = "GPL";
-    platforms = self.ghc.meta.platforms;
+    # FIXME: this gives an infinite recursion in the "darcs" attribute
+    # in all-packages.nix.
+    #platforms = self.ghc.meta.platforms;
+    platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
     maintainers = [ self.stdenv.lib.maintainers.andres ];
   };
 })
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 1ade2473627..3e1fc920a59 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -40,9 +40,6 @@
 , ...
 }:
 
-assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"
-  || stdenv.isArm || stdenv.system == "mips64el-linux";
-
 assert stdenv.platform.name == "sheevaplug" -> stdenv.platform.uboot != null;
 
 let
diff --git a/pkgs/os-specific/linux/nvidia-x11/default.nix b/pkgs/os-specific/linux/nvidia-x11/default.nix
index 35595a7b8f4..f9239bb5fba 100644
--- a/pkgs/os-specific/linux/nvidia-x11/default.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/default.nix
@@ -21,8 +21,7 @@ stdenv.mkDerivation {
 
   patches =
     [ ./version-test.patch ]
-    ++ optional (!libsOnly && versionAtLeast kernelDev.version "3.11") ./nvidia-drivers-linux-3.11-incremental.patch
-    ;
+    ++ optional (!libsOnly && versionAtLeast kernelDev.version "3.11") ./nvidia-drivers-linux-3.11-incremental.patch;
 
   src =
     if stdenv.system == "i686-linux" then
@@ -58,5 +57,7 @@ stdenv.mkDerivation {
     homepage = http://www.nvidia.com/object/unix.html;
     description = "X.org driver and kernel module for NVIDIA graphics cards";
     license = stdenv.lib.licenses.unfreeRedistributable;
+    platforms = stdenv.lib.platforms.linux;
+    hydraPlatforms = [];
   };
 }
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 083a71548b9..fcd7439e97e 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -55,6 +55,8 @@ let
             throw "package ‘${attrs.name}’ has an unfree license, refusing to evaluate"
           else if !allowBroken && attrs.meta.broken or false then
             throw "you can't use package ‘${attrs.name}’ because it has been marked as broken"
+          else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then
+            throw "the package ‘${attrs.name}’ is not supported on ‘${result.system}’"
           else
             lib.addPassthru (derivation (
               (removeAttrs attrs ["meta" "passthru" "crossAttrs"])
diff --git a/pkgs/top-level/release-lib.nix b/pkgs/top-level/release-lib.nix
index 3280df09dd5..e2f5309ced3 100644
--- a/pkgs/top-level/release-lib.nix
+++ b/pkgs/top-level/release-lib.nix
@@ -119,14 +119,12 @@ rec {
 
   # May fail as much as it wishes, we will catch the error.
   processPackage = attrSet:
-    if attrSet ? recurseForDerivations && attrSet.recurseForDerivations then
+    if attrSet.recurseForDerivations or false then
       packagesWithMetaPlatform attrSet
-    else if attrSet ? recurseForRelease && attrSet.recurseForRelease then
+    else if attrSet.recurseForRelease or false then
       packagesWithMetaPlatform attrSet
     else
-      if attrSet ? meta && attrSet.meta ? platforms
-        then attrSet.meta.platforms
-        else [];
+      attrSet.meta.hydraPlatforms or (attrSet.meta.platforms or []);
 
 
   /* Common platform groups on which to test packages. */