From 95ff01f8965fd3b09953c75d16c4e2e7af38aa41 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 18 Mar 2015 14:06:22 +0100 Subject: lib: Refactor kernel configuration into a module. This means, we don't have that lib directory anymore and also we're not doing text substitution on the kernel config but instead override the original attributes. However, this needs to be refactored even further, so we can use the NixOS kernel system, which allows for certain modules to require specific kernel features. That way we can automatically create a kernel config from the list of required features and we only need to set a specific base config instead of specifying the *full* kernel config. Signed-off-by: aszlig --- modules/module-list.nix | 1 + modules/user/aszlig/system/kernel.nix | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 modules/user/aszlig/system/kernel.nix (limited to 'modules') diff --git a/modules/module-list.nix b/modules/module-list.nix index dbcb08a7..2cc3235f 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -7,4 +7,5 @@ ./user/aszlig/services/i3 ./user/aszlig/services/slim ./user/aszlig/services/vlock + ./user/aszlig/system/kernel.nix ] diff --git a/modules/user/aszlig/system/kernel.nix b/modules/user/aszlig/system/kernel.nix new file mode 100644 index 00000000..4a7ba609 --- /dev/null +++ b/modules/user/aszlig/system/kernel.nix @@ -0,0 +1,53 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.vuizvui.user.aszlig.system.kernel; + + generateKConf = exprs: let + isNumber = c: elem c ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"]; + mkValue = val: + if val == "" then "\"\"" + else if val == "y" || val == "m" || val == "n" then val + else if all isNumber (stringToCharacters val) then val + else if substring 0 2 val == "0x" then val + else "\"${val}\""; + mkConfigLine = key: val: "${key}=${mkValue val}"; + mkConf = cfg: concatStringsSep "\n" (mapAttrsToList mkConfigLine cfg); + in pkgs.writeText "generated.kconf" (mkConf exprs + "\n"); + +in { + options.vuizvui.user.aszlig.system.kernel = { + enable = mkEnableOption "aszlig's custom kernel"; + + config = mkOption { + type = types.attrsOf types.unspecified; + default = {}; + description = '' + An attribute set of configuration options to use + for building a custom kernel. + ''; + }; + }; + + config = mkIf cfg.enable { + boot = let + linuxVuizvui = pkgs.buildLinux { + inherit (pkgs.kernelSourceVuizvui) version src; + + kernelPatches = singleton pkgs.vuizvuiKernelPatches.bfqsched; + configfile = generateKConf cfg.config; + allowImportFromDerivation = true; + }; + in rec { + kernelPackages = pkgs.recurseIntoAttrs + (pkgs.linuxPackagesFor linuxVuizvui kernelPackages); + + loader.grub.devices = map (i: "/dev/disk/by-id/${i}") [ + "ata-WDC_WD10EZEX-00BN5A0_WD-WCC3F5756955" + "ata-WDC_WD10EZEX-00BN5A0_WD-WCC3F5790537" + ]; + }; + }; +} -- cgit 1.4.1