Installing Hyprland's plugins package without Home-Manager

I am currently trying to install hyprland-plugins. The maintainer for a long time just had instructions for installing it using Home-Manager and flakes but recently began provideing instructions for NixOS users just using configuration.nix. According to the README in the GitHub repo linked to above, this is the required code block:

{ lib, pkgs, inputs, ... }:
with lib; let
  hyprPluginPkgs = inputs.hyprland-plugins.packages.${pkgs.system};
  hypr-plugin-dir = pkgs.symlinkJoin {
    name = "hyrpland-plugins";
    paths = with hyprPluginPkgs; [
      hyprexpo
      #...plugins
    ];
  };
in
{
  environment.sessionVariables = { HYPR_PLUGIN_DIR = hypr-plugin-dir; };
}

And then add this to hyprland.conf:

# load all the plugins you installed
exec-once = hyprctl plugin load "$HYPR_PLUGIN_DIR/lib/libhyprexpo.so"

That should be everything. But when I rebuild switch, here is the traceback:

Traceback
$ sudo nixos-rebuild switch --upgrade-all
unpacking 1 channels...
error:
       … while evaluating the attribute 'config'
         at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/modules.nix:360:9:
          359|         options = checked options;
          360|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          361|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/modules.nix:360:18:
          359|         options = checked options;
          360|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          361|         _module = checked (config._module);

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

       error: attempt to call something which is not a function but a set: { environment = «thunk»; }
       at /home/evangelist/nixoslaptop-configs/configuration.nix:17:1:
           16| in
           17| {
             | ^
           18|   environment.sessionVariables = { HYPR_PLUGIN_DIR = hypr-plugin-dir; };
warning: could not build a newer version of nixos-rebuild, using current version
building the system configuration...
error:
       … while evaluating the attribute 'config'
         at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/modules.nix:360:9:
          359|         options = checked options;
          360|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          361|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/modules.nix:360:18:
          359|         options = checked options;
          360|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          361|         _module = checked (config._module);

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

       error: attempt to call something which is not a function but a set: { environment = «thunk»; }
       at /home/evangelist/nixoslaptop-configs/configuration.nix:17:1:
           16| in
           17| {
             | ^
           18|   environment.sessionVariables = { HYPR_PLUGIN_DIR = hypr-plugin-dir; };
Command '['nix-build', '<nixpkgs/nixos>', '--attr', 'config.system.build.toplevel', '--no-out-link']' returned non-zero exit status 1.
nixoslaptop-configs on î‚  hypr-plugin-experiment [$!] 
$

What is the traceback trying to say in greater detail? And what would you ppl suggest I might try next?

Here is my configuration.nix source code permalink branched off on my personal GitHub repo.

Remove the code block you shared. Add the following code your config on line 138.

  environment.sessionVariables = {
    HYPR_PLUGIN_DIR = pkgs.symlinkJoin {
      name = "hyprland-plugins";
      paths = with hyprland-plugins.packages.${config.nixpkgs.buildPlatform.system}; [
        hyprexpo
        #...plugins
      ];
    };
  };

And then, on the 4th line, replace inputs with hyprland-plugins.

Finally, you need to add a channel called hyprland-plugins. I don’t use channels anymore so the following command is a “best effort” (sorry!):

$ sudo nix-channel --add https://github.com/hyprwm/hyprland-plugins/archive/main.tar.gz hyprland-plugins

Try rebuilding now.

Thank you for your reply. Since last time I have now removed my previous code block, as you suggested @thefossguy. I added the sessionVariables code snippet. Next I replaced inputs with hyprland-plugins at line 4. Finally I added the hyprland channel. Still no dice.

Here is my latest traceback
$ sudo nixos-rebuild switch --upgrade-all
error: filesystem error: read_symlink: No such file or directory [/nix/var/nix/profiles/per-user/root/channels/hyprland-plugins]
building the system configuration...
error:
       … while calling the 'head' builtin
         at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/attrsets.nix:1534:13:
         1533|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1534|             head values
             |             ^
         1535|           else

       … while evaluating the attribute 'value'
         at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/modules.nix:1086:7:
         1085|     // {
         1086|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1087|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `warnings':

       … while evaluating definitions from `/nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/nixos/modules/system/boot/systemd/tmpfiles.nix':

       … while evaluating the option `boot.initrd.systemd.storePaths':

       … while evaluating definitions from `/nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/nixos/modules/config/console.nix':

       … while evaluating the option `console.keyMap':

       … while evaluating the option `environment.sessionVariables':

       … while evaluating the module argument `hyprland-plugins' in "/home/evangelist/nixoslaptop-configs/configuration.nix":

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

       error: attribute 'hyprland-plugins' missing
       at /nix/store/z2hvk7vkk5h9s4nlpzvs90z9j9kjkzc9-nixos/nixos/lib/modules.nix:654:66:
          653|       extraArgs = mapAttrs (
          654|         name: _: addErrorContext (context name) (args.${name} or config._module.args.${name})
             |                                                                  ^
          655|       ) (functionArgs f);
Command '['nix-build', '<nixpkgs/nixos>', '--attr', 'config.system.build.toplevel', '--no-out-link']' returned non-zero exit status 1.

What is this traceback trying to say now and what could we try next?

Here is the latest reference to the changes to my configuration.nix source code via my GitHub via permalink.

I see, I made some mistakes in understanding before. It appears that all the plugins from the hyprland-pulgins repository are already available in nixpkgs.

From the 4th line, please remove hyprland-plugins,

And, on line 126, please replace hyprland-plugins.packages.${config.nixpkgs.buildPlatform.system} with pkgs.hyprlandPlugins

We also don’t need a channel called hyprland-plugins. So let’s remove it with the following command:

$ sudo nix-channel --remove hyprland-plugins

Can you try rebuilding with this change?

That worked! Thank you, @thefossguy. I am able to install plugins now.

Not sure why the maintainer on the official GitHub repo for this project has incorrect installation instructions for NixOS. Maybe I should submit an Issue and PR.

That’s because the instructions are about how to use the flake offered by that repository. Ideally, it should have a note that says “Using this repository is not necessary as packages are included in nixpkgs. Use this repository only if you want the very latest version of packages.”

1 Like