Config build fails due to boot.initrd.extraFiles "permission denied"

My configuration stopped building after some recent commit (which I assume might be nixos/stage-1: create initramfs /lib at build time · NixOS/nixpkgs@d9105c2 · GitHub)

With the offending line being

I’m pretty sure it should just point to the file directly rather than use pkgs.runCommandLocal, but that aside it is failing with mkdir: cannot create directory 'root/lib/firmware/edid': Permission denied, which didn’t seem to be a problem before.

The config works without that line just fine, but I want to figure out why it might be failing.

1 Like

im having the same issue, did you figure out anything more?

Nope couldn’t figure it out, atm I’m just relying on a forked nixos-hardware with that line commented out, works just fine.

Bumping because I’m a complete nixos novice and ran into the same issue. I have a monitor that requires a custom edid binary and so far everything looked good up until

boot.initrd.extraFiles."lib/firmware/edid/dell_u2412m_edid.bin".source = 
  pkgs.runCommandNoCC "dell-u2412-edid" {} "cp ${./dell_u2412m_edid.bin.src} $out";

For reference, I got this snippet from this github issue.

The result of sudo nixos-rebuild switch is

building Nix...
building the system configuration...
these 3 derivations will be built:
  /nix/store/k0f58n3pnk78vlxwqfbyp9wb9amxkq3f-initrd-linux-6.6.36.drv
  /nix/store/q4iyp68xwxn473r2w56b0s1w1nkg56q6-boot.json.drv
  /nix/store/16v6wlqzgla023gldcjgixh258xrf04x-nixos-system-beta-24.05.2472.c0d0be00d4ec.drv
building '/nix/store/k0f58n3pnk78vlxwqfbyp9wb9amxkq3f-initrd-linux-6.6.36.drv'...
mkdir: cannot create directory 'root/lib/firmware/edid': Permission denied
error: builder for '/nix/store/k0f58n3pnk78vlxwqfbyp9wb9amxkq3f-initrd-linux-6.6.36.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/16v6wlqzgla023gldcjgixh258xrf04x-nixos-system-beta-24.05.2472.c0d0be00d4ec.drv' failed to build

I might note that

hardware.firmware = [
  (pkgs.runCommandNoCC "dell-u2414-edid" { compressFirmware = false; } ''
   mkdir -p $out/lib/firmware/edid/
   cp ${./dell_u2412m_edid.bin.src} $out/lib/firmware/edid/dell_u2412m_edid.bin
   '')
];

gets the binary into /run/current-system/firmware/edid but ends up giving me error=-22 in the logs, hence why I think I need it in initrd.

Hoping this bump will catch the eye of someone more experienced.

EDIT: I should have paid more attention to the very last reply in this post on the topic.

From what I gather now, hardware.firmware is the preferred way of modifying firmware (who would have guessed,) so the last snippet was actually correct. It just turns out that error=-22 means firmware could not be found because the kernel is not compiled with other search paths (for a lack of a better term.) The snippet I reproduce here should do the trick:

  boot.kernelPatches = [
    {
      name = "edid-loader-fix-config";
      patch = null;
      extraConfig = ''
        FW_LOADER y
      '';
    }
  ];

From the linked github issue, it seems that nixos will eventually get this upstream sometime in the future.

In any case, this worked for me. Hoping this helps anyone else.