Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc/stdenv/meta.chapter.md: document meta.badPlatforms #225276

Merged
merged 4 commits into from Apr 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/stdenv/meta.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
This conversation was marked as resolved.
Show resolved Hide resolved

```nix
meta.platforms = lib.platforms.all;
meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ];
```
Comment on lines +96 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd have a complete example that we could refer to. We have to expect readers to drop into any piece of documentation with barely any contextual knowledge of Nix or Nixpkgs idioms or inner workings. While this snippet is enough if you know that it would apply in a mkDerivation call, it gets really confusing if you don't. Maybe in the example introduction we can refer and link to a full example, outlining how this snippet would fit in and which effect it would have.


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.
This conversation was marked as resolved.
Show resolved Hide resolved

### `tests` {#var-meta-tests}

::: {.warning}
Expand Down