{
  inputs,
  config,
  lib,
  pkgs,
  ...
}: let
  inherit (builtins) toString;
  inherit (lib.modules) mkAliasOptionModule mkDefault mkIf;
  inherit (lib.my) mapModulesRec';
in {
  # disables Nixpkgs Hyprland module to avoid conflicts
  #disabledModules = [ "programs/hyprland.nix" ];
  
  imports =
    [
      inputs.home-manager.nixosModules.home-manager
      (mkAliasOptionModule ["hm"] ["home-manager" "users" config.user.name])
  	  inputs.nix-colors.homeManagerModules.default
      inputs.hyprland.nixosModules.default
    ]
    ++ (mapModulesRec' (toString ./modules) import);

  hm.imports = [
    inputs.hyprlock.homeManagerModules.hyprlock
    inputs.hypridle.homeManagerModules.hypridle
    inputs.hyprland.homeManagerModules.default
  ];

  # Common config for all nixos machines;
  environment.variables = {
    NIXPKGS_ALLOW_UNFREE = "1";
  };

  nix = {
    package = pkgs.nixVersions.stable;

    nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # Enables use of `nix-shell -p ...` etc
    registry.nixpkgs.flake = inputs.nixpkgs; # Make `nix shell` etc use pinned nixpkgs

    settings = {
      experimental-features = [ "nix-command" "flakes" ];
      auto-optimise-store = true;
      keep-outputs = true;
      keep-derivations = true;
      substituters = [ "https://nix-community.cachix.org" "https://nixpkgs-wayland.cachix.org" "https://hyprland.cachix.org" ];
      trusted-public-keys = [
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
        "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
        "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
      ];
    };
  };

  system = {
    stateVersion = "23.11";
    configurationRevision = with inputs; mkIf (self ? rev) self.rev;
  };
  hm.home.stateVersion = config.system.stateVersion;

  boot = {
    kernelPackages = mkDefault pkgs.unstable.linuxPackages_latest;
    kernelParams = ["pcie_aspm.policy=performance"];
  };

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "workman";
  };
  console = {
    useXkbConfig = mkDefault true;
  };

  time.timeZone = mkDefault "Europe/Moscow";

  i18n.defaultLocale = mkDefault "en_GB.UTF-8";

  hardware.enableRedistributableFirmware = true;

  environment.systemPackages = with pkgs; [
    unrar unzip
  	micro
  	curl wget
    desktop-file-utils
    shared-mime-info
    xdg-user-dirs
    xdg-utils
    # fun fact! when using flakes not having
    # git available as a global package while operating
    # on a git repository makes nixos-rebuild break,
    # rendering your system unable to rebuild.
    # nix is really cool
    git  
  ];

  documentation.nixos.enable = false;
}
