nixos-generators icon indicating copy to clipboard operation
nixos-generators copied to clipboard

`fileExtension` is wrong when setting `sdImage.compressImage = false`

Open DerRockWolf opened this issue 1 year ago • 0 comments

I'm not sure it this would be considered a bug.

If one adjust an existing format using formatConfigs and changes something that affects the resulting file extension, e.g.,:

{
  formatConfigs = {
    sd-aarch64 = {lib, ...}: {
      sdImage.compressImage = false;
    };
  };
}

and execute nix build .#nixosConfigurations.HOST.config.formats.sd-aarch64 the following error is thrown:

No target file found for sdImage format
Check the content of this build path: /nix/store/5dy36v03np7kwf58vdpciwmz3n4lwc61-nixos-sd-image-24.11.20240906.574d1ea-aarch64-linux.img

This can be fixed by overriding fileExtension with ".img*" (instead of ".img.*").

{
  formatConfigs = {
    sd-aarch64 = {lib, ...}: {
      sdImage.compressImage = false;
      fileExtension = lib.mkForce ".img*";
    };
  };
}

It took me quite some time to find what was wrong. Should we adjust the fileExtension default and maybe provide a few more details in the error message?

Code: https://github.com/nix-community/nixos-generators/blob/5ae384b83b91080f0fead6bc1add1cff8277cb3f/all-formats.nix#L42-L46

DerRockWolf avatar Sep 13 '24 09:09 DerRockWolf