summary refs log tree commit diff
path: root/nixos/modules/testing/minimal-kernel.nix
blob: 7c2b9c05cf9a047e01165270e16c5b222b5c0b6b (plain) (blame)
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
{ config, pkgs, lib, ... }:

let
  configfile = builtins.storePath (builtins.toFile "config" (lib.concatStringsSep "\n"
    (map (builtins.getAttr "configLine") config.system.requiredKernelConfig))
  );

  origKernel = pkgs.buildLinux {
    inherit (pkgs.linux) src version stdenv;
    inherit configfile;
    allowImportFromDerivation = true;
    kernelPatches = [ pkgs.kernelPatches.cifs_timeout_2_6_38 ];
  };

  kernel = origKernel // (derivation (origKernel.drvAttrs // {
    configurePhase = ''
      runHook preConfigure
      mkdir ../build
      make $makeFlags "''${makeFlagsArray[@]}" mrproper
      make $makeFlags "''${makeFlagsArray[@]}" KCONFIG_ALLCONFIG=${configfile} allnoconfig
      runHook postConfigure
    '';
  }));

   kernelPackages = pkgs.linuxPackagesFor kernel;
in {
  boot.kernelPackages = kernelPackages;
}