singularity-tools: enable __structuredAttrs and pass contents directly (#358723)

This commit is contained in:
Philip Taron 2024-11-25 10:05:42 -08:00 committed by GitHub
commit 62742e9d5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,12 +51,14 @@ lib.makeExtensible (final: {
result = vmTools.runInLinuxVM (
runCommand "${projectName}-image-${name}.sif"
{
__structuredAttrs = true;
nativeBuildInputs = [
singularity
e2fsprogs
util-linux
];
strictDeps = true;
inherit contents;
layerClosure = writeClosure ([ bashInteractive ] ++ runScriptReferences ++ contents);
preVM = vmTools.createEmptyImage {
size = diskSize;
@ -89,12 +91,7 @@ lib.makeExtensible (final: {
cp -ar "$f" "./$f"
done < "$layerClosure"
# TODO(@ShamrockLee):
# Once vmTools.runInLinuxVMm works with `__structuredAttrs = true` (#334705),
# set __structuredAttrs = true and pass contents as an attribute
# so that we could loop with `for c in ''${contents[@]}`
# instead of expanding all the paths in contents into the Bash string.
for c in ${lib.escapeShellArgs contents} ; do
for c in "''${contents[@]}"; do
for f in "$c"/bin/* ; do
if [ ! -e "bin/$(basename "$f")" ] ; then
ln -s "$f" bin/