# 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’).

{
  pkgs,
  ...
}:

{
  imports = [
    ./gnome
    ./hardware-configuration.nix
    ./keyboard.nix
    ./terminal
    ./hyprland
    ./audio.nix
    ./networking.nix
    ./development.nix
    ./security.nix
    ./locale.nix
    ./sddm.nix
  ];

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

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.martin = {
    isNormalUser = true;
    description = "martin";
    extraGroups = [
      "networkmanager"
      "wheel"
    ];
    packages = with pkgs; [ ];
  };

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

  environment.sessionVariables = {
    # Tells Electron apps to use Wayland
    NIXOS_OZONE_WL = "1";
    NIXOS_CONFIG_PATH = "/etc/nixos";
  };

  fonts = {
    fontconfig.enable = true;
    packages = with pkgs; [
      nerd-fonts.jetbrains-mono
    ];
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    gnupg
    wget
    kitty
    xdg-utils
    xdg-desktop-portal-gtk
    kdePackages.qtwayland
    kdePackages.qtsvg
    kdePackages.qt6ct
    protonmail-desktop
    stremio
    fastfetch
    freetube
    nextcloud-client
    discord
    nix-prefetch-github # Cmd to get rev and hash from GitHub
    gimp
    vlc
  ];

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

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

  programs = {
    gnupg.agent.enable = true;

    kdeconnect.enable = true;

    steam = {
      enable = true;
      remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
      dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
      localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
    };
  };

  # List services that you want to enable:

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

  services = {
    flatpak.enable = true;

    xserver = {
      enable = true;
      # Load Nvidia driver for Xorg and Wayland
      videoDrivers = [ "nvidia" ];
    };
  };

  stylix = {
    enable = true;
    image = ./catppuccin.png;
    base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
    polarity = "dark";
    opacity.terminal = 0.8;
    override = {
      base02 = "b0b0b0"; # Comments in shell
      base03 = "b0b0b0"; # Comments in nvim
      base04 = "b0b0b0"; # Secondary text in shell
    };
  };

  qt.enable = true;

  hardware = {
    # Enable OpenGL
    graphics.enable = true;
    nvidia = {
      # Required
      modesetting.enable = true;
      # Use closed-source drivers
      open = false;
      # Enable the Nvidia settings menu
      nvidiaSettings = true;
    };
  };

  # 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.11"; # Did you read the comment?
}
