{
  config,
  pkgs,
  inputs,
  ...
}: {
  imports = [./hardware-configuration.nix];

  nixpkgs.config.allowUnfree = true;
  system.autoUpgrade.enable = true;
  time.timeZone = "America/New_York";
  powerManagement.enable = true;

  hardware = {
    bluetooth = {
      enable = true;
      powerOnBoot = true;
      settings = {
        General = {
          Enable = "Source,Sink,Media,Socket";
        };
      };
    };
  };

  nix = {
    gc.automatic = false;
    settings = {
      experimental-features = ["nix-command" "flakes"];
      #substituters = ["http://nix.dhilton.xyz/" "https://cache.nixos.org/"];
      #trusted-public-keys = ["nix.dhilton.xyz:MOW060dF1A0/UXmPZBue9KMxCO13PHYFwx1X9hcdYZ4="];
    };
  };

  networking = {
    hostName = "laptop";
    networkmanager.enable = true;
    firewall.enable = true;
  };

  i18n = {
    defaultLocale = "en_US.UTF-8";
    extraLocaleSettings = {
      LC_ADDRESS = "en_US.UTF-8";
      LC_IDENTIFICATION = "en_US.UTF-8";
      LC_MEASUREMENT = "en_US.UTF-8";
      LC_MONETARY = "en_US.UTF-8";
      LC_NAME = "en_US.UTF-8";
      LC_NUMERIC = "en_US.UTF-8";
      LC_PAPER = "en_US.UTF-8";
      LC_TELEPHONE = "en_US.UTF-8";
      LC_TIME = "en_US.UTF-8";
    };
  };

  services = {
    hardware.bolt = {enable = true;};
    displayManager.ly = {
      enable = true;
      x11Support = false;
      settings = {
        animation = "colormix";
        battery_id = "BAT0";
        clear_password = true;
        colormix_col1 = "0xffffea";
        colormix_col2 = "0x006600";
        colormix_col3 = "0x8888cc";
      };
    };
    pipewire = {
      enable = true;
      alsa.enable = true;
      alsa.support32Bit = true;
      pulse.enable = true;
      jack.enable = true;
    };
    auto-cpufreq = {
      enable = false;
      settings = {
        battery = {
          governor = "powersave";
          turbo = "never";
        };
        charger = {
          governor = "balance_performance";
          turbo = "auto";
        };
      };
    };
    logind = {
      lidSwitch = "suspend-then-hibernate";
      lidSwitchExternalPower = "suspend";
    };
    avahi = {
      enable = false;
      nssmdns4 = true;
      openFirewall = true;
    };

    blueman.enable = true;
    fwupd.enable = true;
    printing.enable = true;
    fprintd.enable = true;
    thermald.enable = true;
  };

  stylix = {
    enable = true;
    autoEnable = true;
    polarity = "light";
    image = ./wallpaper.png;
    targets.chromium.enable = false;
    base16Scheme = {
      base00 = "#ffffea";
      base01 = "#eaffff";
      base02 = "#eeee9e";
      base03 = "#99994c";
      base04 = "#555555";
      base05 = "#000000";
      base06 = "#000000";
      base07 = "#000000";
      base08 = "#aa0000";
      base09 = "#884400";
      base0A = "#99994c";
      base0B = "#006600";
      base0C = "#8888cc";
      base0D = "#000099";
      base0E = "#8888cc";
      base0F = "#5d3a1a";
    };
    #"${pkgs.base16-schemes}/share/themes/everforest.yaml";
    opacity = {
      terminal = 0.85;
      popups = 0.75;
      desktop = 0.75;
      applications = 0.85;
    };
    cursor = {
      package = pkgs.adwaita-icon-theme;
      name = "Adwaita";
      size = 28;
    };
    fonts = {
      serif = {
        package = pkgs.nerd-fonts.iosevka;
        name = "Iosevka NF";
      };

      sansSerif = {
        package = pkgs.nerd-fonts.iosevka;
        name = "Iosevka NF";
      };

      monospace = {
        package = pkgs.nerd-fonts.iosevka;
        name = "Iosevka NFM";
      };
    };
  };

  hardware = {
    sensor.iio.enable = true;
    graphics.enable32Bit = true;
    graphics.extraPackages = with pkgs; [
      intel-vaapi-driver
      intel-media-driver
      intel-compute-runtime
    ];
  };

  programs = {
    zsh.enable = true;
    virt-manager.enable = true;
    niri = {
      enable = true;
    };
  };

  virtualisation = {
    libvirtd = {enable = true;};
    kvmgt = {enable = true;};
    docker = {enable = true;};
  };

  users.users.k = {
    isNormalUser = true;
    description = "k";
    extraGroups = ["networkmanager" "wheel" "cdrom" "libvirtd"];
    packages = with pkgs; [zsh];
    shell = pkgs.zsh;
  };

  home-manager = {
    backupFileExtension = "bk";
    users = {"k" = import ./home.nix;};
  };

  environment = {
    sessionVariables = {MOZ_USE_XINPUT2 = "1";};
    systemPackages = with pkgs; [
      config.boot.kernelPackages.perf
    ];
  };

  systemd.sleep.extraConfig = ''
    HibernateDelaySec=20m
    SuspendState=mem
  '';

  boot = {
    plymouth = {enable = true;};

    consoleLogLevel = 0;
    initrd.verbose = false;
    kernelParams = [
      "quiet"
      "splash"
      "boot.shell_on_fail"
      "loglevel=3"
      "rd.systemd.show_status=false"
      "rd.udev.log_level=3"
    ];
    loader.timeout = 0;
  };

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.11"; # Did you read the comment?
}
