about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-03-18 14:06:22 +0100
committeraszlig <aszlig@redmoonstudios.org>2015-03-18 14:11:42 +0100
commit95ff01f8965fd3b09953c75d16c4e2e7af38aa41 (patch)
tree9b3756971fbeb06c6d86f790383e0517271b4c27 /modules
parent7fc10424d9460046c18b5649e580cf308489501b (diff)
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 <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/module-list.nix1
-rw-r--r--modules/user/aszlig/system/kernel.nix53
2 files changed, 54 insertions, 0 deletions
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"
+      ];
+    };
+  };
+}