{ cfg, config, lib, pkgs, inputs, ... }:

{
  imports = [
    ./hardware-configuration.nix
    ../graphical/configuration.nix
    inputs.home-manager.nixosModules.default
  ];

  networking.hostName = "darp8";
  networking.networkmanager = {
    enable = true;
    wifi.backend = "iwd";
  };

  time.timeZone = "Europe/Dublin";
  # time.timeZone = "America/New_York";

  hardware = {
    bluetooth.enable = true;
    graphics = {
      enable = true;
      extraPackages = with pkgs;[
        intel-compute-runtime
        intel-media-driver
      ];
    };
    system76.enableAll = true;
  };
  boot = {
    kernelPackages = pkgs.linuxPackages_latest;
  };

  services = {
    system76-scheduler.enable = true;
    tailscale.enable = false;
    power-profiles-daemon.enable = false;
    thermald.enable = true;
    logind.settings.Login.HandleLidSwitch = "suspend-then-hibernate";
    hardware.bolt.enable = true;
  };

  systemd = {
    services = {
      charge-thresholds = {
        description = "Set System76 battery charge thresholds";
        wantedBy = [ "multi-user.target" "post-resume.target" ];
        after = [ "network.target" "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
        serviceConfig = {
          Type = "oneshot";
          ExecStart = "${pkgs.system76-power}/bin/system76-power charge-thresholds --profile balanced";
          RemainAfterExit = true;
        };
      };
    };

    sleep.settings.Sleep = {
      HibernateDelaySec="15m";
      SuspendState="mem";
    };
  };

  home-manager = {
    useGlobalPkgs = true;
    extraSpecialArgs = { inherit inputs; inherit cfg; };
    users = {
      "${cfg.username}" = import ./home.nix;
    };
    backupFileExtension = ".bak";
  };

  # This option defines the first version of NixOS you have installed on this particular machine
  # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
  # and migrated your data accordingly.
  #
  # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
  system.stateVersion = "23.11"; # Did you read the comment?
}
