{
  config,
  lib,
  pkgs,
  modulesPath,
  ...
}: let
  user = config.user;
in {
  imports = [
    (modulesPath + "/installer/scan/not-detected.nix")
  ];

  boot.initrd.availableKernelModules = ["xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" "sdhci_pci"];
  boot.initrd.kernelModules = ["uas" "usbcore" "usb_storage" "vfat" "nls_cp437" "nls_iso8859_1"];
  boot.kernelModules = ["kvm-intel"];
  boot.extraModulePackages = [];

  fileSystems."/" = {
    device = "/dev/disk/by-uuid/48a07e82-1090-448c-a751-3a410afba0f7";
    fsType = "btrfs";
    options = ["subvol=@" "compress=zstd" "autodefrag"];
  };

  boot.initrd.luks.devices."usbkey" = {
    device = "/dev/disk/by-label/usbkey1";
  };

  boot.initrd.luks.devices."cryptroot" = {
    device = "/dev/disk/by-uuid/570cc51f-bd5c-4bee-a18f-f6aabaf60881";
    keyFileSize = 4096;
    preOpenCommands = ''
      mkdir -m 0755 -p /key
      mount -n -o ro /dev/mapper/usbkey /key
    '';
    keyFile = "/key/keyfile";
    preLVM = false;
  };

  fileSystems."/home" = {
    device = "/dev/disk/by-uuid/48a07e82-1090-448c-a751-3a410afba0f7";
    fsType = "btrfs";
    options = ["subvol=@home" "compress=zstd" "autodefrag"];
  };

  fileSystems."/swap" = {
    device = "/dev/disk/by-uuid/48a07e82-1090-448c-a751-3a410afba0f7";
    fsType = "btrfs";
    options = ["subvol=@swap"];
  };

  fileSystems."/boot" = {
    device = "/dev/disk/by-uuid/EED9-A165";
    fsType = "vfat";
  };

  swapDevices = [{device = "/swap/swapfile";}];

  boot.plymouth.enable = true;
  boot.initrd.verbose = false;
  boot.consoleLogLevel = 1;
  boot.kernelParams = ["quiet" "udev.log_level=3"];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp53s0.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp54s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;

  hardware.graphics = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver # LIBVA_DRIVER_NAME=iHD
      vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
      vaapiVdpau
      libvdpau-va-gl
    ];
  };

  hardware.keyboard.zsa.enable = true;

  networking.hostName = "FCS-Tristan-Nixbook";

  system.stateVersion = "22.11"; # do not change
  home-manager.users.${user}.imports = [
    {
      home.stateVersion = "22.05";

      wayland.windowManager.hyprland = {
        settings = {
          bind = [
            "SUPER_SHIFT, Q, killactive,"
          ];
        };
        extraConfig = ''
          device {
            name = at-translated-set-2-keyboard
            kb_variant = dvorak,
            kb_layout = gb,gb
            kb_options = grp:alt_shift_toggle,caps:escape
          }
        '';
      };
    }
  ];
}
