# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];
  boot.kernelPackages = pkgs.linuxPackages_latest;
  boot.kernelParams = [
    "quiet"
    "splash"
  ];

  # https://github.com/lwfinger/rtw89/issues/240
  # boot.extraModprobeConfig = ''
  #   options rtw89_pci disable_aspm_l1ss=y disable_aspm_l1=y disable_clkreq=y
  #   options rtw89_core disable_ps_mode=y
  # '';

  # ipu is apparently required to make the webcam available as a camera device
  hardware.ipu6 = {
    enable = true;
    platform = "ipu6";
  };

  services.fwupd.enable = true;

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/1ea0784c-4eeb-46f1-a0ae-f6b311b27bd1";
      fsType = "btrfs";
      options = [ "subvol=@" ];
    };

  boot.initrd.luks.devices."luks-root" = {
    device = "/dev/disk/by-uuid/8832c090-9ca7-4a9c-8cfd-cf43cb59b3d3";
    crypttabExtraOpts = [ "fido2-token=auto" ];
  };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/86C2-FD4D";
      fsType = "vfat";
      options = [ "fmask=0022" "dmask=0022" ];
    };

  fileSystems."/home" =
    { device = "/dev/disk/by-uuid/1ea0784c-4eeb-46f1-a0ae-f6b311b27bd1";
      fsType = "btrfs";
      options = [ "subvol=@home" ];
    };

  # TODO - only enable this if the user remy exists
  fileSystems."/scratch/${config.nix-config.userName}" =
    { device = "/dev/disk/by-uuid/1ea0784c-4eeb-46f1-a0ae-f6b311b27bd1";
      fsType = "btrfs";
      options = [
        "subvol=@scratch"
        # Even though the mount point is not in home, we still want to show it in gnome-related file managers
        "x-gvfs-show"
        "x-gvfs-name=scratch"
        "x-gvfs-icon=view-refresh"
        ];
      # TODO make it owned by the user
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface.
  networking.useDHCP = lib.mkDefault true;


  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;

}
