formats *: set filename to the fileending

This commit is contained in:
lassulus 2023-07-21 14:58:38 +02:00
parent 3c949b3842
commit efb2d33d4f
22 changed files with 23 additions and 15 deletions

View File

@ -31,9 +31,9 @@
# attrset of formats to be exposed under config.system.formats
formats = lib.flip lib.mapAttrs allConfigs (
formatName: conf: pkgs.runCommand formatName {} ''
formatName: conf: pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}${conf.config.filename}" {} ''
set -efu
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -wholename '${conf.config.filename}' -xtype f -print -quit)
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.filename}' -xtype f -print -quit)
ln -s "$target" "$out"
''
);

View File

@ -10,7 +10,7 @@
filename = lib.mkOption {
type = lib.types.str;
description = "Declare the path of the wanted file in the output directory";
default = "*";
default = "";
};
formatAttr = lib.mkOption {
type = lib.types.str;

View File

@ -4,4 +4,5 @@
];
formatAttr = "amazonImage";
filename = ".vhd";
}

View File

@ -4,4 +4,5 @@
];
formatAttr = "digitalOceanImage";
filename = ".qcow2.gz";
}

View File

@ -11,5 +11,5 @@
services.journald.console = "/dev/console";
formatAttr = "tarball";
filename = "*.tar.xz";
filename = ".tar.xz";
}

View File

@ -4,4 +4,5 @@
];
formatAttr = "googleComputeImage";
filename = ".raw.tar.gz";
}

View File

@ -4,5 +4,5 @@
];
formatAttr = "hypervImage";
filename = "*.vhdx";
filename = ".vhdx";
}

View File

@ -13,5 +13,5 @@
virtualisation.hypervGuest.enable = true;
formatAttr = "isoImage";
filename = "*.iso";
filename = ".iso";
}

View File

@ -13,5 +13,5 @@
systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"];
formatAttr = "isoImage";
filename = "*.iso";
filename = ".iso";
}

View File

@ -14,5 +14,5 @@
isoImage.makeUsbBootable = true;
formatAttr = "isoImage";
filename = "*.iso";
filename = ".iso";
}

View File

@ -4,4 +4,5 @@
];
formatAttr = "kubevirtImage";
filename = ".qcow2";
}

View File

@ -10,7 +10,7 @@
];
formatAttr = "linode";
filename = "*.img.gz";
filename = ".img.gz";
system.build.linode = import "${toString modulesPath}/../lib/make-disk-image.nix" {
inherit lib config pkgs;

View File

@ -9,5 +9,5 @@
];
formatAttr = "metadata";
filename = "*/tarball/*.tar.xz";
filename = ".tar.xz";
}

View File

@ -10,5 +10,5 @@
];
formatAttr = "tarball";
filename = "*/tarball/*.tar.xz";
filename = ".tar.xz";
}

View File

@ -16,4 +16,5 @@ else {
"${toString modulesPath}/../maintainers/scripts/openstack/openstack-image.nix"
];
formatAttr = "openstackImage";
filename = ".qcow2";
}

View File

@ -3,5 +3,5 @@
"${toString modulesPath}/virtualisation/proxmox-lxc.nix"
];
formatAttr = "tarball";
filename = "*/tarball/*.tar.xz";
filename = ".tar.xz";
}

View File

@ -3,4 +3,5 @@
"${toString modulesPath}/virtualisation/proxmox-image.nix"
];
formatAttr = "VMA";
filename = ".vma.zst";
}

View File

@ -35,4 +35,5 @@
};
formatAttr = "qcow";
filename = ".qcow2";
}

View File

@ -26,5 +26,5 @@
};
formatAttr = "raw";
filename = "*.img";
filename = ".img";
}

View File

@ -4,5 +4,5 @@
];
formatAttr = "virtualBoxOVA";
filename = "*.ova";
filename = ".ova";
}

View File

@ -4,4 +4,5 @@
];
formatAttr = "vmwareImage";
filename = ".vmdk";
}

View File

@ -169,7 +169,7 @@ out=$(nix-build "${nix_args[@]}" "${nix_build_args[@]}" -A "config.system.build.
if [[ -z $run ]]; then
# show the first file, ignoring nix-support
find "$out" -wholename "$filename" -xtype f -print -quit
find "$out" -name "*$filename" -xtype f -print -quit
else
runner=$(find "$out"/bin -type l -print -quit)
exec "$runner"