# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

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

{

  imports =
  [
    ./hardware-configuration.nix
  ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # default kernel causes issues with wpa_supplicant meaning shutdown times are > 10 mins updating to kernel 69+ fixes this
  boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_10;

  # I was told that adding these helps but it doesnt seemt to work as monitors are still buggy at 144hz, may as well keep them
  boot.kernelParams = [
    "video=DP-2:1920x1080@144"
    "video=DP-3:1920x1080@144"
    "video=eDP-2:2560x1200@165"
  ];

  boot.initrd.kernelModules = [ "amdgpu" ];

  networking.hostName = "gabbielaptop"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  hardware.graphics = {
    enable = true;
    enable32Bit = true;
  };
  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/London";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_GB.UTF-8";

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

  # Enable the X11 windowing system.
  # You can disable this if you're only using the Wayland session.
#  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.displayManager.sddm.enable = true;
  services.displayManager.sddm.wayland.enable = true;
#  services.desktopManager.plasma6.enable = true;

  # Enable the Hyprland WM functionality for NixOS (xdg portals etc.)
  programs.hyprland.enable = true;  
#  programs.waybar.enable = true;

  # Configure keymap in X11
  services.xserver.xkb.layout = "gb";

  # Configure console keymap
  console.keyMap = "uk";

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  programs.zsh.enable = true;
  users.users.blue = {
    isNormalUser = true;
    description = "Gabriella Bere";
    extraGroups = [ "networkmanager" "wheel" "dialout" ];
    shell = pkgs.zsh;
  };

#  home-manager = {
#    extraSpecialArgs = { inherit inputs; };
#    users = {
#      "blue" = import ../../home-manager/home.nix;
#    };
#  };

  # Enable fingerprint daemon
  services.fprintd.enable = true;

  # Enable bluetooth and blueman
  hardware.bluetooth.enable = true;
  services.blueman.enable = true;

  # Install firefox.
  programs.firefox.enable = true;

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # Enable flatpak for delcarative-flatpak used in home-manager
  services.flatpak.enable = true;

  # Enable qmk for managing framework laptop keyboards
  hardware.keyboard.qmk.enable = true;

  # Enable steam and enable steam remoteplay
  programs.steam.enable = true;
  programs.steam.remotePlay.openFirewall = true;  

  services.protonmail-bridge.enable = true;

  # protonmail daemon config
#  systemd.user.services.protonmail-bridge = {
#    enable = true;
#    wantedBy = [ "default.target" ];
#    description = "autostart protonmail-bridge on login as a daemon";
#    serviceConfig = {
#      Type = "simple";
#      ExecStart = "${lib.getExe pkgs.protonmail-bridge} --noninteractive --no-window";
#    };
#  };

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  networking.firewall.allowedTCPPorts = [ 
    43391 # used to forward minecraft traffic to minecraft.gabbie.blue:33991
    4455 # used for OBS websocket
  ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # networking.firewall.allowedTCPPortRanges = [
  #   {
  #     from = 49000;
  #     to = 65535;
  #   }
  # ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # 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 = "24.05"; # Did you read the comment?

}