rustc allows code to perform compile-time tests against target_env [0], which is a function of the target triple. There isn't provision in Nixpkgs for learning target_env, however. That doesn't affect rustc's evaluation of cfg guards in Rust code - rustc knows perfectly well what target_env is - but it _does_ affect the env vars passed to a build script set by buildRustCrate, which is presently hard-coded to gnu, and also affects any Nix code looking to branch on target_env. Being able to access target_env is very relevant to, for example, WASI as (using Rust terminology) wasm32-wasip1 and wasm32-wasip2 differ only by target_env, with identical target_arch and target_os values. Properly reflecting target_env may also fix some random musl issues if you're a bit lucky. This commit adds a new attr, rust.platform.env, which reflects the target_env that rustc will set for the target, and wires it up in buildRustCrate. In isolation, this change mostly only affects build scripts checking target_env, but crate2nix will greatly benefit from being able to accurately resolve the dep graph (which can also vary depending on target_env). The target triple -> target_env function resists Kolmogorov compression: it's irregular and, though there are some patterns, there are lots of special cases. So, I have done the stupidest possible thing and scraped out all of the targets with non-empty target_env values and dumped that into an attrset. This attrset will progressively get out of date as rustc adds new platforms, but updating it should be simple enough - I've included the generation script as a comment. There are some other configuration options not being reflected in Nix. I have left those alone, but, in the future, maybe this can be extended to just dumping all of them into an attrset and then reflecting them in rust.platform. It might even make sense to convert the existing code producing rust.platform to just looking up from an attrset and to 'do what rustc does'. I would have liked to have added a test targetting a platform with a non-empty non-GNU target_env, but all of the yaks were quite hairy. Fixes https://github.com/NixOS/nixpkgs/issues/436832 [0]: https://doc.rust-lang.org/reference/conditional-compilation.html#r-cfg.target_env
Nixpkgs is a collection of over 140,000 software packages that can be installed with the Nix package manager. It also implements NixOS, a purely-functional Linux distribution.
Manuals
- NixOS Manual - how to install, configure, and maintain a purely-functional Linux distribution
- Nixpkgs Manual - contributing to Nixpkgs and using programming-language-specific Nix expressions
- Nix Package Manager Manual - how to write Nix expressions (programs), and how to use Nix command line tools
Community
- Discourse Forum
- Matrix Chat
- Official wiki
- Community-maintained list of ways to get in touch (Discord, Telegram, IRC, etc.)
Other Project Repositories
The sources of all official Nix-related projects are in the NixOS organization on GitHub. Here are some of the main ones:
- Nix - the purely functional package manager
- NixOps - the tool to remotely deploy NixOS machines
- nixos-hardware - NixOS profiles to optimize settings for different hardware
- Nix RFCs - the formal process for making substantial changes to the community
- NixOS homepage - the NixOS.org website
- hydra - our continuous integration system
- NixOS Branding - NixOS branding
Continuous Integration and Distribution
Nixpkgs and NixOS are built and tested by our continuous integration system, Hydra.
- Continuous package builds for unstable/master
- Continuous package builds for the NixOS 26.05 release
- Tests for unstable/master
- Tests for the NixOS 26.05 release
Artifacts successfully built with Hydra are published to cache at https://cache.nixos.org/. When successful build and test criteria are met, the Nixpkgs expressions are distributed via Nix channels.
Contributing
Nixpkgs is among the most active projects on GitHub. While thousands of open issues and pull requests might seem like a lot at first, it helps to consider it in the context of the scope of the project. Nixpkgs describes how to build tens of thousands of pieces of software and implements a Linux distribution. The GitHub Insights page gives a sense of the project activity.
Community contributions are always welcome through GitHub Issues and Pull Requests.
For more information about contributing to the project, please visit the contributing page.
Donations
The infrastructure for NixOS and related projects is maintained by a nonprofit organization, the NixOS Foundation. To ensure the continuity and expansion of the NixOS infrastructure, we are looking for donations to our organization.
You can donate to the NixOS Foundation through SEPA bank transfers or by using Open Collective:
License
Nixpkgs is licensed under the MIT License.
Note
MIT license does not apply to the packages built by Nixpkgs, merely to the files in this repository (the Nix expressions, build scripts, NixOS modules, etc.). It also might not apply to patches included in Nixpkgs, which may be derivative works of the packages to which they apply. The aforementioned artifacts are all covered by the licenses of the respective packages.