From 3113d052a798486743cbaf0dcd98146221e71129 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Mon, 13 Mar 2017 23:53:23 +0100 Subject: [PATCH] update linux-nvme, downgrade kernel to 4.9 (but add builds for >4.8) --- conf | 4 ++++ logical/jarvis.nix | 6 +++++- modules/linux-nvme.nix | 38 +++++++++++++++++++++++++------------- physical/xps9360.nix | 23 +++++++++++++++++++++-- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/conf b/conf index bf3069b..de65c0a 100755 --- a/conf +++ b/conf @@ -7,6 +7,10 @@ then fi export NIX_PATH="ssh-id-file=`pwd`/deploy_key":secrets=`pwd`/secrets.nix case $1 in +git) + export NIX_PATH="nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz:nixos-config=`pwd`/logical/$2.nix:$NIX_PATH" + eval ${@:3} + ;; stable) export NIX_PATH="nixpkgs=https://nixos.org/channels/nixos-16.09/nixexprs.tar.xz:nixos-config=`pwd`/logical/$2.nix:$NIX_PATH" eval ${@:3} diff --git a/logical/jarvis.nix b/logical/jarvis.nix index 40d6f5e..a167497 100644 --- a/logical/jarvis.nix +++ b/logical/jarvis.nix @@ -23,5 +23,9 @@ ${pkgs.xorg.xrandr}/bin/xrandr --dpi 192 ''; nix.gc.automatic = pkgs.lib.mkOverride 30 false; - + # nix.trustedBinaryCaches = [http://192.168.1.27:5000]; + # nix.binaryCachePublicKeys = [ + # "hydra.example.org-1:NbZfmBIhIevVM5OZ81TbwruSC9etkIrdi1mR6AAdm98=" + # ]; + virtualisation.virtualbox.host.enable = pkgs.lib.mkOverride 30 false; } diff --git a/modules/linux-nvme.nix b/modules/linux-nvme.nix index 5f7962a..e32626a 100644 --- a/modules/linux-nvme.nix +++ b/modules/linux-nvme.nix @@ -1,27 +1,39 @@ { config, lib, pkgs, ... }: # check if it's working: # nix-shell -p nvme-cli --command "sudo nvme get-feature -f 0x0c -H /dev/nvme0" | grep Enable -{ boot = rec { +let +cfg = config.linux_nvme; +inherit (lib) mkIf mkOption mkEnableOption; +in +{ + options.linux_nvme = { + basekpkgs = mkOption { default = pkgs.linuxPackages_latest; }; + gofaster = mkEnableOption "enable parallel building on kernel"; + nvmepatch = mkEnableOption "enable nvme patch"; + }; + config.boot = rec { # gotta go faster - kernelPackages = pkgs.linuxPackages_latest // { - kernel = pkgs.linuxPackages_latest.kernel.overrideDerivation (attr: { + kernelPackages = mkIf cfg.gofaster (cfg.basekpkgs // { + kernel = cfg.basekpkgs.kernel.overrideDerivation (attr: { enableParallelBuilding = true; }); - }; + }); - kernelPatches = let - kver = kernelPackages.kernel.version; - kernel_newer_4_9 = builtins.compareVersions kver "4.9" > -1; + kernelPatches = mkIf cfg.nvmepatch (let + newerThan = v: builtins.compareVersions config.boot.kernelPackages.kernel.version v > -1; # https://github.com/damige/linux-nvme/ linux-nvme = pkgs.fetchFromGitHub { owner = "damige"; repo = "linux-nvme"; - rev = "49204bb12ca0797e17d70f21bb947a99eaeebbfa"; - sha256 = "1bybrr0j7n81vhf3g36cm8sfmax0kp0b3xndlbcr5im9zrlkvwkj"; + rev = "4e9b1de7ad5386f6c8c208d81005a77d79460d26"; + sha256 = "151pnv1gjrcmlvw8bx0ndpvn254jjy394h8yr3sgh2gqbc5i1aqp"; }; - in map (name: { patch = "${linux-nvme}/src/${kver}/${name}.patch"; inherit name; }) - (if kernel_newer_4_9 - then ["APST" "pm_qos1" "pm_qos2" "pm_qos3" "nvme"] - else ["nvmepatch1-V4" "nvmepatch2-V4" "nvmepatch3-V4"]); + mkpatches = dir: map (name: { patch = "${linux-nvme}/patches/${dir}/${name}.patch"; inherit name; }); + in + if newerThan "4.11" then [] else + if newerThan "4.10" then (mkpatches "4.10.x" ["APST"]) else + if newerThan "4.9" then (mkpatches "4.9.x" ["APST" "pm_qos1" "pm_qos2" "pm_qos3" "nvme"]) else + if newerThan "4.8" then (mkpatches "4.8.x" ["nvmepatch1-V4" "nvmepatch2-V4" "nvmepatch3-V4"]) else + throw "unknown kernel version"); }; } diff --git a/physical/xps9360.nix b/physical/xps9360.nix index eec78b4..84de475 100644 --- a/physical/xps9360.nix +++ b/physical/xps9360.nix @@ -12,8 +12,24 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; boot.blacklistedKernelModules = ["psmouse"]; - + linux_nvme = { + basekpkgs = pkgs.linuxPackages_4_9; + gofaster = true; + nvmepatch = true; + }; + # boot.kernelPackages = pkgs.linuxPackagesFor ((pkgs.linux_testing.override { + # argsOverride = { + # version = "4.11.0-drm"; + # modDirVersion = "4.11.0-rc1"; + # src = pkgs.fetchgit { + # url = "git://anongit.freedesktop.org/drm-intel"; + # rev = "1d1c80ec6d4d6ac72aa80920d5290776f3c81a86"; + # sha256 = "1879cgzag8072rp99prhm3nqaf90z63j74p7si931bvz4qj4z7s0"; + # }; + # }; + # }).overrideDerivation (attr: {enableParallelBuilding = true;})); + # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; @@ -27,7 +43,10 @@ networking.wireless.enable = true; hardware.bluetooth.enable = true; - boot.kernelParams = ["i915.enable_fbc=1"]; # "i915.enable_psr=1"]; # lvds downclock is no longer a thing + # https://wiki.archlinux.org/index.php/Dell_XPS_13_(9360)#Module-based_Powersaving_Options + # might require linux 4.11 + boot.kernelParams = ["i915.enable_fbc=1" "i915.enable_guc_loading=1" "i915.enable_guc_submission=1" "i915.enable_huc=1" "i915.enable_psr=2"]; + # now we wait until enable_psr=1 is fixed fileSystems."/" = { device = "/dev/disk/by-uuid/a751e4ea-f1aa-48e1-9cbe-423878e29b62";