Commit Graph

197 Commits

Author SHA1 Message Date
Will Fancher
226f8c7618 buildLinux: Forward buildDTBs and target arguments
Fixes #533937
2026-06-21 11:46:27 -04:00
Emily
31d1d80b3f lib/systems: move kernel configuration out of the platform structure
Currently, you need to override `stdenv.hostPlatform` to request a
compressed kernel on AArch64, and the kernel configuration is split
between the central structured configuration and string snippets in
platform definitions. This has consequently made the latter bitrot
terribly. Since the platform‐specific logic is now very limited after
cleaning up the detritus, we can move it into the kernel derivation
and expose the relevant configuration there for anyone who wants to
customize it further or needs to read it out.

Co-authored-by: zowoq <59103226+zowoq@users.noreply.github.com>
2026-06-10 11:17:38 +10:00
Stefan Frijters
41b1ca532a linuxPackages.kernel.configfile: use writeText instead of passAsFile
passAsFile doesn't work if __structuredAttrs is enabled.
2026-04-11 17:17:13 +02:00
zowoq
2879caafcf linux_hardened: remove
isn't maintained to the standards people expect of kernels in nixpkgs
2026-04-04 13:51:50 +10:00
zowoq
abdbeb7205 linux: remove isXen
follow up from 25208eeaba
2026-03-21 14:44:46 +10:00
zowoq
94fc9597d5 linux_libre: remove cruft
follow up from 545a975d7e
2026-03-19 11:05:10 +10:00
n0099
099dedfea0 buildLinux: remove useless top-level let binding 2026-03-07 00:58:29 +00:00
Samuel Dionne-Riel
cd6eb54878 linux: Partially revert "linux: drop hacky passing around of positions"
This partially reverts commit 845e340ed9.

This re-introduces the `pos` juggling previous done.

The rationale used in the commit was:

> This is long obsolete since the versions are maintained in a JSON
> file now.

That is only accurate for `mainline`. Other in-tree kernels are
maintained in different ways. This led to a loss of information.

Before (cf3f5c4def):

```
nix-repl> linux_latest.meta.position
".../pkgs/os-specific/linux/kernel/mainline.nix:34"
nix-repl> linux_rpi0.meta.position
".../pkgs/os-specific/linux/kernel/linux-rpi.nix:20"

```

After (2fb006b87f):

```
nix-repl> linux_latest.meta.position
".../pkgs/os-specific/linux/kernel/build.nix:558"
nix-repl> linux_rpi0.meta.position
".../pkgs/os-specific/linux/kernel/build.nix:558"
```

This is also observable for out-of-tree kernels:

```
nix-repl> pkgs.linux_jovian.meta.position
".../Jovian-NixOS/pkgs/linux-jovian/default.nix:11"

nix-repl> :r # after updating the Nixpkgs input

nix-repl> pkgs.linux_jovian.meta.position
"/nix/store/xjjq52iwslhz6lbc621a31v0nfdhr5ks-source/pkgs/os-specific/linux/kernel/build.nix:558"
```

This also conveniently works around the root cause of an
`stdenv.mkDerivation`-based `pos` infrec regression when using the
kernel package version in a NixOS configuration to conditionally
apply kernel patches.
2025-11-01 18:21:35 -04:00
Maximilian Bosch
1965f3c77d linux: manual-config.nix -> build.nix
Since I started touching this subsystem, I found the name confusing
since this is the part where we actually compile the kernel and we have
a ready-to-use configuration.

The stated goal of the commit introducing it[1] is to provide a function
to

> make it possible to build a kernel with a user provided .config.

Considering that this is supposed to be a differentiation from other
build mechanisms and nowadays this is the only way to build kernels in
nixpkgs, I figured that `build.nix` is a better name.

`pkgs.linuxManualConfig` isn't renamed on purpose: Kloenk and I are
planning to do more involved work and it may become necessary to change
parts of the API. So asking users to do a migration now just to add
another one soon isn't worth it.

[1] bf7467cbb1
2025-10-24 18:06:29 +02:00
Maximilian Bosch
845e340ed9 linux: drop hacky passing around of positions
This is something I introduced in 63185299f4
to make sure the `version`/`src` attributes point to the files that declare
the version such that we get pinged by ofborg for updates.

This is long obsolete since the versions are maintained in a JSON file
now. Also, the kernel team is listed as owner in the ci/OWNERS file for
the entire subtree, so we definitely get pinged by CI nowadays.

Hence, remove the hackery.
2025-10-24 18:06:29 +02:00
nixpkgs-ci[bot]
e23d356469 Merge staging-next into staging 2025-10-05 00:18:23 +00: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
Alyssa Ross
d884c9a687 Reapply "linux: default stdenv.hostPlatform.linux-kernel"
This reverts commit ddaa949afe.

This was reverted as part of a bulk revert of all kernel changes in a
certain time period — as far as I know there was no actual
justification for reverting this change in particular.  The original
rationale for making this change stands: it's nice for new platforms
not to have to copy the defaults over and over in
lib/systems/platforms.nix.
2025-09-30 12:01:09 +02:00
Elliot Berman
aedb07e294 linux: gate hostPlatform extraConfig by enableCommonConfig
When enableCommonConfig is set to false, we should limit the config
options that are implicitly enabled. extraConfig for
aarch64-multiplatform brings in platform-specific configuration and
limits the ability to create a trimmed down kernel configuration for a
particular board.
2025-08-26 11:27:16 -07:00
Atemu
fd3c915975 linux-kernels: add LTS flag
This serves to differentiate between a kernel that is an LTS release and one
that is merely a regular "stable" release.
2025-08-23 17:42:41 +02:00
Martin Weinelt
98214d19e0 Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/development/python-modules/django-stubs-ext/default.nix
	pkgs/development/python-modules/django-stubs/default.nix
	pkgs/development/python-modules/python-roborock/default.nix
2025-08-10 14:46:08 +02:00
Maximilian Bosch
dccb264578 linux: remove mentions of extraStructuredConfig & throw error
PR #431115 changed extraStructuredConfig to structuredExtraConfig to
follow the deprecation warning about `extraConfig`. However,
`extraStructuredConfig` was mentioned in several places in the docs that
weren't addressed. Also, using this would silently fail since the code
in question would still accept the old key.

This patch updates the docs accordingly and throws an error if the
code-path is reached and `extraStructuredConfig` is being used.
2025-08-10 14:10:50 +02:00
Alyssa Ross
d0584aeeb0 linux: fix cross
The .unwrapped attributes are not correctly spliced.  Use the top
level attributes instead, which are spliced correctly.

Fixes: e9b2edb491 ("linux: un-simplify toolchain selection")
2025-08-08 11:11:42 +02:00
Alyssa Ross
1abb38d2a5 linux: use consistent rustc and rust-bindgen
If we're going to use the unwrapped versions, we should do so
consistently in both parts of the kernel build, not mix and match.

Fixes: e9b2edb491 ("linux: un-simplify toolchain selection")
2025-08-08 11:11:42 +02:00
Vladimír Čunát
a45dc179ff Merge branch 'master' into staging 2025-08-05 13:39:34 +02:00
Alex Lyon
64352daf32 linux: fix structuredExtraConfig 2025-08-05 01:30:25 -07:00
Julian Stecklina
c2420281d2 linux: verify basic configuration sanity
Co-authored-by: Tristan Ross <tristan.ross@midstall.com>
2025-07-28 00:08:54 -07:00
Julian Stecklina
e9b2edb491 linux: un-simplify toolchain selection
This reverts commit 70cc251554.

This commit caused gcc to be pulled in as a target compiler for
pkgsLLVM.

Co-authored-by: Tristan Ross <tristan.ross@midstall.com>
2025-07-28 00:08:48 -07:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Wolfgang Walther
0febbb4ff9 linux: remove assert on linux
Asserting the hostplatform for `linux` is bad, because it can't be
caught by CI. For the `linux` package itself, it doesn't make a
difference, because it also has `meta.platforms = linux` set, so this
will fail evaluation - and in a way that can nicely be caught by CI.
2025-07-21 21:15:10 +02:00
dramforever
984615b18a buildLinux: configEnv: Fix for cross
The dependencies pkg-config and ncurses are for building tools to use on
build, so they should be depsBuildBuild.

This fixes "make $makeFlags nconfig" for cross.
2025-06-21 16:01:15 +08:00
eljamm
d19f6eaf6f linux: add extraPassthru
Currently, kernel update scripts can't be triggered, given that
`passthru` doesn't propagate to the [final
passthru](59138c7667/pkgs/os-specific/linux/kernel/generic.nix (L300)).
This change introduces `extraPassthru` for properly propagating it.
2025-05-31 06:39:22 +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
Tim Schumacher
02333bc7d5 linux/common-config: Split Rust toolchain and kernel-based conditions
The ongoing RISC-V breakage may become version independent in the
future, move it to the correct condition before updating it with the
full list of supported architectures.

While at it, simplify the remaining rustc-specific conditions into an
`availableOn`.
2025-03-17 00:08:20 +01:00
Alyssa Ross
37789d9eaa linuxManualConfig: forbid config errors on aarch64
It's not a nice experience to wait for a kernel build, only to notice
the options you set didn't actually do anything, because Nixpkgs'
kernel configuration script just prints a warning if an option that
should have been set isn't set in the final kernel config.

Ideally, I think we'd never allow config errors, but we certainly
don't have to torelate them for aarch64, when CI for kernel changes
can ensure we don't accidentally break the build with x86-specific
options.

I've tested that configuration of all mainline kernels still works on
aarch64.
2024-12-24 12:40:46 +01:00
K900
7661b4ac55 Merge remote-tracking branch 'origin/staging-next' into staging 2024-12-19 12:47:54 +03:00
Yueh-Shun Li
dac886831c buildLinux: kernel.configEnv: comply with overrideAttrs
Override `finalAttrs.finalPackage` instead of `kernel` from the let-in
block to make configEnv behave in accordance with overrideAttrs of the
result package.

Continuation of commit f10331cf2e ("buildLinux: passthru by
<pkg>.overrideAttrs instead of lib.extendDerivation")
2024-12-18 16:37:21 +01:00
Julian Stecklina
70cc251554 linux: simplify toolchain selection
When we set CROSS_COMPILE to set the toolchain prefix, everything
works out of the box without using absolute paths everywhere. This
removes a lot of duplication from the kernel derivations.
2024-12-18 16:34:07 +01:00
Julian Stecklina
48a0850c15 linux: allow building with ld.lld
Even when building with pkgsLLVM.stdenv where ld is ld.lld and not
binutils ld, the build picks up binutils ld for linking. This prevents
features from working that require ld.lld.

The reason is that when the LD environment variable is not set, Linux
defaults to `ld` as a linker and ld is:

/nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/ld
GNU ld (GNU Binutils) 2.42

This ld comes from pkgsLLVM.buildPackages.stdenv.cc.

Fix by being more specific about which tools we want to build with.
This just extends what manual-config.nix has already done for quite a
while to avoid similar problems for other tools.

It's important to pass LD and other toolchain environment variables to
`make config` in generate-config.pl, because otherwise `make config`
will also make decisions based on the wrong toolchain.
2024-12-18 16:34:07 +01:00
jopejoe1
6034f6087e linux: change tests to attrset 2024-10-20 13:37:07 +02:00
Maximilian Bosch
d3e6c8fc75 linux: implement rustAvailable condition
* It doesn't matter if `rustc` is available, but if rustc can compile to
  the hostPlatform. So use a custom condition instead of `availableOn`.
* Explicitly exclude the combination of GCC and riscv which is known
  to be broken[1].

[1] https://lore.kernel.org/lkml/31885EDD-EF6D-4EF1-94CA-276BA7A340B7@kernel.org/T/

Co-authored-by: Alyssa Ross <hi@alyssa.is>
2024-10-12 17:08:18 +02: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
Andrew Marshall
abc759221f linux: remove unneeded and misleading passthru.isVanilla
This was added for use by ZFS, but it turned out that `pname == "linux"`
is sufficient enough and has better coverage since many of our Linux
variants do not have an existing `passthru.isX`, and instead are
identifiable by a different pname.
2024-09-09 10:24:41 -04:00
Andrew Marshall
222e62af54 linux: add passthru.isVanilla
For use by consumers that want to iterate over all Linux Kernel packages
to, e.g., find the latest “vanilla” version that matches some version
constraint. (E.g. This will soon be used by ZFS’s
latestCompatibleLinuxPackages)
2024-08-28 09:07:55 -04:00
Krzysztof Nazarewski
7c3815ab71 kernel: fix EDID firmware loading
for context:
- https://github.com/NixOS/nixpkgs/pull/279789#discussion_r1624936659
- https://github.com/NixOS/nixpkgs/pull/279789#issuecomment-2148560802
- https://github.com/NixOS/nixpkgs/pull/279789#issuecomment-2150726766
2024-07-18 16:57:18 +03:00
Philip Taron
2f3e0581ef linuxKernel: drop conditionals for versions greater Linux 4.16; that's all of them 2024-06-19 10:20:15 -07:00
Atemu
8378222004 buildLinux: allow changing the pname
Linux kernel drvs were all just "linux-x.y.z". This allows variants to
distinguish themselves in package names (i.e. "linux-libre").

Repology uses pname for matching
https://github.com/repology/repology-rules/issues/445. This should fix our
kernel variants not showing up on Repology.
2024-05-29 20:33:10 +02:00
Robert Hensing
e768d95f41 linux/generic.nix: Fix CONFIG_RUST
I thought it was module based, but it wasn't.

Fixes https://github.com/NixOS/nixpkgs/pull/306790#issuecomment-2092485576

> This has broken [...] Rust support
2024-05-03 12:44:58 +02:00
Robert Hensing
debe527772 kernel: Add NixOS evaluation test 2024-04-25 16:42:22 +02:00
Robert Hensing
3e83fe9aa5 kernel: Make lazier (fix infinite recursion) 2024-04-25 16:34:57 +02:00
Robert Hensing
74dbae8968 kernel: Test laziness of certain arguments 2024-04-25 16:33:28 +02:00
Wim de With
c41df32743 kernel/generic: fix overrides 2024-03-22 14:45:07 +01:00
K900
853e0c2992 linux/generic: make output of buildLinux overrideable again
Fixes #296448
2024-03-18 13:26:54 +03:00
K900
424d609df4 linux: uncurse arguments
Currently things like `buildLinux { inherit src version; }` fail because of
`callPackage` auto-inserting `kernelPatches`, which is both a `buildLinux`
argument and a `pkgs` toplevel attribute, with completely different semantics.

Avoid that entirely by splitting the call into two - one for arguments we want
from `callPackage`, and one for everything else.
2024-03-16 18:39:32 +03:00
Silvan Mosberger
548a86b335 Merge pull request #288154 from ShamrockLee/linux-kernel-passthru
buildLinux: Fix result derivation overriding with `passthru` via `stdenv.mkDerivation` instead of `lib.extendDerivation`
2024-02-26 20:46:43 +01:00