From d7326deeca3fc7187c0217c3b636c119a61c7d53 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 8 Apr 2023 00:48:44 -0700 Subject: [PATCH 1/4] doc/stdenv/meta.chapter.md: document meta.badPlatforms We don't have any documentation for the `meta.badPlatforms` attribute. This commit adds documentation for it. --- doc/stdenv/meta.chapter.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index 0b4777efdb8c9..3d7b26a37cef2 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -86,6 +86,17 @@ meta.platforms = lib.platforms.linux; Attribute Set `lib.platforms` defines [various common lists](https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix) of platforms types. +### `badPlatforms` {#var-meta-badPlatforms} + +The list of Nix platform types on which the package is known not to be buildable. Hydra will never create prebuilt binaries for these platform types, even if they are in `meta.platforms`. In general it is preferable to set `meta.platforms = lib.platforms.all` and then exclude any platforms on which the package is known not to build. For example, a package which requires dynamic linking and cannot be linked statically could use this: + +```nix +meta.platforms = lib.platforms.all; +meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ]; +``` + +The `lib.meta.availableOn` function can be used to test whether or not a package is available (i.e. buildable) on a given platform. Some packages use this to automatically detect the maximum set of features with which they can be built. For example, `systemd` requires dynamic linking, and has a `meta.badPlatforms` setting similar to the one above. Packages which can be built with or without `systemd` support will use `lib.meta.availableOn` to detect whether or not `systemd` is available on the `hostPlatform` for which they are being built; if it is not available (e.g. due to a statically-linked host platform like `pkgsStatic`) this support will be disabled by default. + ### `tests` {#var-meta-tests} ::: {.warning} From 9d3d7a39a30d32d5d2f9a44ccd3d5af47f48c1ea Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 23 Apr 2023 22:07:59 -0700 Subject: [PATCH 2/4] reformat with one sentence per line --- doc/stdenv/meta.chapter.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index 3d7b26a37cef2..a50a1edb10c7b 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -88,14 +88,20 @@ Attribute Set `lib.platforms` defines [various common lists](https://github.com/ ### `badPlatforms` {#var-meta-badPlatforms} -The list of Nix platform types on which the package is known not to be buildable. Hydra will never create prebuilt binaries for these platform types, even if they are in `meta.platforms`. In general it is preferable to set `meta.platforms = lib.platforms.all` and then exclude any platforms on which the package is known not to build. For example, a package which requires dynamic linking and cannot be linked statically could use this: +The list of Nix platform types on which the package is known not to be buildable. +Hydra will never create prebuilt binaries for these platform types, even if they are in `meta.platforms`. +In general it is preferable to set `meta.platforms = lib.platforms.all` and then exclude any platforms on which the package is known not to build. +For example, a package which requires dynamic linking and cannot be linked statically could use this: ```nix meta.platforms = lib.platforms.all; meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ]; ``` -The `lib.meta.availableOn` function can be used to test whether or not a package is available (i.e. buildable) on a given platform. Some packages use this to automatically detect the maximum set of features with which they can be built. For example, `systemd` requires dynamic linking, and has a `meta.badPlatforms` setting similar to the one above. Packages which can be built with or without `systemd` support will use `lib.meta.availableOn` to detect whether or not `systemd` is available on the `hostPlatform` for which they are being built; if it is not available (e.g. due to a statically-linked host platform like `pkgsStatic`) this support will be disabled by default. +The `lib.meta.availableOn` function can be used to test whether or not a package is available (i.e. buildable) on a given platform. +Some packages use this to automatically detect the maximum set of features with which they can be built. +For example, `systemd` requires dynamic linking, and has a `meta.badPlatforms` setting similar to the one above. +Packages which can be built with or without `systemd` support will use `lib.meta.availableOn` to detect whether or not `systemd` is available on the `hostPlatform` for which they are being built; if it is not available (e.g. due to a statically-linked host platform like `pkgsStatic`) this support will be disabled by default. ### `tests` {#var-meta-tests} From d9e11f91d6b760c6ceebe06fc47a80c42bdd89fc Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 23 Apr 2023 22:13:14 -0700 Subject: [PATCH 3/4] implement https://github.com/NixOS/nixpkgs/pull/225276#discussion_r1166083676 --- doc/stdenv/meta.chapter.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index a50a1edb10c7b..986c25b946957 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -98,10 +98,10 @@ meta.platforms = lib.platforms.all; meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ]; ``` -The `lib.meta.availableOn` function can be used to test whether or not a package is available (i.e. buildable) on a given platform. +The [`lib.meta.availableOn`](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/lib/meta.nix#L95-L106) function can be used to test whether or not a package is available (i.e. buildable) on a given platform. Some packages use this to automatically detect the maximum set of features with which they can be built. -For example, `systemd` requires dynamic linking, and has a `meta.badPlatforms` setting similar to the one above. -Packages which can be built with or without `systemd` support will use `lib.meta.availableOn` to detect whether or not `systemd` is available on the `hostPlatform` for which they are being built; if it is not available (e.g. due to a statically-linked host platform like `pkgsStatic`) this support will be disabled by default. +For example, `systemd` [requires dynamic linking](https://github.com/systemd/systemd/issues/20600#issuecomment-912338965), and [has a `meta.badPlatforms` setting](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/pkgs/os-specific/linux/systemd/default.nix#L752) similar to the one above. +Packages which can be built with or without `systemd` support will use `lib.meta.availableOn` to detect whether or not `systemd` is available on the [`hostPlatform`](#ssec-cross-platform-parameters) for which they are being built; if it is not available (e.g. due to a statically-linked host platform like `pkgsStatic`) this support will be disabled by default. ### `tests` {#var-meta-tests} From 2b6de0562a4499a053e212ae062c10de96d4854c Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 23 Apr 2023 22:17:07 -0700 Subject: [PATCH 4/4] implement recommendations from https://github.com/NixOS/nixpkgs/pull/225276#discussion_r1166078941 --- doc/stdenv/meta.chapter.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index 986c25b946957..48b6efcc35da6 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -88,8 +88,8 @@ Attribute Set `lib.platforms` defines [various common lists](https://github.com/ ### `badPlatforms` {#var-meta-badPlatforms} -The list of Nix platform types on which the package is known not to be buildable. -Hydra will never create prebuilt binaries for these platform types, even if they are in `meta.platforms`. +The list of Nix [platform types](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/lib/meta.nix#L75-L81) on which the package is known not to be buildable. +Hydra will never create prebuilt binaries for these platform types, even if they are in [`meta.platforms`](#var-meta-platforms). In general it is preferable to set `meta.platforms = lib.platforms.all` and then exclude any platforms on which the package is known not to build. For example, a package which requires dynamic linking and cannot be linked statically could use this: @@ -190,7 +190,7 @@ To be effective, it must be presented directly to an evaluation process that han ### `hydraPlatforms` {#var-meta-hydraPlatforms} -The list of Nix platform types for which the Hydra instance at `hydra.nixos.org` will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of `meta.platforms`. Thus, the only reason to set `meta.hydraPlatforms` is if you want `hydra.nixos.org` to build the package on a subset of `meta.platforms`, or not at all, e.g. +The list of Nix platform types for which the [Hydra](https://github.com/nixos/hydra) [instance at `hydra.nixos.org`](https://nixos.org/hydra) will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of `meta.platforms`. Thus, the only reason to set `meta.hydraPlatforms` is if you want `hydra.nixos.org` to build the package on a subset of `meta.platforms`, or not at all, e.g. ```nix meta.platforms = lib.platforms.linux;