{
  pkgs,
  lib,
  ...
}:
with lib; {
  imports = [../.]; # Common config.

  # Configure the bootloader.
  boot = {
    # Use linux-zen kernel.
    kernelPackages = pkgs.linuxKernel.packages.linux_zen;

    # Enable systemd-boot
    loader.systemd-boot.enable = true;
    loader.efi.canTouchEfiVariables = true;

    # Enable quiet boot with splash
    plymouth.enable = true;
    consoleLogLevel = 3;
    initrd.verbose = false;
    kernelParams = [
      "quiet"
      "splash"
      "boot.shell_on_fail"
      "udev.log_priority=3"
      "rd.systemd.show_status=auto"
    ];

    # Allow emulating aarch64 to build for Raspberry Pi.
    binfmt.emulatedSystems = ["aarch64-linux"];
  };

  # Console font.
  console.font = "${pkgs.terminus_font}/share/consolefonts/ter-v20b.psf.gz";

  # Enable zram swap.
  zramSwap.enable = true;

  # Enable smart card support (for YubiKey).
  services.pcscd.enable = true;

  # Enable login manager.
  services.greetd = {
    enable = true;
    settings = {
      default_session = {
        command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time";
        user = "greeter";
      };
    };
  };

  # Enable window manager.
  programs.niri = {
    enable = true;
    package = pkgs.niri-unstable;
  };

  # Set wallpaper.
  stylix.image = ./wallpaper.jpg;

  # Desktop related services.
  programs.dconf.enable = true;
  security.polkit.enable = true;
  services.hardware.bolt.enable = true;
  services.upower.enable = true;
  services.libinput.enable = true;

  # Virtualisation.
  programs.virt-manager.enable = true;
  users.groups.libvirtd.members = ["fern"];
  virtualisation = {
    spiceUSBRedirection.enable = true;
    libvirtd = {
      enable = true;
      qemu = {
        package = pkgs.qemu_kvm;
        swtpm.enable = true;
        ovmf = {
          enable = true;
          packages = [pkgs.OVMFFull.fd];
        };
      };
    };
  };

  # Install Steam client.
  programs.steam.enable = true;

  # Enable configuration of keyboard.
  hardware.keyboard.qmk.enable = true;
  services.udev.packages = [pkgs.via];

  # Nintendo Switch udev rules.
  services.udev.extraRules = ''
    SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="3000", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", ATTRS{idProduct}=="7321", MODE="0666"
  '';

  # Enable gamemode service.
  programs.gamemode.enable = true;

  # Enable CUPS to print documents.
  services.printing = {
    enable = true;
    drivers = [pkgs.brlaser pkgs.cups-dymo]; # Brother laser printer & Dymo label printer.
  };

  services.system-config-printer.enable = true;

  # https://github.com/tailscale/tailscale/issues/4432#issuecomment-1112819111
  networking.firewall.checkReversePath = false;

  # Enable brightness control.
  hardware.brillo.enable = true;
  users.groups.video.members = ["fern"];

  # Control external monitor
  hardware.i2c.enable = true;
  services.ddccontrol.enable = true;

  # Enable sound with pipewire.
  services.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

  # Enable CPU frequency scaling management.
  services.tlp.enable = mkForce false; # enabled by nixos-hardware
  services.auto-cpufreq.enable = true;

  # Samba file sharing.
  services.samba = {
    enable = true;
    openFirewall = true;
    settings = {
      global = {
        "workgroup" = "FLOCK";
        "server string" = "muskduck";
        "netbios name" = "muskduck";
        "security" = "user";
      };
      "Music" = {
        "path" = "/home/fern/Music";
        "browseable" = "yes";
        "read only" = "yes";
        "guest ok" = "no";
      };
    };
  };

  services.samba-wsdd = {
    enable = true;
    openFirewall = true;
  };
}
