Skip to content

Commit d7dfd13

Browse files
bors[bot]mexisme
andauthored
Merge NixOS#510
510: Config settings for Dell XPS 13 / 9300 r=Mic92 a=mexisme Co-authored-by: mexisme <[email protected]>
2 parents e2f9c6f + ed291da commit d7dfd13

File tree

6 files changed

+137
-0
lines changed

6 files changed

+137
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ See code for all available configurations.
9898
| [Dell Poweredge R7515](dell/poweredge/r7515) | `<nixos-hardware/dell/poweredge/r7515>` |
9999
| [Dell Precision 5530](dell/precision/5530) | `<nixos-hardware/dell/precision/5530>` |
100100
| [Dell XPS 13 7390](dell/xps/13-7390) | `<nixos-hardware/dell/xps/13-7390>` |
101+
| [Dell XPS 13 9300](dell/xps/13-9300) | `<nixos-hardware/dell/xps/13-9300>` |
101102
| [Dell XPS 13 9310](dell/xps/13-9310) | `<nixos-hardware/dell/xps/13-9310>` |
102103
| [Dell XPS 13 9343](dell/xps/13-9343) | `<nixos-hardware/dell/xps/13-9343>` |
103104
| [Dell XPS 13 9350](dell/xps/13-9350) | `<nixos-hardware/dell/xps/13-9350>` |

dell/xps/13-9300/README.wiki

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
= Dell XPS 13 9300 =
2+
3+
== Firmware upgrades ==
4+
5+
Note that this device is supported by [https://fwupd.org/ fwupd].
6+
To perform firmware upgrades just activate the service
7+
8+
<code>
9+
services.fwupd.enable = true;
10+
</code>
11+
12+
Then use <code>fwupdmgr</code> to perform updates.
13+
14+
== Battery drain when sleeping ==
15+
16+
The laptop uses the S2 sleep mode by default instead of S3, which leads to
17+
draining a lot of battery during sleep.
18+
19+
See https://wiki.archlinux.org/index.php/Dell_XPS_13_(9300)#Power_Management
20+
and https://bugzilla.kernel.org/show_bug.cgi?id=199689#c3 for reference

dell/xps/13-9300/default.nix

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{ config, lib, ... }:
2+
3+
let
4+
inherit (lib) mkDefault;
5+
6+
in {
7+
imports = [
8+
../../../common/cpu/intel
9+
../../../common/gpu/intel.nix
10+
../../../common/pc/laptop
11+
../../../common/pc/laptop/acpi_call.nix
12+
../../../common/pc/ssd
13+
../sleep-resume/i2c-designware
14+
];
15+
16+
# Force S3 sleep mode. See README.wiki for details.
17+
boot.kernelParams = [ "mem_sleep_default=deep" ];
18+
19+
# Touchpad goes over i2c, and the psmouse module interferes with it
20+
boot.blacklistedKernelModules = [ "psmouse" ];
21+
22+
# Includes the Wi-Fi and Bluetooth firmware for the QCA6390.
23+
hardware.enableRedistributableFirmware = mkDefault true;
24+
25+
# Allows for updating firmware via `fwupdmgr`.
26+
services.fwupd.enable = mkDefault true;
27+
28+
# This will save you money and possibly your life!
29+
services.thermald.enable = mkDefault true;
30+
31+
# Reloads i2c-designware module after suspend
32+
services.sleep-resume.i2c-designware.enable = mkDefault true;
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{config, lib, pkgs, ...}:
2+
3+
let
4+
inherit (lib) mkIf mkOption types;
5+
6+
reloadBtusb = pkgs.writeShellApplication {
7+
name = "reload-btusb.sh";
8+
runtimeInputs = [
9+
pkgs.coreutils
10+
pkgs.kmod
11+
];
12+
text = ''
13+
# Reload Bluetooth after resuming from sleep.
14+
15+
# Wait up-to 0.5 second for the module to be unloaded:
16+
# (It should never take this long)
17+
modprobe -r --wait 500 btusb
18+
19+
# "btusb" sometimes seems to need a little bit of time to settle after unloading:
20+
sleep 0.2
21+
modprobe btusb
22+
'';
23+
};
24+
25+
cfg = config.services.sleep-resume.bluetooth;
26+
in {
27+
options = {
28+
services.sleep-resume.bluetooth = {
29+
enable = mkOption {
30+
default = false;
31+
type = types.bool;
32+
description = "Reload Bluetooth after resuming from sleep";
33+
};
34+
};
35+
};
36+
37+
config = mkIf cfg.enable {
38+
powerManagement.resumeCommands = "${reloadBtusb}/bin/reload-btusb.sh";
39+
};
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{ config, lib, pkgs, ... }:
2+
3+
let
4+
inherit (lib) mkIf mkOption types;
5+
6+
reloadDesignware = pkgs.writeShellApplication {
7+
name = "reload-i2c-designware.sh";
8+
runtimeInputs = [ pkgs.kmod ];
9+
text = ''
10+
# Reload the i2c Designware driver after resuming from sleep.
11+
12+
# Wait up-to 0.5 second for each module to be unloaded:
13+
# (It should never take this long)
14+
modprobe -r --wait 500 i2c_designware_platform
15+
modprobe -r --wait 500 i2c_designware_core
16+
modprobe -r --wait 500 i2c_hid_acpi
17+
modprobe -r --wait 500 i2c_hid
18+
19+
# Should reload the module dependencies automatically:
20+
modprobe i2c_designware_platform
21+
'';
22+
};
23+
24+
cfg = config.services.sleep-resume.i2c-designware;
25+
in {
26+
options = {
27+
services.sleep-resume.i2c-designware = {
28+
enable = mkOption {
29+
default = false;
30+
type = types.bool;
31+
description = "Reload the i2c_designware driver after resuming from sleep.";
32+
};
33+
};
34+
};
35+
36+
config = mkIf cfg.enable {
37+
powerManagement.resumeCommands = "${reloadDesignware}/bin/reload-i2c-designware.sh";
38+
};
39+
}
40+
41+
42+

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
dell-poweredge-r7515 = import ./dell/poweredge/r7515;
3434
dell-precision-5530 = import ./dell/precision/5530;
3535
dell-xps-13-7390 = import ./dell/xps/13-7390;
36+
dell-xps-13-9300 = import ./dell/xps/13-9300;
3637
dell-xps-13-9310 = import ./dell/xps/13-9310;
3738
dell-xps-13-9343 = import ./dell/xps/13-9343;
3839
dell-xps-13-9350 = import ./dell/xps/13-9350;

0 commit comments

Comments
 (0)