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

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

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

# Latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;

# catppuccin
catppuccin.autoEnable = false;
catppuccin.enable = true;

# Bootloader
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.limine = {
    enable = true;
    enableEditor = true;
    maxGenerations = 10;
};
catppuccin.limine = {
    enable = true;
    flavor = "mocha";
    accent = "lavender";
};

# Time and locale
time.timeZone = "Europe/Warsaw";
i18n.defaultLocale = "en_DK.UTF-8";

# Swap
swapDevices = [{
    device = "/.swapfile";
    size = 8*1024;
}];

# TTY related
console = {
    keyMap = "pl";
};
catppuccin.tty = {
    enable = true;
    flavor = "mocha";
};

# Enable doas and disable sudo
security.doas.enable = true;
security.sudo.enable = false;
security.doas.extraRules = [{
    users = ["cln"];
    keepEnv = true;
    persist = true;
}];

# Polkit
security.polkit.enable = true;

# Set up an user account
users.users.cln = {
    isNormalUser = true;
    description = "cln";
    createHome = true;
    home = "/home/cln";
    shell = pkgs.zsh;
    extraGroups = [ "wheel" "audio" "video" "render" ]; 
};

# Pipewire
security.rtkit.enable = true;
    services.pipewire = {
        enable = true;
        alsa.enable = true;
        alsa.support32Bit = true;
        pulse.enable = true;
        jack.enable = true;
};

# Intel GPU Drivers
hardware.graphics = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver     
      vpl-gpu-rt             
      intel-compute-runtime   
      libvdpau-va-gl       
    ];
};

environment.sessionVariables = {
    LIBVA_DRIVER_NAME = "iHD";
    VDPAU_DRIVER = "va_gl";
};

hardware.enableRedistributableFirmware = true;
boot.kernelParams = [ "i915.enable_guc=3" ];

# Bluetooth
hardware.bluetooth = {
  enable = true;
  powerOnBoot = false;
};

# Networking
networking = {
    hostName = "cln";
    wireless.iwd = {
        enable = true;
        settings = {
            Settings = {
                AutoConnect = true;
            };
        };
    };
    firewall = {
        enable = true;
        allowedTCPPorts = [];
        allowedUDPPorts = [];
    };
    nameservers = [
        "194.242.2.4"
        "194.242.2.2"
        "1.1.1.1"
        "1.0.0.1"
    ];
};

# Display manager
services.displayManager.sddm = {
    enable = true;
    wayland.enable = true;
};
catppuccin.sddm = {
    enable = true;
    flavor = "mocha";
    accent = "lavender";
};

# Niri related ( configuration is in modules/niri )
programs.niri.enable = true;

# Bash
programs.zsh.enable = true;

# iVPN
services.ivpn.enable = true;

# Upower
services.upower.enable = true;

# Steam
programs.steam = {
    enable = true;
    remotePlay.openFirewall = false;
    dedicatedServer.openFirewall = false;
};
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "steam"
    "steam-unwrapped"
];

# Fonts
fonts.packages = with pkgs; [
    jetbrains-mono
    nerd-fonts.jetbrains-mono
];

environment.systemPackages = with pkgs; [
    cryptsetup
    xfsprogs
];

system.stateVersion = "26.11";

}
