about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
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"
+      ];
+    };
+  };
+}