{
  config,
  pkgs,
  username,
  project,
  ...
}: let
  # Define the custom background package with the correct relative path
  background-package = pkgs.stdenvNoCC.mkDerivation {
    name = "background-image";
    src = ../other/wallpaper4.png; # Place wallpaper.jpg in the same directory as this config file
    dontUnpack = true;
    installPhase = ''
      cp $src $out
    '';
  };

  plasmaTheme = "desktop"; #Possible values are "laptop" or "desktop"
  powerProfile = "laptop"; #Possible values are "laptop" or "desktop"
in {
  imports = [
    ./autostart.nix
    ../modules/stylix
  ];

  # Pass the variable to home-manager
  home-manager.extraSpecialArgs = {
    inherit plasmaTheme powerProfile;
  };

  home-manager.sharedModules = [
    ./home.nix
  ];

  systemd.services = {
    "plasma-workspace".serviceConfig.KillMode = "mixed";
    "plasma-workspace".serviceConfig.TimeoutStopSec = "5s";
    "sddm".serviceConfig.KillMode = "mixed";
  };

  programs.gamemode.enable = true;

  services = {
    xserver = {
      enable = true;
      videoDrivers = ["amdgpu"];

      xkb = {
        layout = "de";
        variant = "";
      };

      desktopManager = {
        #gnome.enable = true;
        xterm.enable = false;
      };

      excludePackages = [pkgs.xterm];
      ## Enable sound with pipewire.
      #services.pulseaudio.enable = false;
    };

    displayManager = {
      sddm = {
        enable = true;
        theme = "breeze";
        wayland.enable = true;
      };
    };

    # Enable the KDE Plasma Desktop Environment.
    desktopManager.plasma6.enable = true;
  };

  system.activationScripts.script.text = ''
    source /home/${username}/${project}/other/colors.sh
    source /home/${username}/${project}/other/pfp.sh
  '';

  environment = {
    plasma6.excludePackages = with pkgs; [
      kdePackages.elisa
    ];

    systemPackages = with pkgs; [
      (pkgs.writeTextDir "share/sddm/themes/breeze/theme.conf.user" ''
        [General]
        background = "${background-package}"
      '') #Custom SDDM theme with background image
      kdePackages.plymouth-kcm
      xdg-desktop-portal
      kdePackages.xdg-desktop-portal-kde
      kdePackages.plasma-workspace
      kdePackages.kdialog
      kdePackages.yakuake #Drop down Terminal
      kdePackages.bluez-qt #Bluetooth management for KDE Plasma
      kdePackages.kconfig #To Get infos about the current config, such as themes
    ];
  };
}
