The option `programs.plasma.workspace.lib' does not exist

Hi!

I have the following problem, I want to make options specific to hostname, so I tried to create mkMerge with mkIf:

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

{
  programs.plasma.workspace = {
    lib.mkMerge = [
      (lib.mkIf ("${pkgs.inetutils}/bin/hostname" == "host-1") {
        wallpaperSlideShow = {
          path = ./wallpaper/Ghibli;
          interval = 1800; # seconds
        };
        wallpaperBackground.blur = true;
          wallpaperFillMode = "preserveAspectFit";
      })
      (lib.mkIf ("${pkgs.inetutils}/bin/hostname" == "host-2") {
        wallpaper = ./wallpaper/Lexus-LS400.jpg;
        wallpaperBackground.blur = true;
        wallpaperFillMode = "preserveAspectFit";
      })
      (lib.mkIf ("${pkgs.inetutils}/bin/hostname" == "host-3") {
        wallpaper = ./wallpaper/Lexus-LS400.jpg;
        wallpaperBackground.blur = true;
        wallpaperFillMode = "preserveAspectFit";
      })
    ];
  };
}

What is strange, I’ve managed to successfully create something similar in Hyprland config:

  wayland.windowManager.hyprland = {
    enable = true;
    xwayland.enable = true;
    settings = {
      lib.mkMerge = [
        (lib.mkIf ("${pkgs.inetutils}/bin/hostname" == "host-1") {
          monitor = [
            "eDP-1, 1366x768@60, 0x0, 1"
            "HDMI-A-1, 1920x1080@100, 0x0, 1"
          ];
        })
        (lib.mkIf ("${pkgs.inetutils}/bin/hostname" == "host-3") {
          monitor = "eDP-1, 1920x1080@120, 0x0, 1";
        })
      ];
  };

As far as I can see there is only one difference, that in number of mkIf statements.
However, when I try to rebuild home-manager I get this error:

[jeansib@host-1:~]$ home-manager switch 
error:
       … while evaluating a branch condition
         at /nix/store/alzxn3hjisc84hrlv44x6hni48crww26-source/lib/lists.nix:126:9:
          125|       fold' = n:
          126|         if n == len
             |         ^
          127|         then nul

       … while calling the 'length' builtin
         at /nix/store/alzxn3hjisc84hrlv44x6hni48crww26-source/lib/lists.nix:124:13:
          123|     let
          124|       len = length list;
             |             ^
          125|       fold' = n:

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: The option `programs.plasma.workspace.lib' does not exist. Definition values:
       - In `/nix/store/2a3x2hwxlflr7vd4fq25hg34641b1mgh-source/plasma-manager/wallpaper.nix':
           {
             mkMerge = [
               {
                 _type = "if";
                 condition = false;
           ...
[jeansib@host-1:~]$ 

Your issue is the = after the lib.mkMerge. You’re setting it as a value instead of calling the function. The same is true for your Hyprland config, but wayland.windowManager.hyprland.settings doesnt have explicitly defined options, so instead of failing its just writing the config file incorrectly.

Also, it would be easier and faster to check the hostname using config.networking.hostName. Edit: config may or may not be accessible since its a Nixpkgs option, not a home-mananager option, depends on how your configuration is set up.

I’m on my phone right now, I’ll post the corrected syntax when I’m at my PC.

wayland.windowManager.hyprland = {
  enable = true;
  xwayland.enable = true;
  settings = lib.mkMerge [
    (lib.mkIf (config.networking.hostName == "host-1") {
      monitor = [
        "eDP-1, 1366x768@60, 0x0, 1"
        "HDMI-A-1, 1920x1080@100, 0x0, 1"
      ];
    })
    (lib.mkIf (config.networking.hostName == "host-3") {
      monitor = "eDP-1, 1920x1080@120, 0x0, 1";
    })
  ];
};

programs.plasma.workspace = lib.mkMerge [
  (lib.mkIf (config.networking.hostName == "host-1") {
    wallpaperSlideShow = {
      path = ./wallpaper/Ghibli;
      interval = 1800; # seconds
    };
    wallpaperBackground.blur = true;
    wallpaperFillMode = "preserveAspectFit";
  })
  (lib.mkIf (config.networking.hostName == "host-2") {
    wallpaper = ./wallpaper/Lexus-LS400.jpg;
    wallpaperBackground.blur = true;
    wallpaperFillMode = "preserveAspectFit";
  })
  (lib.mkIf (config.networking.hostName == "host-3") {
    wallpaper = ./wallpaper/Lexus-LS400.jpg;
    wallpaperBackground.blur = true;
    wallpaperFillMode = "preserveAspectFit";
  })
];

These should work as expected. I’m not certain about the plasma one, are you importing some module for the programs.plasma.workspace option? It doesn’t exist in home-manager.

Btw, this is what was going to be written into your hyprland config with your original code

lib {
  mkMerge {
    monitor=eDP-1, 1366x768@60, 0x0, 1
    monitor=HDMI-A-1, 1920x1080@100, 0x0, 1
  }
}

Thank you for your answer, I think I understand it now. This plasma option is from a plasma-manager module:

I have managed to rebuild my system, but I have one more question, how can I insert mkMerge inside workspace={} if I want several options inside it?
I mean something like this:

programs.plasma.workspace = {
  mkMerge [mkIf etc...];
  anotherOption = true;
  yetAnotherOption = "foobar";
};
programs.plasma.workspace = mkMerge [
  (mkIf condition {
    ...
  })
  {
    anotherOption = true;
    yetAnotherOption = "foobar";
  }
];

Thank you very much!