nixpkgs/pkgs/os-specific/linux/kernel/mainline.nix
Eelco Dolstra 8d2a765adf Let-float various fromJSON calls to avoid repeated JSON reading/parsing
Some of these were read/parsed dozens of times in a `nix search`
invocation, and in particular the MELPA recipes archive (3 MiB) was
read 4 times.
2024-06-03 18:52:42 +02:00

31 lines
860 B
Nix

let
allKernels = builtins.fromJSON (builtins.readFile ./kernels-org.json);
in
{ branch, lib, fetchurl, fetchzip, buildLinux, ... } @ args:
let
thisKernel = allKernels.${branch};
inherit (thisKernel) version;
src =
# testing kernels are a special case because they don't have tarballs on the CDN
if branch == "testing"
then fetchzip {
url = "https://git.kernel.org/torvalds/t/linux-${version}.tar.gz";
inherit (thisKernel) hash;
}
else fetchurl {
url = "mirror://kernel/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz";
inherit (thisKernel) hash;
};
args' = (builtins.removeAttrs args ["branch"]) // {
inherit src version;
modDirVersion = lib.versions.pad 3 version;
extraMeta.branch = branch;
} // (args.argsOverride or {});
in
buildLinux args'