symlinkJoin: support __structuredAttrs

Use the $paths bash array from __structuredAttrs.
Populate it from $pathsPath if passAsFile is used instead.
This commit is contained in:
Matt Sturgeon
2026-05-02 03:24:29 +01:00
parent 7aaa00e7cc
commit bc67c840d6
2 changed files with 22 additions and 1 deletions
@@ -559,7 +559,10 @@ rec {
paths = mapPaths (path: "${path}${stripPrefix}") paths;
buildCommand = ''
mkdir -p $out
for i in $(cat $pathsPath); do
if [ -n "''${pathsPath:-}" ] && [ -f "$pathsPath" ]; then
mapfile -d " " -t paths < "$pathsPath"
fi
for i in "''${paths[@]}"; do
${optionalString (!failOnMissing) "if test -d $i; then "}${lndir}/bin/lndir -silent $i $out${
optionalString (!failOnMissing) "; fi"
}
@@ -55,6 +55,24 @@ in
'';
};
symlinkJoin-structured-attrs = testEqualContents {
assertion = "symlinkJoin-structured-attrs";
actual = symlinkJoin {
__structuredAttrs = true;
name = "symlinkJoin-structured-attrs";
paths = [
foo
bar
baz
];
};
expected = runCommand "symlinkJoin-foo-bar-baz" { } ''
mkdir -p $out/{var/lib/arbitrary,etc/test.d}
ln -s {${foo},${bar}}/etc/test.d/* $out/etc/test.d
ln -s ${baz}/var/lib/arbitrary/baz $out/var/lib/arbitrary/
'';
};
symlinkJoin-strip-paths = testEqualContents {
assertion = "symlinkJoin-strip-paths";
actual = symlinkJoin {