about summary refs log tree commit diff
path: root/modules/nixos-hardware/apple
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 16:23:40 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 16:24:02 +0000
commit8c0790eb6095ef59a9623596f5794d250b95c699 (patch)
tree4801e46054b433e786e15d030b6cab991d8a6724 /modules/nixos-hardware/apple
parent36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (diff)
parent99cdc883064ac5a1b9e189d3500a809616e79765 (diff)
downloadnixlib-8c0790eb6095ef59a9623596f5794d250b95c699.tar
nixlib-8c0790eb6095ef59a9623596f5794d250b95c699.tar.gz
nixlib-8c0790eb6095ef59a9623596f5794d250b95c699.tar.bz2
nixlib-8c0790eb6095ef59a9623596f5794d250b95c699.tar.lz
nixlib-8c0790eb6095ef59a9623596f5794d250b95c699.tar.xz
nixlib-8c0790eb6095ef59a9623596f5794d250b95c699.tar.zst
nixlib-8c0790eb6095ef59a9623596f5794d250b95c699.zip
Add 'modules/nixos-hardware/' from commit '99cdc883064ac5a1b9e189d3500a809616e79765'
git-subtree-dir: modules/nixos-hardware
git-subtree-mainline: 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2
git-subtree-split: 99cdc883064ac5a1b9e189d3500a809616e79765
Diffstat (limited to 'modules/nixos-hardware/apple')
-rw-r--r--modules/nixos-hardware/apple/default.nix12
-rw-r--r--modules/nixos-hardware/apple/macbook-air/4/default.nix16
-rw-r--r--modules/nixos-hardware/apple/macbook-air/6/default.nix18
-rw-r--r--modules/nixos-hardware/apple/macbook-air/default.nix8
-rw-r--r--modules/nixos-hardware/apple/macbook-pro/10-1/README.wiki9
-rw-r--r--modules/nixos-hardware/apple/macbook-pro/10-1/default.nix21
-rw-r--r--modules/nixos-hardware/apple/macbook-pro/11-5/README.md32
-rw-r--r--modules/nixos-hardware/apple/macbook-pro/11-5/default.nix27
-rw-r--r--modules/nixos-hardware/apple/macbook-pro/12-1/default.nix14
-rw-r--r--modules/nixos-hardware/apple/macbook-pro/default.nix7
10 files changed, 164 insertions, 0 deletions
diff --git a/modules/nixos-hardware/apple/default.nix b/modules/nixos-hardware/apple/default.nix
new file mode 100644
index 000000000000..a2ee26230aaa
--- /dev/null
+++ b/modules/nixos-hardware/apple/default.nix
@@ -0,0 +1,12 @@
+{ config, lib, ... }:
+
+{
+  boot.kernelParams = [
+    "hid_apple.iso_layout=0"
+  ];
+
+  hardware.facetimehd.enable = lib.mkDefault
+    (config.nixpkgs.config.allowUnfree or false);
+
+  services.mbpfan.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/apple/macbook-air/4/default.nix b/modules/nixos-hardware/apple/macbook-air/4/default.nix
new file mode 100644
index 000000000000..181a099799a1
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-air/4/default.nix
@@ -0,0 +1,16 @@
+{ lib, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/cpu/intel/sandy-bridge
+  ];
+
+  boot.kernelParams = [
+    "acpi_backlight=vendor"
+  ];
+
+  services.xserver.deviceSection = lib.mkDefault ''
+    Option "TearFree" "true"
+  '';
+}
diff --git a/modules/nixos-hardware/apple/macbook-air/6/default.nix b/modules/nixos-hardware/apple/macbook-air/6/default.nix
new file mode 100644
index 000000000000..555d70418b85
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-air/6/default.nix
@@ -0,0 +1,18 @@
+{ config, lib, ... }:
+
+{
+  imports = [ ../. ];
+
+  boot = {
+    extraModulePackages = with config.boot.kernelPackages; [ mba6x_bl ];
+    kernelModules = [ "mba6x_bl" ];
+
+    # Divides power consumption by two.
+    kernelParams = [ "acpi_osi=" ];
+  };
+
+  services.xserver.deviceSection = lib.mkDefault ''
+    Option "Backlight" "mba6x_backlight"
+    Option "TearFree" "true"
+  '';
+}
diff --git a/modules/nixos-hardware/apple/macbook-air/default.nix b/modules/nixos-hardware/apple/macbook-air/default.nix
new file mode 100644
index 000000000000..ea15175d0319
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-air/default.nix
@@ -0,0 +1,8 @@
+{
+  imports = [
+    ../.
+    ../../common/cpu/intel
+    ../../common/pc/laptop
+    ../../common/pc/laptop/ssd
+  ];
+}
diff --git a/modules/nixos-hardware/apple/macbook-pro/10-1/README.wiki b/modules/nixos-hardware/apple/macbook-pro/10-1/README.wiki
new file mode 100644
index 000000000000..149b30e6ed22
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-pro/10-1/README.wiki
@@ -0,0 +1,9 @@
+= Apple MacBook Pro 10,1 =
+
+I presume the associated configuration also will work with to other 10,x models.
+
+If you don't have an Ethernet adapter, make sure your NixOS installer has a sufficiently modern kernel or you will be stuck without internet and unable to installer.
+
+Note that (with NixPkgs circa late October 2016) Linux 4.8.1 does not work: everything will boot through X, but then manually-run commands accessing peripherals (nmcli, lspci, etc) will hang inexplicably.
+
+Thankfully no tweaking of the BIOS or similar was needed. Do note that if your MacOS partition is encrypted, you will have an easier time shrinking it from within MacOS, but this is standard advice.
diff --git a/modules/nixos-hardware/apple/macbook-pro/10-1/default.nix b/modules/nixos-hardware/apple/macbook-pro/10-1/default.nix
new file mode 100644
index 000000000000..e029ef21ecac
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-pro/10-1/default.nix
@@ -0,0 +1,21 @@
+{ lib, pkgs, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/pc/laptop/ssd
+  ];
+
+  # TODO: boot loader
+  boot.loader.systemd-boot.enable = true;
+  boot.loader.efi.canTouchEfiVariables = true;
+
+  # TODO: reverse compat
+  hardware.opengl.driSupport32Bit = true;
+
+  services.xserver = {
+    # TODO: we should not enable unfree drivers
+    # when there is an alternative (i.e. nouveau)
+    videoDrivers = [ "nvidia" ];
+  };
+}
diff --git a/modules/nixos-hardware/apple/macbook-pro/11-5/README.md b/modules/nixos-hardware/apple/macbook-pro/11-5/README.md
new file mode 100644
index 000000000000..17e5ef1d36e0
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-pro/11-5/README.md
@@ -0,0 +1,32 @@
+# Apple MacBook Pro 11,5
+
+This configuration will **not** work with MacBook Pro 11,2 or 11,3 models.
+
+## Notable features
+
+* Prevent intermittent USB 3.0 controller wakeup signal when the lid is closed. Without this fix your laptop may get very hot and drain the battery after waking up in your laptop bag.
+
+  You can see for yourself which devices are allowed to wake up your laptop using the command:
+
+  ```shell
+  cat /proc/acpi/wakeup
+  ```
+
+  This fix works for Linux kernel 3.13 and above.
+
+  Sources:
+
+  * [Fix unwanted laptop resume after lid is closed](https://medium.com/@laurynas.karvelis_95228/install-arch-linux-on-macbook-pro-11-2-retina-install-guide-for-year-2017-2034ceed4cb2#66ba)
+  * [Arch wiki: MacBookPro11,x Suspend](https://wiki.archlinux.org/index.php/MacBookPro11,x#Suspend)
+  * [simonvandel/dotfiles (nix config)](https://github.com/simonvandel/dotfiles/blob/f254a4a607257faee295ce798ed215273c342850/nixos/vandel-macair/configuration.nix#L45)
+
+## Graphics
+
+The [MacBookPro11,4 and MacBookPro11,5](https://support.apple.com/kb/SP719) models ship with a discrete ATI graphics card (whereas MacBookPro11,2 and MacBookPro11,3 ship with NVidia cards). This is alongside the usual integrated Intel GPU.
+
+You may wish to look into dynamic switching between integrated and discrete graphics, but this config doesn't attempt it.
+
+## Additional resources
+
+* Arch linux wiki: [MacBookPro11,x](https://wiki.archlinux.org/index.php/MacBookPro11,x)
+* Kernel patches: [MacBookPro11,x](https://bugzilla.kernel.org/buglist.cgi?quicksearch=macbookpro11)
diff --git a/modules/nixos-hardware/apple/macbook-pro/11-5/default.nix b/modules/nixos-hardware/apple/macbook-pro/11-5/default.nix
new file mode 100644
index 000000000000..a53b5d8adeb4
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-pro/11-5/default.nix
@@ -0,0 +1,27 @@
+{ lib, config, pkgs, ... }:
+
+let
+
+  kernelPackages = config.boot.kernelPackages;
+
+in
+
+{
+  imports = [
+    ../.
+    ../../../common/pc/laptop/ssd
+    <nixpkgs/nixos/modules/hardware/network/broadcom-43xx.nix>
+  ];
+
+  # Apparently this is currently only supported by ati_unfree drivers, not ati
+  hardware.opengl.driSupport32Bit = false;
+
+  services.xserver.videoDrivers = [ "ati" ];
+
+  services.udev.extraRules =
+    # Disable XHC1 wakeup signal to avoid resume getting triggered some time
+    # after suspend. Reboot required for this to take effect.
+    lib.optionalString
+      (lib.versionAtLeast kernelPackages.kernel.version "3.13")
+      ''SUBSYSTEM=="pci", KERNEL=="0000:00:14.0", ATTR{power/wakeup}="disabled"'';
+}
diff --git a/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix b/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix
new file mode 100644
index 000000000000..02c6f328cf5a
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-pro/12-1/default.nix
@@ -0,0 +1,14 @@
+{ lib, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/pc/laptop/ssd
+    <nixpkgs/nixos/modules/hardware/network/broadcom-43xx.nix>
+  ];
+
+  # USB subsystem wakes up MBP right after suspend unless we disable it.
+  services.udev.extraRules = lib.mkDefault ''
+    SUBSYSTEM=="pci", KERNEL=="0000:00:14.0", ATTR{power/wakeup}="disabled"
+  '';
+}
diff --git a/modules/nixos-hardware/apple/macbook-pro/default.nix b/modules/nixos-hardware/apple/macbook-pro/default.nix
new file mode 100644
index 000000000000..4ced65a382e0
--- /dev/null
+++ b/modules/nixos-hardware/apple/macbook-pro/default.nix
@@ -0,0 +1,7 @@
+{
+  imports = [
+    ../.
+    ../../common/cpu/intel
+    ../../common/pc/laptop
+  ];
+}