Hyprland: error adding a file to a tree builder

When adding hyprland to nix configuration, the system no longer builds.

error:
       … while calling the 'head' builtin
         at /nix/store/k8nkf470zpidpa5nh76lh2x6rxfzpwa4-source/lib/attrsets.nix:1574:11:
         1573|         || pred here (elemAt values 1) (head values) then
         1574|           head values
             |           ^
         1575|         else

       … while evaluating the attribute 'value'
         at /nix/store/k8nkf470zpidpa5nh76lh2x6rxfzpwa4-source/lib/modules.nix:846:9:
          845|     in warnDeprecation opt //
          846|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          847|         inherit (res.defsFinal') highestPrio;

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

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

       … while evaluating the option `warnings':

       … while evaluating definitions from `/nix/store/k8nkf470zpidpa5nh76lh2x6rxfzpwa4-source/nixos/modules/config/xdg/portal.nix':

       … while evaluating the option `xdg.portal.configPackages':

       … while evaluating definitions from `/nix/store/k8nkf470zpidpa5nh76lh2x6rxfzpwa4-source/nixos/modules/programs/wayland/hyprland.nix':

       … while evaluating the option `programs.hyprland.package':

       … while evaluating definitions from `/nix/store/717ak5aizpfwqgpazzlgkqh6ywx4md5k-source/hosts/nitro/configuration.nix':

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

       error: adding a file to a tree builder: failed to insert entry: invalid object specified - VERSION

here are my config files (i’m kinda new to nix)
and here is the full stack trace

What’s the output of nix --version?
Also, can you try again after running nix flake update?

Nix version:
nix (Nix) 2.24.12

I did update my flake and it still did not work.

You’re probably running into fetchTarball fails after downloading proton-ge · Issue #10575 · NixOS/nix · GitHub, though that’s odd if you’re on nix 2.24. I would try using a shell with nix 2.18, e.g. nix shell 'nixpkgs#nixVersions_2_18' then rebuild. Or, use lix, which doesn’t suffer from this issue.

I did see that post and tried to use a different nix version. But it’s weird, this error just came out of nowhere. I used hyprland normally before.

I have absolutely no idea of what’s causing this. It apparently is a git error. Should I make an issue in the Nixpkgs github? Maybe it’s the hyprland’s repo fault?

It’s a nix bug.

And did that work or not?

Nope.

So, where should I report this?

Well for completeness: what commands did you run to get a different nix and update your lockfile?

I just ran nix flake update to update lock file. I tried using nix run nixpkgs#nixVersions.nix_2_20 -- flake update to try a different nix version but to no avail.

Also, the problem seems to come up while downloading this package:

Ah, sorry, I wasn’t specific; you happened to choose the version where the bug started.
Use nix 2.18:

nix run github:nixos/nixpkgs/nixos-24.11#nixVersions.nix_2_18 -- flake update

(EDIT: actually I did mention 2.18 above :sweat_smile:)

I think I had tried 2.18 before so I forgot to mention it hahaha
Well, I tried again and the error still persists.

I’m out of ideas :pensive:

Does even lix have that issue?

Also to be clear, are you getting the error on nix flake update or when rebuilding?

Rebuilding. Updating the flake has always worked fine.

Haven’t tried it. Is there any advantage/disadvantage to using it?

Then the nix run nix... flake update command won’t do anything to help.

Try

nix run github:nixos/nixpkgs/nixos-24.11#nixVersions.nix_2_18 -- build /path/to/your/config/dir#nixosConfigurations.$(hostname).config.system.build.toplevel
sudo result/bin/switch-to-configuration switch

EDIT: to be clear, only replace /path/to/your/config/dir, everything else is literal.

Yeah, but maybe it was something in the lock file, idk.
I have switched to lix here, when I get home I’ll try again.

nix run github:nixos/nixpkgs/nixos-24.11#nixVersions.nix_2_18 -- build /path/to/your/config/dir#nixosConfigurations.$(hostname).config.system.build.toplevel
sudo result/bin/switch-to-configuration switch

Will try this aswell.

I’ve been intermittently getting the exact same error, and what fixes it for me is using nh to build my system. So instead of running nixos-rebuild, I do this:

$ nh os switch

(Except I’ve got that bound to an oss alias)

For me, that builds and activates the system without errors. What sort of magic nh is doing to achieve that, I do not know. I haven’t looked at what command(s) it’s running under the hood.

I installed nh by adding this to my system config:

programs.nh = {
  enable = true;
  clean.enable = true;
  flake = "/home/dan/dot";
};