153 Commits

Author SHA1 Message Date
Philip Taron
e03d0a783d various: reduce // merges, optimize ++ chains across hot paths (#506793) 2026-05-27 22:06:37 +00:00
Ryan Burns
f2c799c9df pkgsStatic: make pkgsMusl a no-op
When pkgsStatic is already musl, we can let pkgsMusl simply be a no-op.
As the interaction of pkgsStatic and pkgsMusl machinery is currently
broken, this fixes pkgsStatic.pkgsMusl.stdenv.
2026-05-18 16:35:06 -07:00
Aliaksandr
702420055d top-level/stage: replace // optionalAttrs with nullable attr names
Convert 2 optionalAttrs: Darwin extraBuildInputs in stdenvNoCC
override, and !isSupported stdenv override in pkgsi686Linux.
2026-05-18 03:54:27 +03:00
Jonas Chevalier
6ed003c564 appendOverlays: preserve splicing on empty overlay list (#501313) 2026-04-07 14:19:48 +00:00
Emily
11b761e60d pkgsi686Linux: force i686-linux on unsupported platforms
Otherwise we end up evaluating into `i686-darwin` in CI…
2026-03-27 21:37:51 +00:00
Wolfgang Walther
e07663a621 top-level/stage: assert no by-name overwrites
This asserts that no by-name packages are overwritten by definitions in
all-packages.nix.
2026-03-20 16:59:19 -04:00
DavHau
99ab2550e7 appendOverlays: return spliced packages on empty overlay list
`appendOverlays []` returned `self` (the unspliced inner fixpoint)
while `import nixpkgs {}` returns `pkgs.__splicedPackages` (the
spliced version). This caused `pkgs.makeWrapper` and similar
spliced packages to lose their `__spliced` attribute after passing
through `appendOverlays`, breaking cross-compilation in NixOS
modules.

The NixOS `nixpkgs.nix` module calls `cfg.pkgs.appendOverlays
cfg.overlays`, and when no overlays are defined, the empty-list
short-circuit returned unspliced packages. This meant
`nativeBuildInputs = [ pkgs.makeWrapper ]` in NixOS modules would
evaluate the host-platform makeWrapper (which throws in cross
context) instead of being spliced to buildPackages.makeWrapper.

Fix by returning `self.__splicedPackages` instead of `self` for
the empty-list case.
2026-03-19 22:05:32 +08:00
Tobias Mayer
4c05f197e6 lib.systems: s/makeMuslParsedPlatform/mkMuslSystem/ 2026-03-06 23:38:09 +01:00
Tobias Mayer
4cd3967a68 lib.systems: expose makeMuslParsedPlatform
Moving this helper from pkgs/stdenv/stage.nix so it can be used
for alternative variations of pkgsMusl and pkgsStatic.
2026-02-14 23:09:33 +01:00
quantenzitrone
233631a84f treewide: remove references to the xorg namespace in pkgs (manual)
this was done manually, fixing the eval and any remaining stuff of the previous commit

together with the previous commit this shouldn't create any rebuilds
2026-01-25 22:28:14 +01:00
Wolfgang Walther
91a8fee3aa treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
NAHO
c8d4dabc43 pkgs: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --type file \
      . \
      pkgs \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2025-10-04 19:02:37 +02:00
Emily
731391c2b9 stdenvNoCC: fix extraBuildInputs on Darwin
Closes: #371465
Fixes: 4928668e21
2025-07-29 16:05:10 +01:00
Wolfgang Walther
612e76db51 pkgsx86_64Darwin: move behind allowVariants
This is already not used in-tree, so should be a variant.
2025-07-24 15:31:04 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Wolfgang Walther
eb875b4a98 pkgsi686Linux: only throw with aliases enabled
For the regular user, this still throws early whenever an attribute
tries to use `pkgsi686Linux`. For CI, this doesn't throw, but instead
overwrites `mkDerivation` to return only derivations marked as
`meta.broken`. This propagates to all reverse dependencies and allows
filtering out these attributes nicely on unsupported platforms.
2025-07-23 08:52:16 +02:00
Tristan Ross
5d5599f720 pkgs/top-level/stage.nix: fix allowVariants with variants set 2025-07-18 13:57:29 -07:00
Peder Bergebakken Sundt
c77ac9dfc3 treewide: fix typos 2025-06-02 16:07:07 +02:00
Tristan Ross
14386224a1 pkgs/top-level/stage.nix: move most nixpkgs sets to variants 2025-05-17 18:03:57 -07:00
Ben Siraphob
9beafa4d27 Revert "stdenv: add uutils-coreutils stdenv" 2025-05-14 15:32:32 -04:00
Sandro Jäckel
bace9f322a pkgsUutils: init 2025-05-14 18:22:17 +02:00
nixpkgs-ci[bot]
c376a565f9 Merge staging-next into staging 2025-04-24 18:04:57 +00:00
zowoq
0931f4e861 Revert "pkgs/top-level/stage.nix: add pkgsLLVMLibc"
This reverts commit 41b14024d2.
2025-04-24 14:04:25 +10:00
Robert Scott
781b42b87d cc-wrapper: add nostrictaliasing hardening flag support
this equates to -fno-strict-aliasing

this is not a particularly new flag and is supported by all our
gcc and clang versions.

add to pkgsExtraHardening's defaultHardeningFlags.
2025-04-06 12:52:47 +01:00
Silvan Mosberger
e52d633a63 Merge remote-tracking branch 'upstream/staging-next' into staging 2025-04-02 18:30:54 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Pavol Rusnak
2925f716f8 rocmPackages: 6.0.2 -> 6.3.3, and various ROCm build fixes and new packages (#367695) 2025-03-24 21:11:47 +01:00
Randy Eckenrode
4928668e21 stdenvNoCC: drop extraBuildInputs on Darwin
Darwin includes its SDK in `extraBuildInputs`, which isn’t needed in
`stdenvNoCC` because it depends on a compiler.  Including it greatly
increases the size of the `stdenvNoCC` closure (by ~1 GiB).

This wasn’t an issue in the past when darwin included CoreFoundation
because CoreFoundation on its own is very small.  Now that it includes
the whole SDK and links some bintools, it pulls in 300~400 MiB for the
SDK plus another ~445 MiB for LLVM.

Fixes #371465
2025-03-24 08:17:31 -04:00
Luna Nova
72a714071e pkgsRocm: add package set with cuda config off, rocm config on 2025-03-19 22:26:48 -07:00
Martin Weinelt
3ebfc6ddcf bintools-wrapper: enable stackclashprotection hardening flag by default (#374893) 2025-02-08 18:16:17 +01:00
Robert Hensing
692a57e61d Revert "Reapply "pkgs/top-level: make package sets composable""
This reverts commit d2faa1bbca.
2025-02-05 14:29:11 +01:00
Wolfgang Walther
d2faa1bbca Reapply "pkgs/top-level: make package sets composable"
This reverts commit 7c251e2b5f.

Left out eec21001b0, which changed
nixos/nixpkgs, doing it differently this time.
2025-02-01 12:04:59 +01:00
K900
7c251e2b5f Revert "pkgs/top-level: make package sets composable" 2025-01-26 09:43:44 +03:00
Wolfgang Walther
2acca93bef pkgs/top-level: fix composing "native cross" package sets
When using pkgsCross with a system that ends up the same as the
localSystem, then modifications for package sets like pksgMusl need to
be done for **both** localSystem and crossSystem. Consider the following
on x86_64-linux:

  pkgsCross.gnu64.pkgsMusl

Before this change, this would result in a musl buildPlatform, but a gnu
hostPlatform. This breaks the promise of "stacking" package sets on top
of each other.

After this change, it results in a musl buildPlatform and a musl
hostPlatform. This works better.

One could expect this to result in the same as pkgsCross.musl64, i.e. a
gnu buildPlatform and a musl hostPlatform, however I couldn't get this
to work without increasing memory usage for ci/eval by many, many GB.
This is caused by usage of pkgsi686Linux inside the main package set,
which follows the same hybrid pattern.
2025-01-25 18:58:09 +01:00
Wolfgang Walther
69775e2deb pkgs/top-level: refactor mkHybridPkgs 2025-01-25 18:58:09 +01:00
Wolfgang Walther
ba6262f2eb pkgs/top-level: refactor mkCrossPkgs 2025-01-25 18:58:07 +01:00
Wolfgang Walther
01a02e41f7 pkgs/top-level: make package sets composable
The various pkgsXYZ top-level package sets did not pass localSystem /
crossSystem to lower levels, so far. This change propagates original
arguments to lower levels, which include the overrides made by an upper
package sets.

There is an extensive test-suite to test various combinations of package
sets in pkgs/test/top-level. There are a few basic promises made:

- Package sets must be idempotent. pkgsMusl.pkgsMusl === pkgsMusl.

- Once pkgsCross is used any subsequent package sets should affect the
  **host platform** and not the build platform. Examples:
  - pkgsMusl.pkgsCross.aarch64-multiplatform is a cross compilation from
musl to glibc/aarch64
  - pkgsCross.aarch64-multiplatform.pkgsMusl is a cross compilation to
musl/aarch64

- Modifications from an earlier layer should not be lost, unless
  explicitly overwritten. Examples:
  - pkgsStatic.pkgsMusl should still be static.
  - pkgsStatic.pkgsCross.gnu64 should be static, but with glibc instead
of musl.

Exceptions / TODOs:
- pkgsExtraHardening is currently not idempotent, because it applies the
  same flags over and over again.

Supersedes #136549
Resolves #114510
Resolves #212494
Resolves #281596
2025-01-25 18:55:03 +01:00
Wolfgang Walther
071851299f pkgs/top-level: refactor mkPkgs
Sharing a first piece of common code between all package sets makes it
easier to maintain and less likely to introduce a new package set
without this.
2025-01-25 18:01:45 +01:00
Wolfgang Walther
3fcedef056 pkgs/top-level/stage: refactor moving more generic package sets to the bottom
No change, just move appendOverlays and extend to the bottom, since they
will be changed much less often. This makes it easier to compare the
other package sets side-by-side.
2025-01-25 17:59:54 +01:00
Wolfgang Walther
4e7cc47a22 pkgs/top-level: rewrite some outdated comments
This removes all specific references to pkgsCross or pkgsi686Linux, because
they have become outdated with the addition of many more package sets.
2025-01-25 17:59:54 +01:00
Robert Scott
04791f4a4d bintools-wrapper: enable stackclashprotection by default 2025-01-11 12:31:08 +00:00
Tristan Ross
41b14024d2 pkgs/top-level/stage.nix: add pkgsLLVMLibc 2025-01-10 20:54:19 -08:00
Peter Waller
a4543ae1bc pkgsLLVM: Fix unwanted target offset
pkgsLLVM introduced an unwanted target offset, as can be seen with the
following commands.

Before this commit:

```
$ nix eval --system x86_64-linux -f . pkgsCross.aarch64-multiplatform.buildPackages.stdenv.hostPlatform.config
"x86_64-unknown-linux-gnu"
$ nix eval --system x86_64-linux -f . pkgsCross.aarch64-multiplatform.buildPackages.pkgsLLVM.stdenv.hostPlatform.config
"aarch64-unknown-linux-gnu"

Explaination: These two should be the same, since the only difference
between them is the addition of "pkgsLLVM". The buildPackages of the
pkgsCross set should have a hostPlatform which is the native platform.
```

After this commit:

```
$ nix eval --system x86_64-linux -f . pkgsCross.aarch64-multiplatform.buildPackages.stdenv.hostPlatform.config
"x86_64-unknown-linux-gnu"
$ nix eval --system x86_64-linux -f . pkgsCross.aarch64-multiplatform.buildPackages.pkgsLLVM.stdenv.hostPlatform.config
"x86_64-unknown-linux-gnu"
```
2024-12-10 09:01:31 +00:00
Wolfgang Walther
3c21a5c9d6 lib/systems: elaborate properly with non-matching system / config / parsed args
When elaborating a system with both "config" and "system" arguments
given, they might not match the parsed results.  Example:

elaborate {
  config = "i686-unknown-linux-gnu";
  system = "x86_64-linux";
}

This would result in a parsed system for i686, because the config
argument is preferred.  But since "// args //" comes after system has
been inferred from parsed, it is overwritten again.  This results in
config and parsed all pointing to i686, while system still tells the
story of x86_64.

Inconsistent arguments can also be given when passing "parsed" directly.
This happened in stage.nix for the various package sets.

The solution is simple: One of the three arguments needs to be treated
as the ultimate source of truth.  "system" can already be losslessly
extracted from "parsed".  However, "config" currently can not, for
example for various -mingw32 cases.  Thus everything must be derived
from "config".

To do so, "system" and "parsed" arguments are made non-overrideable for
systems.elaborate.  This means, that "system" will be used to parse when
"config" is not given - and "parsed" will be ignored entirely.

The systemToAttrs helper is exposed on lib.systems, because it's useful
to deal with top-level localSystem / crossSystem arguments elsewhere.
2024-11-03 17:38:19 +01:00
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
John Ericson
5f134ec6cf Clean up cross bootstrapping
For a long time, we've had `crossLibcStdenv`, `*Cross` libc attributes,
and `*bsdCross` pre-libc package sets. This was always bad because
having "cross" things is "not declarative": the naming doesn't reflect
what packages *need* but rather how we *provide* something. This is
ugly, and creates needless friction between cross and native building.

Now, almost all of these `*Cross` attributes are gone: just these are
kept:

- Glibc's and Musl's are kept, because those packages are widely used
  and I didn't want to risk changing the native builds of those at this
  time.

- generic `libcCross`, `theadsCross`, and friends, because these relate
  to the convolulted GCC bootstrap which still needs to be redone.

The BSD and obscure Linux or freestnanding libcs have conversely all
been made to use a new `stdenvNoLibc`, which is like the old
`crossLibcStdenv` except:

1. It usable for native and cross alike

2. It named according to what it *is* ("a standard environment without
   libc but with a C compiler"), rather than some non-compositional
   jargon ("the stdenv used for building libc when cross compiling",
   yuck).

I should have done this change long ago, but I was stymied because of
"infinite recursions". The problem was that in too many cases we are
overriding `stdenv` to *remove* things we don't need, and this risks
cyles since those more minimal stdenvs are used to build things in the
more maximal stdenvs.

The solution is to pass `stage.nix` `stdenvNoCC`, so we can override to
*build up* rather than *tear down*. For now, the full `stdenv` is also
passed, so I don't need to change the native bootstraps, but I can see
this changing as we make things more uniform and clean those up.

(adapted from commit 51f1ecaa59)
(adapted from commit 1743662e55)
2024-09-06 10:26:56 -04:00
K900
4f29b5a16b Merge remote-tracking branch 'origin/staging-next' into staging 2024-07-31 08:57:17 +03:00
Robert Scott
48bde3a189 cc-wrapper: add support for pacret hardening flag on aarch64 2024-07-28 19:27:14 +01:00
tomberek
cc7b011fe1 Merge pull request #318034 from ExpidusOS/feat/zig-cc
Add stdenv & CC support for Zig
2024-07-28 14:09:31 -04:00
Robert Scott
a30f794865 pcre: expose enableJit argument, disable shadowstack when enabled 2024-07-28 17:40:54 +01:00