Nixos-rebuild switch constantly fails

Hello,
As per title, I’ve tried to run nixos-rebuild switch multiple times since yesterday, and it keeps failing. Today, I got the error linked to Sonic Pi which I shared below. Yesterday, it was due to Gimp.

Is it possible both packages became somehow corrupted (and, if so, how do I investigate?), or there is another underlying problem going on here?

warning: updating lock file '"/etc/nixos/flake.lock"':
• Updated input 'home-manager':
    'github:nix-community/home-manager/7c78e592a895f2f1921f0024848fe193e2f8518e?narHash=sha256-RXxejsGIWtJ5rJKLAm8Kh159euZHPMi7CtbOoHLsm2c%3D' (2025-07-17)
  → 'github:nix-community/home-manager/d0300c8808e41da81d6edfc202f3d3833c157daf?narHash=sha256-irfg7lnfEpJY%2B3Cffkluzp2MTVw1Uq9QGxFp6qadcXI%3D' (2025-07-18)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/62e0f05ede1da0d54515d4ea8ce9c733f12d9f08?narHash=sha256-JHQbm%2BOcGp32wAsXTE/FLYGNpb%2B4GLi5oTvCxwSoBOA%3D' (2025-07-14)
  → 'github:nixos/nixpkgs/6e987485eb2c77e5dcc5af4e3c70843711ef9251?narHash=sha256-RKwfXA4OZROjBTQAl9WOZQFm7L8Bo93FQwSJpAiSRvo%3D' (2025-07-16)
building the system configuration...
error: builder for '/nix/store/9dss5c0ddh1mwl0fazcz72vx3w5cdrjs-sonic-pi-4.5.1.drv' failed with exit code 1;
       last 25 log lines:
       > [100%] Built target libsp_link
       > [ 98%] Performing install step for 'sp_link'
       > [100%] Built target libsp_link
       > Install the project...
       > -- Install configuration: ""
       > -- Installing: /build/source/app/server/beam/tau/priv/libsp_link.so
       > [ 99%] Completed 'sp_link'
       > [ 99%] Built target sp_link
       > [ 99%] Linking CXX executable sonic-pi
       > [100%] Built target sonic-pi
       > Compiling Erlang/Elixir files...
       > warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell) or set the ELIXIR_ERL_OPTIONS="+fnu" environment variable
       > warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell) or set the ELIXIR_ERL_OPTIONS="+fnu" environment variable
       > ==> logger_file_backend
       > Compiling 1 file (.ex)
       > Generated logger_file_backend app
       > ==> decimal
       > Compiling 4 files (.ex)
       > Generated decimal app
       > ==> mime
       > Compiling 1 file (.ex)
       > Generated mime app
       > ==> tau
       > escript: Not an archive file
       > ** (Mix) Could not compile dependency :telemetry, "/nix/store/zzgvmbmj7pal2jvjfqjdd8mnfckgd1gf-rebar3-3.25.0/bin/rebar3 bare compile --paths /build/source/app/server/beam/tau/_build/prod/lib/*/ebin" command failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile telemetry --force", update it with "mix deps.update telemetry" or clean it with "mix deps.clean telemetry"
       For full logs, run:
         nix log /nix/store/9dss5c0ddh1mwl0fazcz72vx3w5cdrjs-sonic-pi-4.5.1.drv
error: 1 dependencies of derivation '/nix/store/g9kh1c74slp1fi27x5i89g75l6kiynyi-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xrhv97lv55rr1igbggplnmbqvrs1ql4i-nixos-system-nixos-25.11.20250716.6e98748.drv' failed to build
Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '/etc/nixos#nixosConfigurations."nixos".config.system.build.toplevel' --no-link' returned non-zero exit status 1.

Removing both gimp and sonic-pi from configuration.nix, made the command run smoothly and quickly. However, I need and want both those apps.
How can I find out what’s going on?

This would be pretty unlikely.
But just to be sure can you run following command:

nix-store --verify --check-contents --repair

and than try again

The command ran for about three minutes, then I did the rebuild and got the same error as the one posted above.
What’s the insight?

Is it still the same package that fails? If so what happens when you remove that package from your config.
Also could you try a compiling benchmark to rule out any compiling issues (or even hardware issues). For that you can try out this: GitHub - phoronix-test-suite/phoronix-test-suite: The Phoronix Test Suite open-source, cross-platform automated testing/benchmarking software.
This is also in the nixpkgs

Running the same command with the same config will give the same result, not sure why we’re expecting anything different here. Nor am I sure why we’re talking about corruption or hardware issues, if sonic-pi is broken, just report it in the nixpkgs github repo.

And why did you remove gimp from your config?

sonic-pi is currently broken on unstable
https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.sonic-pi.x86_64-linux

gimp was broken
https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.gimp.x86_64-linux
fixed at: gimp: fix build with gettext 0.25 by wegank · Pull Request #425710 · NixOS/nixpkgs · GitHub

should be in unstable: Nixpkgs PR #425710 ("gimp: fix build with gettext 0.25") progress

I don’t think your nix store is at fault here.

2 Likes

Thank you. That’s what I was trying to understand and wasn’t sure where to check.
When something like this happen, is there a way to skip the update of the broken package(s) and keep on doing the rebuild with the others?

There isn’t a way to “skip” packages during the rebuild per se, because your system is always built from a specific nixpkgs commit (currently the one in which sonic-pi is broken). You could however take the packages from different revisions of nixpkgs. One way you could do that is by specifying another instance of nixpkgs at an earlier commit, where sonic-pi still built successfully and take the package from there.

Something like

inputs = {
    nixpkgs-older.url = "github:nixos/nixpkgs?ref=<your-ref>";
}
outputs = {...}@inputs

environment.systemPackages = [
    inputs.nixpkgs-older.legacyPackages.${pkgs.system}.sonic-pi
];

Do note that doing this seems to be generally discouraged, because it apparently evaluates nixpkgs twice, which makes your rebuild take longer IIUC.

As an aside: I cannot recommend the userscript at link enough. Just make sure to add the branch nixos-unstable in there. It’s the best way to track PR statuses in nixpkgs IMO.

2 Likes

This is very valuable knowledge. Thanks for sharing. :blush:
I will look into both in detail this weekend.
I will close this thread now then. Truly appreciated everyone’s help.

Before you do that, can you answer one question? Are you using "github:NixOS/nixpkgs/nixpkgs-unstable" or "github:NixOS/nixpkgs/nixos-unstable" for your nixpkgs input url?

I’m using this one.
Why?

Because I remember reading that nixpkgs-unstable goes through slightly fewer tests than nixos-unstable.

1 Like

It’s mostly the tests that assert the OS boots properly. It wouldn’t affect end-user software like this, buy yes, when using nixos use the nixos-* branches.

1 Like