/home/jtanguy/blog

Installing NixOS on a XPS 9560

Julien Tanguy, . Tagged

I recently bought a XPS 9650 from Dell, and I am enjoying it so far. This laptop is an early 2017 model, so documentation for installing NixOS on it was scarce.

With the help of some posts, I managed to install NixOS on it. Here is the general config with some tips along the way.

Update: Domen Kožar pointed me out on Twitter to another config, with a more elaborate setup with LUKS and such : https://gist.github.com/grahamc/fba67370053acc01ac216a6e4b73d308

I know that my config is not perfect and can be improved upon, but it is fine for me atm.

Initial setup

I decided not to wipe out the preinstalled Windows 10, so I decided to shrink the main partition as much as I could.

After backing up windows on a live key and making sure that all drivers but Nvidia were up to date, I went into the BIOS for some configuration:

  1. Disable Secure Boot. I don’t think it’s possible to install NixOS with it.
  2. Change the SSD controller from RAID to AHCI. This breaks the existing windows install; I looked for a way to install an AHCI driver for windows, with no luck yet.

Update: I just stumbled upon a reddit post which lists exactly the steps needed to make Windows install the AHCI drivers automatically. Here is the updated procedure I followed:

  1. In the windows admin command prompt, run bcdedit /set {current} safeboot minimal
  2. Reboot and go into the BIOS configuration
  3. Disable Secure Boot
  4. Change the SSD controller to AHCI
  5. Reboot. Windows will boot into safe mode
  6. In the windows admin command prompt, run bcdedit /deletevalue {current} safeboot
  7. Reboot. Windows will reconfigure itself for AHCI.

Then it was time for the setup.

Network

The NixOS liveUSB I used at the time didn’t have the drivers I needed for my Wifi card. I borrowed a USB-C to Ethernet adapter from a friend and kept on going.

Graphics

This one gave me some troubles. First, I blacklisted nouveau kernel modules, just for precaution, and configured bumblebee, but my machine froze every time I tried to start the X server.

Apparently, if you turn off or on the nvidia graphics card, the system hard freezes. I chose to use the non-free Nvidia drivers coupled with bumblebee, with the hardware.bumblebee.pmMethod option set to none (it requires switching on the nixos-unstable channel first).

I am aware that this setup is not the most battery-efficient one, but given the amount of documentation at the time and given that it works well enough, I decided not to try to improve it.

Bluetooth

I did not investigate too much into bluetooth, but I might try again some day.

Fingerprint reader

My model was shipped with a fingerprint reader, but at the time of this writing, it is still not supported by fprintd.

It’s useful to separate purely work-related stuff from the rest, this way you can share your config with your colleagues and it makes the cleanup easier.

TL;DR

Here is the full configuration

{ config, pkgs, ... }:
{
  imports = [
      ./hardware-configuration.nix # Hardware scan
      ./valwin/configuration.nix   # Work-related stuff
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.blacklistedKernelModules = [ "nouveau" "bbswitch" ];

  # Nvidia is hard
  nixpkgs.config.allowUnfree = true;
  hardware.bumblebee.enable = true;
  hardware.bumblebee.pmMethod = "none"; # Needs nixos-unstable
  boot.extraModulePackages = [ pkgs.linuxPackages.nvidia_x11 ];

  hardware.pulseaudio.enable = true;
  hardware.pulseaudio.package = pkgs.pulseaudioFull;
  hardware.bluetooth.enable = true;

  networking.hostName = "mayoi"; # Define your hostname.
  networking.networkmanager.enable = true;

  fonts = {
    enableFontDir = true;
    enableGhostscriptFonts = true;
    fonts = with pkgs; [ source-code-pro ];
  };

  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = "fr";
    defaultLocale = "en_US.UTF-8";
  };

  time.timeZone = "Europe/Paris";

  environment.systemPackages = with pkgs; [
    wget git dmenu feh i3 i3lock i3status fontconfig-ultimate
    networkmanagerapplet openssl htop pasystray xorg.xbacklight
    source-code-pro vim
  ];

  services.xserver.enable = true;
  services.xserver.layout = "fr";
  services.xserver.xkbOptions = "eurosign:e";

  services.xserver.libinput.enable = true;
  services.xserver.videoDrivers = [ "intel" ];

  services.xserver.windowManager.i3 = {
    enable = true;
    extraSessionCommands = ''
      ${pkgs.feh}/bin/feh  --bg-scale $HOME/.local/share/background-image
      ${pkgs.pasystray}/bin/pasystray &
      ${pkgs.networkmanagerapplet}/bin/nm-applet &
    '';
  };

  services.fprintd.enable = true;

  services.xserver.synaptics.palmDetect = true;
  services.xserver.multitouch.ignorePalm = true;

  services.redshift = {
    enable = true;
    latitude = "47.218371";
    longitude = "-1.553621";
  };

  users.extraUsers.jtanguy = {
    isNormalUser = true;
    group = "users";
    extraGroups = [ "wheel" "networkmanager" ];
    home = "/home/jtanguy";
    createHome = true;
    uid = 1000;
  };

  # The NixOS release to be compatible with for stateful data such as databases.
  system.stateVersion = "16.09";

}