374e6bcc40
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](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/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.
41 lines
919 B
Nix
41 lines
919 B
Nix
{
|
|
stdenvNoCC,
|
|
kmod,
|
|
modules,
|
|
buildEnv,
|
|
name ? "kernel-modules",
|
|
}:
|
|
|
|
buildEnv {
|
|
inherit name;
|
|
|
|
paths = modules;
|
|
|
|
postBuild = ''
|
|
source ${stdenvNoCC}/setup
|
|
|
|
if ! test -d "$out/lib/modules"; then
|
|
echo "No modules found."
|
|
# To support a kernel without modules
|
|
exit 0
|
|
fi
|
|
|
|
kernelVersion=$(cd $out/lib/modules && ls -d *)
|
|
if test "$(echo $kernelVersion | wc -w)" != 1; then
|
|
echo "inconsistent kernel versions: $kernelVersion"
|
|
exit 1
|
|
fi
|
|
|
|
echo "kernel version is $kernelVersion"
|
|
|
|
shopt -s extglob
|
|
|
|
# Regenerate the depmod map files. Be sure to pass an explicit
|
|
# kernel version number, otherwise depmod will use `uname -r'.
|
|
if test -w $out/lib/modules/$kernelVersion; then
|
|
rm -f $out/lib/modules/$kernelVersion/modules.!(builtin*|order*)
|
|
${kmod}/bin/depmod -b $out -C $out/etc/depmod.d -a $kernelVersion
|
|
fi
|
|
'';
|
|
}
|