Enable Plasma 6

There are no secrets in my config, but maybe newbie stuff :smiley:

I deploy this configuration.nix through a flake.



    # 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.
          ./hardware-configuration.nix
          ./system/apps/steam.nix
        ];
     
      nix.settings.experimental-features = [ "nix-command" "flakes" ];
     
      # Bootloader
      boot.loader.systemd-boot.enable = true;
      boot.loader.efi.canTouchEfiVariables = true;
     
      networking.hostName = "sn0wbound"; # Define your hostname.
      # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
     
      # Configure network proxy if necessary
      # networking.proxy.default = "http://user:password@proxy:port/";
      # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
     
      # Enable networking
      networking.networkmanager.enable = true;
     
      # Set your time zone.
      time.timeZone = "Europe/Berlin";
     
      # Select internationalisation properties.
      i18n.defaultLocale = "en_US.UTF-8";
     
      i18n.extraLocaleSettings = {
        LC_ADDRESS = "de_DE.UTF-8";
        LC_IDENTIFICATION = "de_DE.UTF-8";
        LC_MEASUREMENT = "de_DE.UTF-8";
        LC_MONETARY = "de_DE.UTF-8";
        LC_NAME = "de_DE.UTF-8";
        LC_NUMERIC = "de_DE.UTF-8";
        LC_PAPER = "de_DE.UTF-8";
        LC_TELEPHONE = "de_DE.UTF-8";
        LC_TIME = "de_DE.UTF-8";
      };
     
      # Enable the X11 windowing system.
      services.xserver.enable = true;
     
      # Enable the Cinnamon Desktop Environment.
      #services.xserver.displayManager.lightdm.enable = true;
      #services.xserver.desktopManager.cinnamon.enable = true;
     
      # Enable KDE Plasma 6
      #services.displayManager.sddm.wayland.enable = true;
      services.displayManager.sddm.enable = true;
      services.desktopManager.plasma6.enable = true;
     
      # Configure keymap in X11
      services.xserver.xkb = {
        layout = "de";
        variant = "";
      };
     
      # Using AMD GPU
      boot.initrd.kernelModules = [ "amdgpu" ];
      services.xserver.videoDrivers = [ "amdgpu" ];
      hardware.opengl.driSupport = true; # This is already enabled by default
      hardware.opengl.driSupport32Bit = true; # For 32-bit applications
      hardware.opengl.extraPackages = with pkgs; [
        amdvlk
        #vulkan-loader
        #vulkan-validation-layers
        #vulkan-extension-layer
      ];
      hardware.opengl.extraPackages32 = with pkgs; [ 
        driversi686Linux.amdvlk
      ];
     
      # Enable OpenGL
      #hardware.opengl = {
      #  enable = true;
      #  driSupport = true;
      #  driSupport32Bit = true;
      #  extraPackages = with pkgs; [
      #    vulkan-loader
      #    vulkan-validation-layers
      #    vulkan-extension-layer
      #    amdvlk
      #  ];
      #};
     
     
      # Configure console keymap
      console.keyMap = "de";
     
      # Enable CUPS to print documents.
      services.printing.enable = true;
     
      # Enable Bluetooth
      hardware.bluetooth.enable = true;
      hardware.bluetooth.powerOnBoot = 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;
        # If you want to use JACK applications, uncomment this
        #jack.enable = true;
     
        # use the example session manager (no others are packaged yet so this is enabled by default,
        # no need to redefine it in your config for now)
        #media-session.enable = true;
      };
     
      # Enable touchpad support (enabled default in most desktopManager).
      # services.xserver.libinput.enable = true;
     
      # Define a user account. Don't forget to set a password with ‘passwd’.
      users.users.xkrenzsim = {
        isNormalUser = true;
        description = "Simon Krenz";
        extraGroups = [ "networkmanager" "wheel" ];
        packages = with pkgs; [
        kate
        #  thunderbird
        ];
      };
     
      # Using zsh
      environment.shells = with pkgs; [ zsh ];
      users.defaultUserShell = pkgs.zsh;
      programs.zsh = {
        enable = true;
        autosuggestions.enable = true;
      };
     
      # Install firefox.
      programs.firefox.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; [
          brave
          clinfo
          git
          glxinfo
          #gnomeExtensions.gtile
          home-manager
          # A full featured CLI system information tool
          inxi
          # Multi-platform app that allows your devices to communicate.
          kdePackages.kdeconnect-kde
          # Components necessary to integrate browsers into the Plasma Desktop.
          kdePackages.plasma-browser-integration
          lutris
          nh
          openssl
          pciutils
          # Install and manage Proton-GE and Luxtorpeda for Steam and 
          # Wine-GE for Lutris with this graphical user interface.
          protonup-qt
          tmux-cssh
          vim
          vulkan-tools
          wayland-utils
          winetricks
          wineWowPackages.waylandFull
          wget
          xwaylandvideobridge
        ]);
     
        #++
     
        #(with pkgs-unstable; [
        #  nh
        #]);
     
      # 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;
     
      # 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.11"; # Did you read the comment?
     
      # Optimising the NixOS store with automatic options. This will optimise the
      # store on every build which may slow down builds. The alternativ is to set
      # them on specific dates like this:
      # nix.optimise.automatic = true;
      # nix.optimise.dates = [ "03:45" ]; # Optional; allows customizing schedule
      nix.settings.auto-optimise-store = true;
     
    }

For me the configuration that you build clearly generates a sddm.conf.

with having services.displayManager.sddm.wayland.enable set to false

╰─ ls -alh result/etc/sddm.conf
lrwxrwxrwx 2 root root 53  1. Jan 1970  result/etc/sddm.conf -> /nix/store/17zdhjjczgs2xfirz8lzv5pmkwpbl21a-sddm.conf


╰─ cat result/etc/sddm.conf
[General]
DefaultSession=plasma.desktop
DisplayServer=x11
GreeterEnvironment=LANG=C.UTF-8 QT_WAYLAND_SHELL_INTEGRATION=layer-shell
HaltCommand=/run/current-system/systemd/bin/systemctl poweroff
InputMethod=
Numlock=none
RebootCommand=/run/current-system/systemd/bin/systemctl reboot

[Theme]
Current=breeze
CursorSize=24
CursorTheme=breeze_cursors
FacesDir=/run/current-system/sw/share/sddm/faces
ThemeDir=/run/current-system/sw/share/sddm/themes

[Users]
HideShells=/run/current-system/sw/bin/nologin
HideUsers=nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9
MaximumUid=30000

[Wayland]
CompositorCommand=
EnableHiDPI=true
SessionDir=/nix/store/fsxrh4ambgsc11arnb7s3fjp9w0kj49y-desktops/share/wayland-sessions

[X11]
DisplayCommand=/nix/store/p5lav04ppa1844r2jn1534qm0fs582d2-Xsetup
DisplayStopCommand=/nix/store/ib5ak7pyc3daypvvq1sycq83awz516x2-Xstop
EnableHiDPI=true
MinimumVT=7
ServerPath=/nix/store/ydybhrzdbwjlws3bb82sna1vr3868r0k-xserver-wrapper
SessionCommand=/nix/store/ar36n7wr14050isypp6440gnpf7lkpwr-xsession-wrapper
SessionDir=/nix/store/fsxrh4ambgsc11arnb7s3fjp9w0kj49y-desktops/share/xsessions
XauthPath=/nix/store/lxwa7w70v4460x4smpsyzw098l87vn7i-xauth-1.1.3/bin/xauth
XephyrPath=/nix/store/0c9wn8nb04qs9kyh2zhll4wzjmp0fmag-xorg-server-21.1.13/bin/Xephyr

with having it true

╭─ ~/dev/test                                                                                                                                                                                                 ✔  took 22s  at 21:37:20 
╰─ ls -alh result/etc/sddm.conf                                
lrwxrwxrwx 2 root root 53  1. Jan 1970  result/etc/sddm.conf -> /nix/store/wrw8qp3fmmi3848j9jqqc687bw9k7qzw-sddm.conf

╭─ ~/dev/test                                                                                                                                                                                                            ✔  at 21:37:30 
╰─ cat result/etc/sddm.conf                                
[General]
DefaultSession=plasma.desktop
DisplayServer=wayland
GreeterEnvironment=LANG=C.UTF-8 QT_WAYLAND_SHELL_INTEGRATION=layer-shell
HaltCommand=/run/current-system/systemd/bin/systemctl poweroff
InputMethod=
Numlock=none
RebootCommand=/run/current-system/systemd/bin/systemctl reboot

[Theme]
Current=breeze
CursorSize=24
CursorTheme=breeze_cursors
FacesDir=/run/current-system/sw/share/sddm/faces
ThemeDir=/run/current-system/sw/share/sddm/themes

[Users]
HideShells=/run/current-system/sw/bin/nologin
HideUsers=nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9
MaximumUid=30000

[Wayland]
CompositorCommand=/nix/store/rizf7g8a5w26lxamz1f5d41knd01pivk-kwin-6.0.4.1/bin/kwin_wayland --no-global-shortcuts --no-kactivities --no-lockscreen --locale1
EnableHiDPI=true
SessionDir=/nix/store/fsxrh4ambgsc11arnb7s3fjp9w0kj49y-desktops/share/wayland-sessions

[X11]
DisplayCommand=/nix/store/p5lav04ppa1844r2jn1534qm0fs582d2-Xsetup
DisplayStopCommand=/nix/store/ib5ak7pyc3daypvvq1sycq83awz516x2-Xstop
EnableHiDPI=true
MinimumVT=7
ServerPath=/nix/store/ydybhrzdbwjlws3bb82sna1vr3868r0k-xserver-wrapper
SessionCommand=/nix/store/ar36n7wr14050isypp6440gnpf7lkpwr-xsession-wrapper
SessionDir=/nix/store/fsxrh4ambgsc11arnb7s3fjp9w0kj49y-desktops/share/xsessions
XauthPath=/nix/store/lxwa7w70v4460x4smpsyzw098l87vn7i-xauth-1.1.3/bin/xauth
XephyrPath=/nix/store/0c9wn8nb04qs9kyh2zhll4wzjmp0fmag-xorg-server-21.1.13/bin/Xephyr

The X11 content is there, because you have still set services.xserver.enable = true.
That would be empty if you set it to false, tho that could likely be removed, ill check that out.

But i dont see any problems on the config that you have provided with generating a sddm.conf, so either you have other configs set that you did not include in your example (the steam-apps.nix and hardware-configuration.nix are missing), or some strange setup that hides the /etc, for understanding that it might be helpful to have those files also.

Or if that in overall wasnt the question i possibly just missunderstood you, which is also possibly :slight_smile:

But as it seems to be more a sddm topic, it might be better to open a separat thread then.

2 Likes

That is why I am so confused. As soon as I set services.displayManager.sddm.wayland.enable to true the /etc/sddm.conf is gone. So I will open a new thread for this.

As a little newbie question beside: If I set services.xserver.enable = false my desktop environment is gone and I am only on the cli. How do I enable wayland again?

1 Like

Sandro provided a nice small minimum example for a pure wayland setup in the PR that changed the logic.

I remember that i did the following to use make sure that this is set systemd.defaultUnit = "graphical.target".

But on the final merged version that is automatically set with services.displayManager.enable which is set when enabling sddm.

I am still confused that you claim that sddm.conf is missing when you disable xserver, as that should not be the case and also was not the case for me, when i build your shared config.
It looks to me kind of that sddm is not part of your resulting system top level.
You could possibly double check if its really enabled via nix repl when you load your config and inspect the final values.

1 Like

Sorry, this line was marked as optional, but as I ran repeatedly into issues with it personally, on friends computers, and finally also with someone on Matrix, I decided to make it a default recommendation.

I will revert that change now.

You can just leave this option off, it was only intended to fix some issues, where people would boot into a black screen.

Is it possible to set unstable as default and stable as an option instead?
As in, inverse of the current unstablePkgs pattern like:

$ sudo nix-channel --add nixos-23.11 release nixos-23.11.7237.46397778ef1f nixos-stable

Then in configuration:

let
stablePkgs = import {
config = config.nixpkgs.config;
};
in

for the nix config and revert some packages to stable. Or this sort of thing is unlikely to work? Still relatively new to nix.

1 Like

Hi! Switching to Plasma 6 from Plasma 5.

Should I still keep the services.xserver.enable = true in my config? Or do I need to enable Wayland somehow? Thanks

If it helps, my use cases are gaming on an AMD gpu and schoolwork.

Also, I’m having the same issue mentioned above with an unthemed SDDM when switching to Plasma 6 on Wayland. [EDIT] NEVERMIND! Simply set services.displayManager.sddm.theme = "breeze" and reboot. It seems like you have to reboot, as simply logging in and out again didn’t fix it.

1 Like

If you keep it enabled depends a bit on your needs and if you want to run plasma on xserver.
If you dont plan on that you should be able to disable it. I am running a non xserver plamsa6 fine.
Please keep in mind to set services.displayManager.sddm.wayland.enable to true, otherwise you will not have a login manager available, when disabling xserver.

1 Like

I’ve had to add the gtk2, gtk3 and gtk4 packages alongside Plasma 6 to fix cursor and font issues, among other things, with certain programs. All’s been fine since I figured that out.

Anybody else encountered the same thing? Might be fixed now but I haven’t bothered to take the packages out yet.

1 Like

This worked fine for me, but since Plasma 6 is pretty much stable now, is there any indication of whether it will be included by default in the next release?

edit: Apparently they just released a new version three hours ago which includes Plasma 6 by default! lol

3 Likes

Plasma 6 and Wayland have been working great for me - is there any way to remove KDE 5? The system-path package depends on plasma-integration-6.0.5-qt5, kio5-plugins-only, breeze-6.0.5-qt5, and kio-extras-kf5-24.02.2, which bring in a ton of KDE packages at version 5.116.0. There are KDE6 equivalents to all of those installed, and I don’t think I have any KDE5-specific packages installed, so I’m not sure why these are being brought in.

1 Like

There is a planned transition somewhere during Vicuña IIRC - it will be removed automatically (from a user POV anyway) at some point down the line.

2 Likes

Is it possible to switch to Plasma 6 without moving to nixos-unstable branch? I am trying to precisely exclude stable and include unstable modules, but now I’m stuck with error: The option 'hardware.graphics' does not exist (it is required in services/desktop-managers/lomiri.nix). Here’s what I’ve written in the configuration.nix so far:

disabledModules =
  [
    "services/x11/xserver.nix"
    "services/x11/desktop-managers/plasma5.nix"
    "services/x11/display-managers/default.nix"
    "services/x11/window-managers/fvwm2.nix"
  ];
imports =
  [ # Include the results of the hardware scan.
    ./hardware-configuration.nix
    # Home-manager
    <home-manager/nixos>
    # Plasma 6
    <unstable/nixos/modules/services/x11/xserver.nix>
    <unstable/nixos/modules/services/x11/desktop-managers/plasma5.nix>
    <unstable/nixos/modules/services/x11/display-managers/default.nix>
    <unstable/nixos/modules/services/x11/window-managers/fvwm2.nix>
  ];

Plasma 6 is also available in 24.05, Plasma 6.0 being specific.
Just disabling the stable modules and enabling unstable ones will also not bring other packages into life.

If you mean 6.1, you might need to override the whole plasma pacakge group.
As it will likely the most of your system closure, it might be easier to switch just to nixos-unstable.

About your specific problem, hardware.graphics are new options that have been renamed from hardware.opengl. You are facing that issue due to mixing stable with unstable modules.

1 Like

Is there a basic working plasma 6 config I can use as a starting place? I’ve tried doing a fresh NixOS 24.05 Plasma6 installation, but failed: Plasma6 sddm login hangs

I got it booting & managed to login, but the panel is empty, I get crash log windows on most stuff I try to start and the system is utterly useless.

I was hoping to get something close to the installer iso which is working fine on my machine, but allas this doesn’t seem to be as easy as hoped.

I had a basic working NixOS 24.05 system running with the default Gnome desktop, but was keen to try KDE Plasma and Wayland. Sadly the result was just a tty-only login with no windowing system.

I tried to follow the steps above, however as I had not been running KDE5 beforehand some of them did not seem to be relevant.

So anyhow I-

  • switched to the nixos-unstable channel
  • did a nix-channel --update
  • Made the following changes to configuration.nix. Note I disabled everything relating to X on the basis of switching to a “pure” Wayland setup (but that may have been an error)
  • Ran nixos-rebuild switch and rebooted
# KDE Plasma 6
services.desktopManager.plasma6.enable = true;
services.displayManager.sddm.wayland.enable = true;

/*   # Disable all the X11 + Gnome stuff
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  # Stop gdm suspending the machine if nobody is logged in to the console
  services.xserver.displayManager.gdm.autoSuspend = false;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "gb";
    variant = "";
  }; */

Lots of download and rebuilding activity ran, but the end result was just a TTY login with no windowing system in sight.

I have no experience with Wayland, so no idea how to try to start the windowing system manually from the console (i.e. the equivalent of xstart) so my only option was to revert to an earlier generation.

Have I done something obviously silly?, and is there anything I can debug to see what’s gone wrong?

The answer in another thread Missing sddm.conf with KDE Plasma 6 and wayland helped me get Plasma 6 running

The recipe in the inital post seems to be missing a 3rd critical line. The example that works (just to get running) for me is:

# KDE Plasma 6
services.desktopManager.plasma6.enable = true;
# Enable SDDM, then enable Wayland support within SDDM(?)
services.displayManager.sddm.enable = true;
services.displayManager.sddm.wayland.enable = true; # required if no login diplay manager

/*   # Disable X11 + Gnome.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  # Stop gdm suspending the machine if nobody is logged in to the console
  services.xserver.displayManager.gdm.autoSuspend = false;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "gb";
    variant = "";
  }; */

However the keymap is wrong in Plasma, as it’s defaulting to the US keyboard layout. I assume services.xserver.xkb is not the way to configure wayland, so there’s still some config options to track down.

I read somewhere on a KDE (non-NixOS) forum that SDDM respected the system settings in /etc/default/locale. However I set the system locale to en_GB.UTF-8 during installation, but that’s not being picked up by SDDM in this setup.

Update- I couldn’t find a way to configure the keymap/locale for Plasma6 declaratively.

However if you use the KDE System Settings/Keyboard/Layouts option and create a single new layout (English(UK) in my case) this seems to be taken as the system default layout, solving the problem.

I am normally using a “special” keymap (workman) which I was configuring like so:

services.xserver.xkb = {
  layout = "us";
  variant = "workman";
};

Now I cannot do that anymore I have a normal us keyboard for my password (works fine for me and my password luckily) and then Plasma has my keymap configured.

From my quick research rn the relevant code to enable the keymap is both used by wayland and x11 and could be refactored to not be behind the services.xserver collection similar to how displayManager was moved out of the xserver collection a few months back.

https://bbs.archlinux.org/viewtopic.php?pid=1477202#p1477202

I am not yet comfortable enough to work on such low-level components, but I could open an issue.

Tryin’ to update to 24.05 and plasma 6 gets a session without workspace (desktop) I can run Chrome, because it starts with the Plasma/Wayland.

Looks like the windowManager isn’t starting with it.

Looked into journalctl and didn’t found any relevant register.

Also, plasma 5 is behaving same as 6 after upgrade.

Also, my GPU is not a NVidia onde. It is a Radeon

Has someone faced same issue?


configuration.nix

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

   # Install DroidCam and needed v4l2loopback
   #  let v4l2loopback-dc = config.boot.kernelPackages.callPackage ./v4l2loopback-dc.nix { };
   #      droidcam = pkgs.callPackage ./droidcam.nix {};
   #  in {
   #    boot.extraModulePackages = [ v4l2loopback-dc ];
   #     environment.systemPackages = [ droidcam ];
   #   }

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      # Enable the KDE Desktop Environment.
      ./users-configuration.nix
      ./local-configuration.nix
      ./wjjunyor-configuration.nix
      ./x-configuration.nix
      ./networking-configuration.nix
      # Sets-up the Home Manager
      # "${home-manager}/nixos"
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = false;
  # Uses the most recent packages.
  boot.kernelPackages = pkgs.linuxPackages_latest;
  boot.kernelParams = [ "amd_iommu=on" "iommu=1" "rd.driver.pre=vfio-pci" ];   #If host = T101 or T800
  boot.kernelModules = [ "kvm-amd" "tap" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" "v4l2loopback" "snd-aloop" "amdgpu" "dm-snapchot" ]; # "hid-nintendo" #If host = T101 or T800
  boot.extraModprobeConfig = ''#If host = T101 or T800 
	options vfio-pci ids=vendorid:deviceid,vendorid:deviceid 
	options v4l2loopback nr_devices=2 exclusive_caps=1,1,1,1,1,1,1,1 video_nr=0,1 card_label=v4l2lo0,v4l2lo1
        ''; 

  # Teste ZFS 
  # boot.initrd.supportedFilesystems = [ "zfs" ];
  # boot.supportedFilesystems = [ "zfs" ];
  # boot.zfs.enableUnstable = false;
  # services.zfs.autoScrub.enable = true;
  # services.zfs.autoSnapshot.enable = true;
  # services.zfs.autoSnapshot.frequent = 8;
  # services.zfs.autoSnapshot.monthly = 1;
  # services.zfs.trim.enable = true;

  # Supposedly better for the SSD.
  fileSystems."/".options = [ "noatime" "nodiratime" "discard" ];

  # Use the GRUB 2 boot loader.
  boot.loader.grub.enable = true;
  # boot.loader.grub.version = 2;     %%% DEPRECATED %%%
  # boot.loader.grub.backgroundColor = "#7EBAE4";
  boot.loader.grub.device = "nodev";
  boot.loader.grub.efiSupport = true;
  boot.loader.efi.canTouchEfiVariables = true;
  # Grub menu is painted really slowly on HiDPI, so we lower the
  # resolution. Unfortunately, scaling to 1280x720 (keeping aspect
  # ratio) doesn't seem to work, so we just pick another low one.
  boot.loader.grub.gfxmodeEfi = "1024x768";
  boot.loader.grub.enableCryptodisk = true;
  boot.initrd.luks.devices = {
    "root" = {
    device = "/dev/disk/by-uuid/209d5369-c671-4d18-adc2-a97e58c5bb69";
    preLVM = true;
    allowDiscards = true;
    };
  };
  
 
  # Select internationalisation properties.

  console.earlySetup = true;
  console.font = "Lat2-Terminus16";   
  console.keyMap = "br-abnt2";
  # i18n.defaultLocale = "pt_BR.UTF-8/UTF-8";
  # i18n.supportedLocales = [
  #   "all"
  #   "pt_BR.UTF-8/UTF-8"
  #   "en_GB.UTF-8/UTF-8"
  #   "es_ES.UTF-8/UTF-8"
  #   "fr_FR.UTF-8/UTF-8"
  #   "zh_CN.UTF-8/UTF-8"
  #   "C.UTF-8/UTF-8"
  # ];
  # i18n.extraLocaleSettings = {
  #   LANGUAGE = "pt_BR";
  #   LC_ALL = "";
  #   LC_ADDRESS = "pt_BR.UTF-8";
  #   LC_IDENTIFICATION = "pt_BR.UTF-8";
  #   LC_MEASUREMENT = "pt_BR.UTF-8";
  #   LC_MONETARY = "pt_BR.UTF-8";
  #   LC_NAME = "pt_BR.UTF-8";
  #   LC_NUMERIC = "pt_BR.UTF-8";
  #   LC_PAPER = "pt_BR.UTF-8";
  #   LC_TELEPHONE = "pt_BR.UTF-8";
  #   LC_TIME = "pt_BR.UTF-8";  
  # };
  i18n.inputMethod.fcitx5.plasma6Support = true;
 
  # Set your time zone.
  time.timeZone = "America/Campo_Grande";

  # 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; };
  programs.bash.enableCompletion = true;
  programs.nix-index.enableBashIntegration = true;
  programs.zsh.enableBashCompletion = true;
  
  # List services that you want to enable:

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

  # Team Viewer Listener
  services.teamviewer.enable = false;

  # Teste Hardware ZFS 
  # HARDWARE
  hardware.bluetooth.enable = true;
  hardware.cpu.amd.updateMicrocode = true;
  hardware.opengl.driSupport = true;
  hardware.opengl.driSupport32Bit = true;
  hardware.opengl.enable = true;
  hardware.opengl.extraPackages = with pkgs; [ vaapiVdpau libvdpau-va-gl ];
  hardware.pulseaudio.support32Bit = true;
  hardware.pulseaudio.zeroconf.discovery.enable = true;
  hardware.pulseaudio.zeroconf.publish.enable = true;
  hardware.sane.enable = true;

  # Enable sound.
  # sound.enable = true;
  hardware.pulseaudio.enable = true;
  powerManagement.enable = true;

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "23.11"; # Did you read the comment?
  
  # Auto upgrade Always ON.
  system.autoUpgrade.enable = true;

  # Garbage Collection Automation and Disk Usage Otimization
  nix.gc.automatic = true;
  nix.gc.dates = "weekly";
  nix.gc.options = "--delete-older-than 30d";
  nix.settings.auto-optimise-store = true;
  nix.extraOptions = ''
    min-free = ${toString (100 * 1024 * 1024)}
    max-free = ${toString (1024 * 1024 * 1024)}
  '';
  services.journald.extraConfig = ''
    SystemMaxUse=2G
  '';

  # Fundamental core packages
  environment.systemPackages = with pkgs; 
   [ # Basic command line tools
     bash
     zsh
     wget
     file
     # gksu
     glibcLocalesUtf8
     git
     hdf5
     zip
     unzip
     htop
     yle-dl
     youtube-dl
     # Tool for searching files/binaries from Nix packages
     nix-index
     dnsutils
     whois
     coreutils
     vbetool
     killall
     nethogs
     unrar
     # Gamin: a file and directory monitoring system
     fam
     # Basic image manipulation and handling stuff
     imagemagick
     ghostscript
     # Text editors
     vim
     # system clipboard support for vim
     xclip
     # VPN
     pptp
     openvpn
     # File format conversions
     pandoc
     pdf2svg
     # Screen brightness and temperature
     redshift
     # SSH filesystem
     sshfs-fuse
     # Yet another dotfile manager
     yadm
     # Password hash generator
     mkpasswd
     # Android
     jmtpfs
     gphoto2
     libmtp
     mtpfs
     nix-prefetch-git
     # Make NTFS filesystems (e.g., USB drives)
     ntfs3g
     # GUI for sound control
     pavucontrol
     # Bluetooth Support
     bluez
     # bluezFull # 20230213 Deprecated
     bluez-tools
     # Precisamos dele 
     pinentry-qt
     fontconfig
     glibcLocales
   ];
}

x-configuration.nix

{ pkgs, lib, ... }: 

{
   #Open ports for KDE Connect
   networking.firewall.allowedTCPPortRanges = [ { from = 1714; to = 1764; } ];
   networking.firewall.allowedUDPPortRanges = [ { from = 1717; to = 1764; } ];
  
   # Enable touchpad support.
   services.libinput.enable = true;
 
   # Enable the X11 windowing system.
   services.xserver.enable = true;
   # services.xserver.desktopManager.plasma5.enable = true; 

   # Use Plasma 6 w/ Wayland
   services.displayManager.defaultSession = "plasma";
   services.displayManager.sddm.enable = true;
   services.displayManager.sddm.theme = "breeze";
   services.displayManager.sddm.wayland.enable = true;
   services.desktopManager.plasma6.enable = true;
   services.desktopManager.plasma6.enableQt5Integration = false;
 
   # Window Manager
   programs.sway.enable = true;
   programs.sway.wrapperFeatures.gtk = true;
   # programs.hyprland.enable = true;
   # programs.hyprland.xwayland.enable = true;
   
   programs.dconf.enable = true;
 
   environment.sessionVariables = {
    KWIN_COMPOSE = "O2";
    KWIN_OPENGL_INTERFACE = "egl"; 
    NIXOS_OZONE_WL = "1";
   };
 
   # Keyboard settings on X
   # services.xserver.xkb.layout = "br";
   # services.xserver.xkb.variant = "abnt2";
 
   # Video backwards compatibility 
   hardware.opengl.driSupport32Bit = true;

   # Scanner settings
   services.ipp-usb.enable = true;
   hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];
   hardware.sane.brscan5 ={
     enable = true; 
     netDevices = {
       "MFP M130fw@CDQ/EscritÃrio" = { model = "MFP M130fw"; ip = "192.168.0.13"; };
       "SL-M4070FR@Adufms/Jornalismo" = { model = "SL-M4070FR"; ip = "192.168.0.150"; };
     };
   };
   # Online acoounts integration
   security.pam.services.sddm.enableKwallet = true;

   environment.variables.SSO_PLUGINS_DIR = ["/run/current-system/sw/lib/signon"];
   environment.variables.SSO_EXTENSIONS_DIR = ["/run/current-system/sw/lib/signon/extensions"];
   
   nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;
   programs.kdeconnect.enable = true;
   programs.chromium.enable = true;
   # programs.firefox.enable = true;   
   # programs.firefox.package = [ ]; -----------------------> IMPLEMENTAR

   # Fonts Settings.   
   fonts.fontDir.enable = true;
   fonts.enableDefaultPackages = true;
   fonts.enableGhostscriptFonts = true;
   fonts.fontconfig.enable = true;
   fonts.packages = with pkgs;
    [ dina-font
      fira-code
      fira-code-symbols
      font-awesome 
      freefont_ttf 
      gentium 
      inconsolata
      liberation_ttf 
      liberation-sans-narrow 
      libertine
      # mplus-outline-fonts
      noto-fonts
      noto-fonts-cjk
      noto-fonts-emoji
      open-sans 
      proggyfonts
      source-code-pro  
      symbola 
      ttf_bitstream_vera 
      ubuntu_font_family 
      unifont 
      ibm-plex
    ];
   
   #  Define how gpg will deal with pinentry" 
   programs.gnupg.agent = {
     enable = true;
     pinentryPackage = lib.mkForce pkgs.pinentry-qt;
   };

   # User packages for graphic environment.
   environment.systemPackages = with pkgs; with qt5; with libsForQt5; 
    [ kdePackages.plasma-desktop 
      wayland-utils
      kdePackages.kpeople
      kdePackages.wayland
      kdePackages.zanshin
      kdePackages.skanlite
      kdeFrameworks.kactivities
      kdeFrameworks.kactivities-stats
      # Password manager for KDE
      kdeFrameworks.kwallet 
      kdeFrameworks.kcmutils
      kdeFrameworks.kconfigwidgets
      kdeFrameworks.kio
      kdeFrameworks.kconfig      
      kdeFrameworks.bluez-qt
      kdeFrameworks.plasma-framework
      # This is needed for graphical dialogs used to enter GPG passphrases
      kdeplasma-addons
      
      # Plasma System Settings 
      kdePackages.systemsettings
      kdePackages.libkscreen
      kdePackages.kdecoration
      khotkeys
      kdePackages.libksysguard	
      kdePackages.plasma-nm
      kdePackages.plasma-pa
      polkit-kde-agent
      kdePackages.powerdevil
      kdePackages.sddm-kcm
      plasma-browser-integration
      plasma-integration
      plasma-desktop
      plasma-workspace
      libsForQt5.ksystemlog      
      libsForQt5.plasma-browser-integration
      xwaylandvideobridge
      glxinfo
      vulkan-tools
      playerctl
      wayland-utils
      aha

      # Screenshots
      kdeApplications.spectacle
      kdeApplications.kwalletmanager
      # Printing and scanning
      kdeApplications.print-manager
      kdeApplications.dolphin-plugins
      kdeApplications.kio-extras
      kdeApplications.knotes
      # Desktop sharing tool
      kdeApplications.krfb              
      kdeApplications.kaccounts-providers   
      kdeApplications.kaccounts-integration
      # kdeApplications.signon-kwallet-extension # 20230213 Missing
      kdeApplications.calendarsupport
      kdeApplications.eventviews
      kdeApplications.kcalutils

      # KDE apps
      kinfocenter
      kscreen
      konsole
      kcalc
      kfind
      kwalletcli
      # Allow automatic unlocking of kwallet if the same password. This seems to work without installing kwallet-pam.
      kwallet-pam
      # ssh-add prompts a user for a passphrase using KDE. Not sure if it is used by anything? ssh-add just asks passphrase on the console.
      ksshaskpass
      # GPG manager for KDE
      kgpg
      # Text editor
      kate
      # Archives (e.g., tar.gz and zip)
      ark
      # Browsers
      chromium
      dolphin
      # Office Suit
      libreoffice
      # Spell checker 
      sonnet
      	aspellDicts.en
      	aspellDicts.es
      	aspellDicts.fr
      	aspellDicts.pt_BR
      # Document readers
      okular
      # Media player
      pacman
      unrar
      # Player de Video
      vlc
      # PDF Handler
      pdfsam-basic

      kio-gdrive    
      signond                     
      xdg-desktop-portal-kde
      qoauth
      #gdrivefs
      aha
    ];
  }

journalctl
journalctl-lastday.log