anchor.diff:      XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-$HOME/.config}
     '';
   
  -  startplasma =
  -    ''
  -      ${set_XDG_CONFIG_HOME}
  -      mkdir -p "''${XDG_CONFIG_HOME}"
  -
  -    ''
  -    + optionalString pulseaudio.enable ''
  -      # Load PulseAudio module for routing support.
  -      # See also: http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/
  -        ${pactl} load-module module-device-manager "do_routing=1"
  -
  -    ''
  -    + ''
  -      ${activationScript}
  -
  -      # Create default configurations if Plasma has never been started.
  -      kdeglobals="''${XDG_CONFIG_HOME}/kdeglobals"
  -      if ! [ -f "$kdeglobals" ]
  -      then
  -          kcminputrc="''${XDG_CONFIG_HOME}/kcminputrc"
  -          if ! [ -f "$kcminputrc" ]; then
  -              cat ${kcminputrc} >"$kcminputrc"
  -          fi
  -
  -          gtkrc2="$HOME/.gtkrc-2.0"
  -          if ! [ -f "$gtkrc2" ]; then
  -              cat ${gtkrc2} >"$gtkrc2"
  -          fi
  -
  -          gtk3_settings="''${XDG_CONFIG_HOME}/gtk-3.0/settings.ini"
  -          if ! [ -f "$gtk3_settings" ]; then
  -              mkdir -p "$(dirname "$gtk3_settings")"
  -              cat ${gtk3_settings} >"$gtk3_settings"
  -          fi
  +  startplasma = ''
  +    ${set_XDG_CONFIG_HOME}
  +    mkdir -p "''${XDG_CONFIG_HOME}"
  +  '' + optionalString config.hardware.pulseaudio.enable ''
  +    # Load PulseAudio module for routing support.
  +    # See also: http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/
  +      ${getBin config.hardware.pulseaudio.package}/bin/pactl load-module module-device-manager "do_routing=1"
  +  '' + ''
  +    ${activationScript}
  +
  +    # Create default configurations if Plasma has never been started.
  +    kdeglobals="''${XDG_CONFIG_HOME}/kdeglobals"
  +    if ! [ -f "$kdeglobals" ]; then
  +      kcminputrc="''${XDG_CONFIG_HOME}/kcminputrc"
  +      if ! [ -f "$kcminputrc" ]; then
  +          cat ${kcminputrc} >"$kcminputrc"
         fi
   
  -    '';
  +      gtkrc2="$HOME/.gtkrc-2.0"
  +      if ! [ -f "$gtkrc2" ]; then
  +          cat ${gtkrc2} >"$gtkrc2"
  +      fi
  +
  +      gtk3_settings="''${XDG_CONFIG_HOME}/gtk-3.0/settings.ini"
  +      if ! [ -f "$gtk3_settings" ]; then
  +          mkdir -p "$(dirname "$gtk3_settings")"
  +          cat ${gtk3_settings} >"$gtk3_settings"
  +      fi
  +    fi
  +  '';
   
   in
   
  
positive.code:       services.xserver.displayManager.sessionPackages = [ pkgs.libsForQt5.plasma5.plasma-workspace ];
  
        security.wrappers = {
          kcheckpass =
            {
              setuid = true;
              owner = "root";
              group = "root";
              source = "${getBin libsForQt5.kscreenlocker}/libexec/kcheckpass";
            };
          start_kdeinit =
            {
              setuid = true;
              owner = "root";
              group = "root";
              source = "${getBin libsForQt5.kinit}/libexec/kf5/start_kdeinit";
            };
          kwin_wayland =
            {
              owner = "root";
              group = "root";
              capabilities = "cap_sys_nice+ep";
              source = "${getBin plasma5.kwin}/bin/kwin_wayland";
            };
        };
  
        # DDC support
  
negative.code:     mkDefault mkIf mkMerge mkOption types;
  
    ini = pkgs.formats.ini { };
  
    gtkrc2 = writeText "gtkrc-2.0" ''
      # Default GTK+ 2 config for NixOS Plasma 5
  