# 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, pkgs, ... }:

{
  imports =
    [
      # Include the results of the hardware scan.
      (if builtins.pathExists /etc/nixos/hardware-configuration.nix then /etc/nixos/hardware-configuration.nix else null)
      # Include device-specific overrides
      (if builtins.pathExists /etc/nixos/device-configuration.nix then /etc/nixos/device-configuration.nix else null)
      ./nvidia.nix
      ./docker.nix
      ./razer.nix
      ./desktop/gnome.nix
      #./desktop/kde-plasma.nix
      ./shell.nix
      ./virtualization.nix
      ./polkit/disable-shutdown.nix
      ./locale.nix
      ./adb.nix
      ./account.nix
    ];

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

  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Enable networking
  networking.networkmanager.enable = true;
  
  # X11 and desktop/display manager is enabled using imported files

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

  # Enable flatpak, some software is newer here unfortunately
  services.flatpak.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;

    # Enable audio interfaces renaming
    wireplumber.enable = true;
  };

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

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    wget
    git
    ffmpeg
    yt-dlp
    mpv
    htop
    btop
    neofetch
    ranger
    gimp
    inkscape
    krita
    smartmontools
    ddrescue
  ];

  # terminal text editor
  programs.neovim = {
    enable = true;
    viAlias = true;
    defaultEditor = true;
    configure = {
      customRC = ''
        set number
        set hlsearch
        set incsearch
        set tabstop=4
        set softtabstop=4
        set shiftwidth=4
        set expandtab
        set autoindent

        syntax on
        set encoding=utf-8
        set wildmode=longest,list,full
        set listchars=space:·,tab:┄┄»
        set indentkeys-=0#
      '';
      packages.myVimPackage = with pkgs.vimPlugins; {
        start = [
          guess-indent-nvim
        ];
      };
    };
  };

  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
  };

  # Enable fail2ban because of the OpenSSH server
  services.fail2ban = {
    enable = true;
    maxretry = 10;
    bantime = "7d";
  };

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    ports = [
      22
      8022
    ];
    extraConfig = ''
      X11Forwarding yes
    '';
  };

  networking.firewall = {
    enable = true;
    # "Disable" firewall because of docker
    allowedTCPPortRanges = [{ from = 0; to = 65535;}];
    allowedUDPPortRanges = [{ from = 0; to = 65535;}];
  };

  # 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.05"; # Did you read the comment?
  # I am lazy
}