Please help with overlays

Hi!
I’m kind of new to nixos and don’t really understand how flakes work. I took the configuration from nixos-with-flakes and modified it to suit my needs.

Now I want to install HyprPanel and according to its guide I need to add

    pkgs = import nixpkgs {
	  inherit system;
	  # ...
	  overlays = [
        inputs.hyprpanel.overlay
	  ];

but I don’t know where to even add this code and any information about using overlays in flakes is not suitable because it uses a completely different general flakes.nix schema (it looks completely different and contains let ... in ... instead of nixos = nixpkgs.lib.nixosSystem ...).
Please help me to rewrite the config (maybe change the schema) and add this overlay.

flakes.nix
{
  description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    ironbar.url = "github:JakeStanger/ironbar";
    hyprpanel.url = "github:Jas-SinghFSU/HyprPanel";
    catppuccin.url = "github:catppuccin/nix";
  };

  outputs = inputs@{ nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      nixos = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.tim = import ./home.nix;
            home-manager.backupFileExtension = "old";
            home-manager.extraSpecialArgs = { inherit inputs; };
            nixpkgs.overlays = [ inputs.hyprpanel.overlay ];
          }
        ];
      };
    };
  };
}

You’re doing it right, that guide arguably advises you to commit an antipattern. There’s no need to explicitly eval nixpkgs unless you’re doing something specific, and doing so means not using the evaluation cache, and is therefore a little slower/more memory intensive.

So, don’t do what the guide says. Your current code achieves the same end goal and is arguably better practice. Where are you stuck?

Thanks for the reply!
I want to install the HyprPanel package. If I can do it without using overlays, ok. But I don’t know if I can do that. If I try to run this configuration, I get

error:
       … while calling the 'head' builtin

         at /nix/store/z71lmgd0ydfnax1b13zbrls5idf1y7ak-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/z71lmgd0ydfnax1b13zbrls5idf1y7ak-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

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

       error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "gnome-bluetooth" at /nix/store/s88mqkxsp5fl7wldp1n99vm21rai2agh-source/nix/default.nix:24'

And all I did was try to add this overlay and added pkgs.hyprpanel to my home.nix.

You’re using overlays just fine:

You’re even using home-manager.useGlobalPkgs, which means that the NixOS module pkgs (which you have applied the hyprpanel overlay to) is passed into home-manager as well. If it wasn’t working it’d tell you the package itself is missing, rather than a dependency.

What’s happening here is that hyprpanel’s overlay is built for nixpkgs unstable, looks like gnome-bluetooth was renamed from gnome.gnome-bluetooth. You’ll need to switch to unstable or do something more messy if you want to use this.

Hmmm…
Looks like I’m already using an unstable branch: nixpkgs.url = “github:nixos/nixpkgs/nixos-unstable”;.
Am I missing something?

When’s the last time you used nix flake update?

I assume I need to run nixos-rebuild switch because I am using the system-wide configuration. If I run nix flake update, I get

path '/home/tim' does not contain a 'flake.nix', searching up
error: could not find a flake.nix file

but I can’t run nixos-rebuild because now it’s broken.

And I think HyprPanel is the only package that requires gnome-bluetooth, so I can’t just remove it and run nixos-rebuild.

You need to run nix flake update in the directory with your flake. nixos-rebuild switch doesn’t update anything, and with flakes even adding the --update flag won’t do anything, because flakes manage their updates with the flake.lock file instead of channels.

When you run nixos-rebuild, nix will go to your flake to check what it should build, and your flake inputs are then used to actually do stuff - whatever flake.lock says nixpkgs is will be used to build your system. If flake.lock doesn’t change, your system does not change, and flake.lock is only ever updated with a call to nix flake update in the directory of you flake (or any of its child directories).

You likely haven’t actually updated at least since September 1st: gnome-bluetooth{,_1_0}: Move to by-name · NixOS/nixpkgs@b4c59a9 · GitHub

Thanks. Now I face some problems with amdvlk package. Will try to fix it and tell you if it works.

1 Like

After updating everything I got building with no errors, but the package is just not installed. As I found in HyprPanel issues, it’s better to install this kind of common way through using something like inputs.hyprpanel.homeManagerModules.default rather than through overlays. I’ve tried all the common attributes, but always get errors. Could you please check this and find which path should be used, if possible.

You could instead do:

{ inputs, pkgs, ... }: {
  home.packages = [
    inputs.hyprpanel.packages.${pkgs.system}.default
  ];
}

I indeed agree that this is better practice, since it allows you to avoid overlays, which means this is much less error prone. It also means the nixpkgs version your system uses is irrelevant as this defers to your dependency flake’s recursive nixpkgs, so an attribute rename won’t break stuff in the future (but you pay a disk space cost since stuff will need to be duplicated, unless you use the same thing you do for home-manager to override the nixpkgs hyprpanel uses, at which point you’re basically back to the former state).

The upsides and downsides of this approach aside, though, this won’t change anything about how the package works, so if you can’t spot it as “installed” now it also won’t be there after the change.

How are you determining whether it is installed? Where exactly did you add it to your config? How do you go through the nested imports to get to the place where you add hyprpaper? This sounds more like part of your configuration isn’t evaluated, or like you don’t fully understand how your configuration works and therefore don’t know what scope hyprpaper is actually “installed” in.


Ignore this text, I accidentally clicked another post before hitting reply, and now discourse marks this as spam if I don’t edit it.

Discourse is really really bad with firefox mobile.

I check if the package is installed by trying to run it (according to the guide, it can be run with the ags command). I think this is the right way, because it is a user-side application and it should be run by command.
Thanks. I guess it’s kind of near to the soultion. But if I add inputs.hyprpanel.packages.${pkgs.system}.default to my home.nix package list, I get

this error
error:
       … while calling the 'head' builtin

         at /nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source/lib/modules.nix:816:9:

          815|     in warnDeprecation opt //
          816|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          817|         inherit (res.defsFinal') highestPrio;

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

       error: The option `home-manager.users.tim.programs.hyprpanel' does not exist. Definition values:
       - In `/nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source/flake.nix':
           {
             enable = true;
           }
P.S. home.nix
{ inputs, config, pkgs, ... }:

{
  imports = [
    ./home/xdg.nix
    ./home/fish.nix
    ./home/eza.nix
    ./home/bottom.nix
    ./home/bat.nix
    ./home/alacritty.nix
    ./home/helix.nix
    ./home/git.nix
    ./home/zoxide.nix
    ./home/hyprland/hyprland.nix
    ./home/hyprland/hypridle.nix
    ./home/swaync.nix
    ./home/udiskie.nix
    ./home/ironbar.nix
    ./home/bemenu.nix
    ./home/obs.nix
    ./home/catppuccin.nix
  ];

  home = {
    username = "tim";
    homeDirectory = "/home/tim";
  };

  home.packages = [
    pkgs.ripgrep-all
    pkgs.wl-clipboard
    pkgs.hyprshot
    pkgs.swaybg
    pkgs.nautilus
    pkgs.eog
    pkgs.google-chrome
    pkgs.clapper
    pkgs.deadbeef
    pkgs.transmission_4-gtk
    pkgs.telegram-desktop
    pkgs.yt-dlp
    pkgs.prismlauncher
    pkgs.lutris
    pkgs.setzer
    # proton-ge-bin
    inputs.hyprpanel.packages.${pkgs.system}.default
  ];

  programs.hyprpanel = {
    enable = true;
  };

  home.pointerCursor = {
    gtk.enable = true;
    package = pkgs.bibata-cursors;
    name = "Bibata-Modern-Classic";
    size = 24;
  };

  home.stateVersion = "24.05";

  programs.home-manager.enable = true;
}

Ohhhh, I’m sorry, my bad. If I remove

 programs.hyprpanel = {
    enable = true;
 };

it builds with no errors. But you’re right, the programs still can’t be run via ags for some reason.

Yeah, the guide is wrong. This is the binary you’ve installed: HyprPanel/nix/default.nix at 2e66d801fd41d6c915286f52fbe500238b83c383 · Jas-SinghFSU/HyprPanel · GitHub

So… Just run hyprpanel.

I think this is just a NixOS-specific mistake in their docs, where if you follow the sections as listed on the website things go wrong. The NixOS docs do point out the binary name as part of the sample config.

1 Like

Oh my god. It does the trick! Thank you so much for your help!!