# 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,
  modulesPath,
  nixos-hardware,
  ...
}:

{
  imports = [
    (modulesPath + "/installer/scan/not-detected.nix")
    nixos-hardware.nixosModules.lenovo-thinkpad-t14
  ];

  console.keyMap = "de";
  services.xserver.xkb.layout = "de";

  boot = {
    initrd = {
      availableKernelModules = [
        "nvme"
        "xhci_pci"
        "thunderbolt"
        "usbhid"
      ];
      luks.devices."btrfs-crypt".device = "/dev/disk/by-uuid/d4f76a5f-bf47-4a03-b7dc-3a1a7f83c030";
      kernelModules = [ ];
    };
    supportedFilesystems = [ "btrfs" ];
    kernelModules = [ "kvm-amd" ];
    extraModulePackages = [ ];

    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };
  };

  fileSystems = {
    "/" = {
      device = "none";
      fsType = "tmpfs";
      options = [
        "defaults"
        "size=8G"
        "mode=755"
      ];
    };
    "/tmp" = {
      device = "/dev/mapper/btrfs-crypt";
      fsType = "btrfs";
      options = [
        "subvol=tmp"
        "noatime"
        "compress=zstd"
      ];
      neededForBoot = true;
    };
    "/persist" = {
      device = "/dev/mapper/btrfs-crypt";
      fsType = "btrfs";
      options = [
        "subvol=persist"
        "noatime"
        "compress=zstd"
      ];
      neededForBoot = true;
    };
    "/nix" = {
      device = "/dev/mapper/btrfs-crypt";
      fsType = "btrfs";
      options = [
        "subvol=nix"
        "noatime"
        "compress=zstd"
      ];
      neededForBoot = true;
    };
    "/snapshots" = {
      device = "/dev/mapper/btrfs-crypt";
      fsType = "btrfs";
      options = [
        "subvol=snapshots"
        "noatime"
        "compress=zstd"
      ];
      neededForBoot = false;
    };
    "/boot" = {
      device = "/dev/disk/by-uuid/4FE7-0CC9";
      fsType = "vfat";
      options = [
        "fmask=0022"
        "dmask=0022"
      ];
    };
  };

  swapDevices = [ ];
  powerManagement = {
    enable = true;
    cpuFreqGovernor = "powersave";
  };

  services = {
    upower.enable = true;
  };

  # 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;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
  time = {
    timeZone = "Europe/Berlin";
    hardwareClockInLocalTime = true;
  };
  networking.timeServers = [
    "ntp1.zih.tu-dresden.de"
    "ntp2.zih.tu-dresden.de"
  ];
}