Commit graph

135 commits

Author SHA1 Message Date
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
Tristan Ross
9f589ea3a0
arocc: init at 0-unstable-06-01 2024-07-27 19:43:41 -07:00
Tristan Ross
2d4c9e6966
pkgs/top-level/{release,stage}.nix: add zig package set 2024-07-27 19:43:41 -07:00
Tristan Ross
2551138e30
pkgsLLVM: use target platform to fix cross 2024-07-26 10:48:35 -07:00
Robert Scott
41cae89e6b glibc: enableCETRuntimeDefault for pkgsExtraHardening 2024-07-15 20:38:15 +01:00
Robert Scott
b207b6ef74 cc-wrapper: add support for shadowstack hardening flag 2024-07-14 21:25:47 +01:00
Franz Pletz
3db93c351d cc-wrapper: add stack clash protection hardening flag
Most Linux distributions are enabling this these days and it does
protect against real world vulnerabilities as demonstrated by
CVE-2018-16864 and CVE-2018-16865.

Fix #53753.

Information on llvm version support gleaned from
6609892a2d
68e07da3e5
092507a730

Information on gcc version support a lot harder to gather,
but both 32bit and 64bit arm do appear to be supported
based on the test suite.
2024-06-07 20:23:46 +01:00
Robert Scott
dd80ca4d00 stdenv: promote zerocallusedregs to defaultHardeningFlags 2024-06-02 23:53:36 +01:00
Aleksana
cab94ab46e
Merge pull request #283460 from rodarima/fix-pkgs-static-gcc-march
pkgsStatic: Pass hostPlatform.gcc attribute
2024-05-16 21:26:10 +08:00
Rodrigo Arias Mallo
e4ee77feb0 pkgsStatic: Pass hostPlatform.gcc attribute
To build the security wrappers[1] the pkgsStatic stdenv is used, so the
binaries are static. However, the hostPlatform may have gcc attributes
that are *required* to build binaries so they can run on the host
platform. In particular, this is the case when using gcc.arch, which
ends up injecting -march=... in the gcc wrapper. Those attributes are
not contained in hostPlatform.parsed.

This change sets the same gcc attributes found in the hostPlatform for
the pkgsStatic cross system, so it can build binaries with the same gcc
flags.

[1]: nixos/modules/security/wrappers/default.nix
2024-05-16 14:08:34 +02:00
Artemis Tosini
06b05d2289 freebsd: Cleanup, get ready to support version 14
* Extend libc

  Include non-libc core libraries in the libc package. Many of these
  mirror libraries present in glibc on linux, such as libgcc, libraries
  used for iconv, and libraries used for reading kernel info (libkvm,
  libprocstat, libmemstat).

  Without this many packages outside the freebsd tree would need to be
  modified to include standard dependencies which would already be on
  the system for other packages.

* Mark FreeBSD as using LLVM

* Update default LLVM version FreeBSD

* Use patch monolith

  The patchesRoot system combined with the fact that each derivation
  will Request specific names of patches makes it very annoying to use
  other FreeBSD source trees with nixpkgs. This new system allows
  providing one Or more entire trees of patches whose contents will be
  dynamically Parsed and only the relevant patches will be applied for
  any one Derivation.

  With this commit, the following knobs are available for specifying the
  FreeBSD source:

  - overriding `freebsd.versionInfo`, for picking another official
    supported FreeBSD release.

  - overriding `freebsd.source` for specifying a specific unpatched
    FreeBSD source tree.

  - overriding `freebsd.patches`, for specifying the patches to apply.

Co-Authored-by: Audrey Dutcher <audrey@rhelmot.io>
Co-Authored-by: John Ericson <John.Ericson@Obsidian.Systems>
2024-05-11 21:52:07 -04:00
Yueh-Shun Li
e9fd4389d2 writeClosure: init, replacing writeReferencesToFile
Replace writeReferencesToFile with writeClosure.

Make writeClosure accept a list of paths instead of a path.

Re-implement with JSON-based exportReferencesGraph interface provided by
__structuredAttrs = true.

Reword the documentation.

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Someone Serge <sergei.kozlukov@aalto.fi>
2024-03-19 02:45:50 +08:00
github-actions[bot]
9819563ca9
Merge master into staging-next 2024-03-02 06:00:53 +00:00
Gabriella Gonzalez
b8698cd8d6
macOS support for NixOS tests (#282401)
Closes #193336
Closes #261694
Related to #108984

The goal here was to get the following flake to build and run on
`aarch64-darwin`:

```nix
{ inputs.nixpkgs.url = <this branch>;

  outputs = { nixpkgs, ... }: {
    checks.aarch64-darwin.default =
      nixpkgs.legacyPackages.aarch64-darwin.nixosTest {
        name = "test";

        nodes.machine = { };

        testScript = "";
      };
  };
}
```

… and after this change it does.  There's no longer a need for the
user to set `nodes.*.nixpkgs.pkgs` or
`nodes.*.virtualisation.host.pkgs` as the correct values are inferred
from the host system.
2024-03-02 06:33:14 +01:00
Robert Scott
4a91b3e798 cc-wrapper: add trivialautovarinit hardening flag support
this equates to -ftrivial-auto-var-init=pattern

clang has removed support for -ftrivial-auto-var-init=zero and
are unlikely to re-add it, so use -ftrivial-auto-var-init=pattern
on both compilers if only to make behaviour more consistent
between the two.

add to pkgsExtraHardening's defaultHardeningFlags.
2024-02-24 12:00:09 +00:00
Robert Scott
e79c133858 add pkgsExtraHardening package set
this package set can be used to trial new hardening flags or
enable those which are still known to cause some problems
2024-01-21 11:16:07 +00:00
Yueh-Shun Li
409f95731e shellcheck-minimal: init
Expose the minimal and stripped shellcheck package used by writeShellApplication.
2023-11-01 06:23:04 +08:00
Silvan Mosberger
f6467c3574 pkgs/by-name: Introduce
This introduces the `pkgs/by-name` directory as proposed by RFC 140.
Included are:
- The implementation to add packages defined in that directory to the
  top-level package scope
- Contributer documentation on how to add packages to it
- A GitHub Actions workflow to check the structure of it on all PRs
2023-09-05 16:10:50 +02:00
Uri Baghin
42b5817e6b pkgsStatic: add support for non-linux host platforms 2023-06-22 15:33:54 +10:00