Problem with setting wallpaper in plasma-manager module

Hi!

I have a nixos “cluster” of three laptops (host-1, -2 and -3), I’m trying to implement different wallpaper based on hostname using home-manager with plasma-manager module. This is my config:

programs.plasma = {
  enable = true;
    workspace = lib.mkMerge [
      (lib.mkIf ("${pkgs.inetutils}/bin/hostname" == "host-1") {
        wallpaperSlideShow = {
          path = ./wallpaper/Ghibli;
          interval = 1; # 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";
      })
    ];
  };
};

It lets me rebuild home, but doesn’t set desired wallpaper… Any idea how to trubleshoot it?

Best,
Miro

FYI something like this:

    workspace = { 
      wallpaper = ./wallpaper/Lexus-LS400.jpg;
    };

works just fine.

This will return the path to the hostname binary, not the machine’s actual hostname.

If you are using Home Manager as a NixOS module you should be able to add { osConfig, ... }: and access the hostname via osConfig.networking.hostName, otherwise your only option is having a separate Home Manager configuration for each machine.

Thank you, this is what I was looking for. Now with this config:

    workspace = lib.mkMerge [
    (lib.mkIf (osConfig.networking.hostName == "host-1") {
      wallpaperSlideShow = {
        path = ./wallpaper/Ghibli;
        interval = 5; # seconds
      };
      wallpaperBackground.blur = true;
      wallpaperFillMode = "preserveAspectFit";
    })
    (lib.mkIf (osConfig.networking.hostName == "host-2") {
      wallpaper = ./wallpaper/Lexus-LS400.jpg;
      wallpaperBackground.blur = true;
      wallpaperFillMode = "preserveAspectFit";
    })
    (lib.mkIf (osConfig.networking.hostName == "host-3") {
      wallpaper = ./wallpaper/Lexus-LS400.jpg;
      wallpaperBackground.blur = true;
      wallpaperFillMode = "preserveAspectFit";
    })
    {
      clickItemTo = "open";
      colorScheme = "BreezeDark";
    }
  ];

I get this error:

       … while evaluating the attribute 'condition'
         at /nix/store/1728d3jg85mkz2w2cvk6vi74i30fn6x7-source/lib/modules.nix:1175:15:
         1174|     { _type = "if";
         1175|       inherit condition content;
             |               ^
         1176|     };

       … while selecting an attribute
         at /nix/store/g7pvb6ixxk6ajbw5ra8f8v3i7bjsn74q-source/plasma-manager/plasma-manager.nix:90:16:
           89|     workspace = lib.mkMerge [
           90|     (lib.mkIf (osConfig.networking.hostName == "host-1") {
             |                ^
           91|       wallpaperSlideShow = {

       error: expected a set but found null: null

(This is the output of home-manager switch --verbose --show-trace command)
What does it mean that it expects a set?

Then you aren’t using Home Manager as a NixOS module, try the second option I gave you.

I’m not familiar with Home Manager in standalone mode, but I think you can pass --file ./path/to/config.nix to home-manager to specify which configuration you want to use, like this:

home-manager switch --file ./host-1.nix --verbose --show-trace

You can configure each host separately and add your common settings in imports:

# host-1.nix
{
  # Common configuration
  imports = [ ./home.nix ];

  # Specific to "host-1"
  programs.plasma = { ... };
}

Okay, thanks.

What are the advantages of using home-manager as a module?

One command to build your system and user config, and you can read values from your system config to control your user config.

Can any user without sudo privileges modify his home-manager module file?

That’s up to you. Set the file and folder permissions as you wish.

You just made me switch;)