Merge pull request #25 from shlevy/required-kernel-config
Required kernel config
This commit is contained in:
commit
21da462ad5
|
@ -1,4 +1,4 @@
|
||||||
{ system }:
|
{ system, minimal ? false }:
|
||||||
|
|
||||||
let pkgs = import <nixpkgs> { config = {}; inherit system; }; in
|
let pkgs = import <nixpkgs> { config = {}; inherit system; }; in
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ rec {
|
||||||
[ ../modules/virtualisation/qemu-vm.nix
|
[ ../modules/virtualisation/qemu-vm.nix
|
||||||
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
|
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
|
||||||
{ key = "no-manual"; services.nixosManual.enable = false; }
|
{ key = "no-manual"; services.nixosManual.enable = false; }
|
||||||
];
|
] ++ lib.optional minimal ../modules/testing/minimal-kernel.nix;
|
||||||
extraArgs = { inherit nodes; };
|
extraArgs = { inherit nodes; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ system }:
|
{ system, minimal ? false }:
|
||||||
|
|
||||||
with import ./build-vms.nix { inherit system; };
|
with import ./build-vms.nix { inherit system minimal; };
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
|
@ -73,4 +73,10 @@ with pkgs.lib;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config = mkIf ((length config.swapDevices) != 0) {
|
||||||
|
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||||
|
(isYes "SWAP")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,6 +263,11 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||||
|
(isEnabled "UNIX")
|
||||||
|
(isYes "INOTIFY_USER")
|
||||||
|
(isYes "NET")
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,24 @@ let kernel = config.boot.kernelPackages.kernel; in
|
||||||
apply = pkgs.aggregateModules;
|
apply = pkgs.aggregateModules;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.requiredKernelConfig = mkOption {
|
||||||
|
default = [];
|
||||||
|
example = literalExample ''
|
||||||
|
with config.lib.kernelConfig; [
|
||||||
|
(isYes "MODULES")
|
||||||
|
(isEnabled "FB_CON_DECOR")
|
||||||
|
(isEnabled "BLK_DEV_INITRD")
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
internal = true;
|
||||||
|
type = types.listOf types.attrs;
|
||||||
|
description = ''
|
||||||
|
This option allows modules to specify the kernel config options that
|
||||||
|
must be set (or unset) for the module to work. Please use the
|
||||||
|
lib.kernelConfig functions to build list elements.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,6 +191,53 @@ let kernel = config.boot.kernelPackages.kernel; in
|
||||||
# The Linux kernel >= 2.6.27 provides firmware.
|
# The Linux kernel >= 2.6.27 provides firmware.
|
||||||
hardware.firmware = [ "${kernel}/lib/firmware" ];
|
hardware.firmware = [ "${kernel}/lib/firmware" ];
|
||||||
|
|
||||||
};
|
lib.kernelConfig = {
|
||||||
|
isYes = option: {
|
||||||
|
assertion = config: config.isYes option;
|
||||||
|
message = "CONFIG_${option} is not yes!";
|
||||||
|
configLine = "CONFIG_${option}=y";
|
||||||
|
};
|
||||||
|
|
||||||
|
isNo = option: {
|
||||||
|
assertion = config: config.isNo option;
|
||||||
|
message = "CONFIG_${option} is not no!";
|
||||||
|
configLine = "CONFIG_${option}=n";
|
||||||
|
};
|
||||||
|
|
||||||
|
isModule = option: {
|
||||||
|
assertion = config: config.isModule option;
|
||||||
|
message = "CONFIG_${option} is not built as a module!";
|
||||||
|
configLine = "CONFIG_${option}=m";
|
||||||
|
};
|
||||||
|
|
||||||
|
### Usually you will just want to use these two
|
||||||
|
# True if yes or module
|
||||||
|
isEnabled = option: {
|
||||||
|
assertion = config: config.isEnabled option;
|
||||||
|
message = "CONFIG_${option} is not enabled!";
|
||||||
|
configLine = "CONFIG_${option}=y";
|
||||||
|
};
|
||||||
|
|
||||||
|
# True if no or omitted
|
||||||
|
isDisabled = option: {
|
||||||
|
assertion = config: config.isDisabled option;
|
||||||
|
message = "CONFIG_${option} is not disabled!";
|
||||||
|
configLine = "CONFIG_${option}=n";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# The config options that all modules can depend upon
|
||||||
|
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||||
|
# !!! Should this really be needed?
|
||||||
|
(isYes "MODULES")
|
||||||
|
(isYes "BINFMT_ELF")
|
||||||
|
];
|
||||||
|
|
||||||
|
# nixpkgs kernels are assumed to have all required features
|
||||||
|
assertions = if config.boot.kernelPackages.kernel ? features then [] else
|
||||||
|
let cfg = config.boot.kernelPackages.kernel.config; in map (attrs:
|
||||||
|
{ assertion = attrs.assertion cfg; inherit (attrs) message; }
|
||||||
|
) config.system.requiredKernelConfig;
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,4 +321,8 @@ in {
|
||||||
system.build.initialRamdisk = initialRamdisk;
|
system.build.initialRamdisk = initialRamdisk;
|
||||||
system.build.extraUtils = extraUtils;
|
system.build.extraUtils = extraUtils;
|
||||||
|
|
||||||
|
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||||
|
(isYes "TMPFS")
|
||||||
|
(isYes "BLK_DEV_INITRD")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
configfile = builtins.storePath (builtins.toFile "config" (pkgs.lib.concatStringsSep "\n"
|
||||||
|
(map (builtins.getAttr "configLine") config.system.requiredKernelConfig))
|
||||||
|
);
|
||||||
|
|
||||||
|
origKernel = pkgs.linuxManualConfig {
|
||||||
|
inherit (pkgs.linux) src version;
|
||||||
|
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 kernelPackages;
|
||||||
|
in {
|
||||||
|
boot.kernelPackages = kernelPackages;
|
||||||
|
}
|
|
@ -5,11 +5,18 @@
|
||||||
|
|
||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
kernel = config.boot.kernelPackages.kernel;
|
||||||
|
|
||||||
|
hasCIFSTimeout = if kernel ? features then kernel.features ? cifsTimeout
|
||||||
|
else (filter (p: p.name == "cifs-timeout") kernel.kernelPatches) != [];
|
||||||
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
config =
|
config =
|
||||||
# Require a patch to the kernel to increase the 15s CIFS timeout.
|
# Require a patch to the kernel to increase the 15s CIFS timeout.
|
||||||
mkAssert (config.boot.kernelPackages.kernel.features ? cifsTimeout) "
|
mkAssert hasCIFSTimeout "
|
||||||
VM tests require that the kernel has the CIFS timeout patch.
|
VM tests require that the kernel has the CIFS timeout patch.
|
||||||
" {
|
" {
|
||||||
|
|
||||||
|
@ -87,6 +94,11 @@ with pkgs.lib;
|
||||||
|
|
||||||
system.upstartEnvironment.GCOV_PREFIX = "/tmp/xchg/coverage-data";
|
system.upstartEnvironment.GCOV_PREFIX = "/tmp/xchg/coverage-data";
|
||||||
|
|
||||||
|
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||||
|
(isYes "SERIAL_8250_CONSOLE")
|
||||||
|
(isYes "SERIAL_8250")
|
||||||
|
(isEnabled "VIRTIO_CONSOLE")
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,4 +385,22 @@ in
|
||||||
|
|
||||||
# Wireless won't work in the VM.
|
# Wireless won't work in the VM.
|
||||||
networking.wireless.enable = mkOverride 50 false;
|
networking.wireless.enable = mkOverride 50 false;
|
||||||
|
|
||||||
|
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||||
|
(isEnabled "VIRTIO_BLK")
|
||||||
|
(isEnabled "VIRTIO_PCI")
|
||||||
|
(isEnabled "VIRTIO_NET")
|
||||||
|
(isEnabled "EXT3_FS")
|
||||||
|
(isEnabled "CIFS")
|
||||||
|
(isYes "BLK_DEV")
|
||||||
|
(isYes "PCI")
|
||||||
|
(isYes "EXPERIMENTAL")
|
||||||
|
(isYes "NETDEVICES")
|
||||||
|
(isYes "NET_CORE")
|
||||||
|
(isYes "INET")
|
||||||
|
(isYes "NETWORK_FILESYSTEMS")
|
||||||
|
] ++ optional (!cfg.graphics) [
|
||||||
|
(isYes "SERIAL_8250_CONSOLE")
|
||||||
|
(isYes "SERIAL_8250")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ nixosSrc ? {outPath = ./.; revCount = 1234; shortRev = "abcdef"; }
|
{ nixosSrc ? {outPath = ./.; revCount = 1234; shortRev = "abcdef"; }
|
||||||
, nixpkgs ? {outPath = <nixpkgs>; revCount = 5678; shortRev = "fedcba"; }
|
, nixpkgs ? {outPath = <nixpkgs>; revCount = 5678; shortRev = "fedcba"; }
|
||||||
|
, minimal ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -194,8 +195,8 @@ let
|
||||||
|
|
||||||
tests =
|
tests =
|
||||||
let
|
let
|
||||||
t = import ./tests { system = "i686-linux"; };
|
t = import ./tests { system = "i686-linux"; inherit minimal; };
|
||||||
t_64 = import ./tests { system = "x86_64-linux"; };
|
t_64 = import ./tests { system = "x86_64-linux"; inherit minimal; };
|
||||||
in {
|
in {
|
||||||
avahi = t.avahi.test;
|
avahi = t.avahi.test;
|
||||||
bittorrent = t.bittorrent.test;
|
bittorrent = t.bittorrent.test;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ system ? builtins.currentSystem }:
|
{ system ? builtins.currentSystem, minimal ? false }:
|
||||||
|
|
||||||
with import ../lib/testing.nix { inherit system; };
|
with import ../lib/testing.nix { inherit system minimal; };
|
||||||
|
|
||||||
{
|
{
|
||||||
avahi = makeTest (import ./avahi.nix);
|
avahi = makeTest (import ./avahi.nix);
|
||||||
|
|
Loading…
Reference in New Issue