summaryrefslogtreecommitdiffstats
path: root/pkgs/os-specific/linux/kernel/mainline.nix
blob: 0ba9f47e542ada3c41a2ee3d03fc178107709c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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' =
    (removeAttrs args [ "branch" ])
    // {
      inherit src version;
      isLTS = thisKernel.lts;

      modDirVersion = lib.versions.pad 3 version;
      extraMeta.branch = branch;
    }
    // (args.argsOverride or { });
in
buildLinux args'