all-formats: fix incorrect symlinks i.e. for sd-image formats

- output $out/$basename instead of $out being a symlink to the resulting file.
  This works around problem where we cannot predict the file extension of the output reliably,
  and therefore the direct symlink had the wrong extension in some cases.
- fix wrong file symlinked under $out for sd image formats
This commit is contained in:
DavHau 2024-07-28 16:03:16 +07:00 committed by Jörg Thalheim
parent 9a666f144f
commit b9c5637760

View File

@ -36,11 +36,14 @@
# attrset of formats to be exposed under config.system.formats
formats = lib.flip lib.mapAttrs allConfigs (
formatName: conf: pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}${conf.config.fileExtension}" {} ''
set -efu
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.fileExtension}' -xtype f -print -quit)
ln -s "$target" "$out"
''
formatName: conf: exposeConfig conf (
pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}" {} ''
set -efu
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.fileExtension}' -xtype f -print -quit)
mkdir $out
ln -s "$target" "$out/$(basename "$target")"
''
)
);
in {
_file = ./all-formats.nix;
@ -54,7 +57,7 @@ in {
options.formats = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
description = ''
Different target formats generated for this NixOS configuratation.
Different target formats generated for this NixOS configuration.
'';
};