{ lib, pkgs, inputs, system, windows-theme, ... }:

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

  home-manager = {
    backupFileExtension = "backup";
    users = {
      admin = import ./home.nix;
    };
    extraSpecialArgs = { inherit inputs system pkgs windows-theme; };
    sharedModules = [
      inputs.self.homeModules.default
    ];
  };

  # Use the systemd-boot EFI boot loader.
  boot = {
    kernelParams = [ "console=tty0" ];
    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
      # timeout = 5;
    };
    plymouth = {
      enable = true;
    };
  };

  nixp.enable = true;

  networking = {
    hostName = "nixp";
    networkmanager.enable = true;
  };

  hardware.bluetooth = {
    enable = true;
    powerOnBoot = true;
  };

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

  i18n = {
    defaultLocale = "en_US.UTF-8";

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

  fonts.packages = with pkgs; [
    noto-fonts
    noto-fonts-emoji
    corefonts
  ];

  services = {
    xserver = {
      enable = true;
      xkb.layout = "gb,cz,ru";

      desktopManager = {
        mate.enable = true;
        xfce.enable = false;
      };

      displayManager.lightdm = {
        enable = true;
      };
    };

    displayManager = {
      defaultSession = "mate";
    };

    libinput.enable = true;
    blueman.enable = true;


    pulseaudio.enable = false;
    pipewire = {
      enable = true;
      alsa.enable = true;
      alsa.support32Bit = true;
      pulse.enable = true;
    };
  };

  security.rtkit.enable = true;

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

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users = {
    root.password = "admin1234";
    admin = {
      isNormalUser = true;
      extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user.
      password = "admin1234";
      packages = (with pkgs; [
        git
        helix
        dconf-editor

        librewolf
        hypnotix
        blueman
        libreoffice
        wineWowPackages.stable
        mpv
        stremio
      ]);
    };
  };

  nixpkgs.config = {
    allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
      "stremio-shell"
      "stremio-server"
      "corefonts"
    ];

    permittedInsecurePackages = [
      "qtwebengine-5.15.19"
    ];
  };

  environment.mate.excludePackages = with pkgs.mate; [
    mate-terminal
    mate-themes
    mate-user-share
    mate-backgrounds
  ];

  # List packages installed in system profile.
  # You can use https://search.nixos.org/ to find more packages (and options).

  # 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 = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # Copy the NixOS configuration file and link it from the resulting system
  # (/run/current-system/configuration.nix). This is useful in case you
  # accidentally delete configuration.nix.
  # system.copySystemConfiguration = true;

  # This option defines the first version of NixOS you have installed on this particular machine,
  # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
  #
  # Most users should NEVER change this value after the initial install, for any reason,
  # even if you've upgraded your system to a new NixOS release.
  #
  # This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
  # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
  # to actually do that.
  #
  # This value being lower than the current NixOS release does NOT mean your system is
  # out of date, out of support, or vulnerable.
  #
  # 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 .
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  system.stateVersion = "25.11"; # Did you read the comment?

}

