-
-
Notifications
You must be signed in to change notification settings - Fork 18k
linux: multiple outputs for kernel targets #324419
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
Draft
fpletz
wants to merge
1
commit into
NixOS:staging
Choose a base branch
from
fpletz:linux-targets-outputs
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,13 @@ in lib.makeOverridable ({ | |
| src, | ||
| # a list of { name=..., patch=..., extraConfig=...} patches | ||
| kernelPatches ? [], | ||
| # kernel image build targets like Image, bzImage, Image.gz, vmlinuz.efi | ||
| kernelTargets ? [], | ||
| # a list of install targets, e.g. : | ||
| # - uinstall for uImage, U-Boot wrapped image | ||
| # - zinstall for zImage, self-extracting images | ||
| # - install, the generic binary image | ||
| installTargets ? [], | ||
| # The kernel .config file | ||
| configfile, | ||
| # Manually specified nixexpr representing the config | ||
|
|
@@ -64,7 +71,9 @@ let | |
| # Shadow the un-defaulted parameter; don't want null. | ||
| modDirVersion = modDirVersion_; | ||
| inherit (lib) | ||
| hasAttr getAttr optional optionals optionalString optionalAttrs maintainers platforms; | ||
| hasAttr getAttr optional optionals optionalString optionalAttrs genAttrs replaceStrings maintainers platforms; | ||
|
|
||
| targetsToOutput = genAttrs kernelTargets (target: replaceStrings ["."] ["-"] target); | ||
|
|
||
| drvAttrs = config_: kernelConf: kernelPatches: configfile: | ||
| let | ||
|
|
@@ -128,10 +137,10 @@ let | |
| ++ optionals withRust [ rustc rust-bindgen ] | ||
| ; | ||
|
|
||
| in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // { | ||
| in (optionalAttrs isModular { outputs = [ "out" "dev" ] ++ (lib.attrValues targetsToOutput); }) // { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would end up wanting to have outputs even if the kernel wasn't built with module support. |
||
| passthru = rec { | ||
| inherit version modDirVersion config kernelPatches configfile | ||
| moduleBuildDependencies stdenv; | ||
| moduleBuildDependencies stdenv targetsToOutput; | ||
| inherit isZen isHardened isLibre withRust; | ||
| isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true; | ||
| baseVersion = lib.head (lib.splitString "-rc" version); | ||
|
|
@@ -242,7 +251,7 @@ let | |
|
|
||
| buildFlags = [ | ||
| "KBUILD_BUILD_VERSION=1-NixOS" | ||
| kernelConf.target | ||
| ] ++ kernelTargets ++ [ | ||
| "vmlinux" # for "perf" and things like that | ||
| ] ++ optional isModular "modules" | ||
| ++ optionals buildDTBs ["dtbs" "DTC_FLAGS=-@"] | ||
|
|
@@ -309,15 +318,14 @@ let | |
| export HOME=${installkernel} | ||
| ''; | ||
|
|
||
| # Some image types need special install targets (e.g. uImage is installed with make uinstall on arm) | ||
| installTargets = [ | ||
| (kernelConf.installTarget or ( | ||
| /**/ if kernelConf.target == "uImage" && stdenv.hostPlatform.linuxArch == "arm" then "uinstall" | ||
| else if kernelConf.target == "zImage" || kernelConf.target == "Image.gz" || kernelConf.target == "vmlinuz.efi" then "zinstall" | ||
| else "install")) | ||
| ]; | ||
| # Some image types need special install targets (e.g. uImage is installed with make uinstall) | ||
| installTargets = if installTargets == [ ] then [ "install" ] else installTargets; | ||
|
|
||
| postInstall = optionalString isModular '' | ||
| postInstall = (lib.concatStringsSep "\n" (lib.mapAttrsToList (target: output: '' | ||
| mkdir -p "''${${output}}" | ||
| moveToOutput "${target}" "''${${output}}" | ||
| ln -sf "''${${output}}/${target}" "$out/${target}" | ||
| '') targetsToOutput)) + (optionalString isModular '' | ||
| mkdir -p $dev | ||
| cp vmlinux $dev/ | ||
| if [ -z "''${dontStrip-}" ]; then | ||
|
|
@@ -387,7 +395,7 @@ let | |
|
|
||
| # Delete empty directories | ||
| find -empty -type d -delete | ||
| ''; | ||
| ''); | ||
|
|
||
| requiredSystemFeatures = [ "big-parallel" ]; | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how valuable it is to have a separate argument for
installTargets, as I can't imagine a scenario where thekernelTargetspassed wouldn't be directly correlated toinstallTargets. My understanding is the linux makefiles accept the kernel image targets as make targets already (e.g.make bzImageworks directly, so something likemake Image vmlinuz.efishould work as well)