nixosTests: fix writeText warning when userData is null

makeEc2Test's userData parameter is required but image-contents.nix
passes null, triggering a deprecation warning from writeText. Make
userData optional (defaulting to null) and create an empty user-data
file when it's not provided.
This commit is contained in:
Philip Taron
2026-03-24 16:32:03 -07:00
parent 7e454277c3
commit cfaddae84d
2 changed files with 5 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ in
{
name,
image,
userData,
userData ? null,
script,
hostname ? "ec2-instance",
sshPublicKey ? null,
@@ -23,7 +23,10 @@ in
name = "metadata";
buildCommand = ''
mkdir -p $out/1.0/meta-data
ln -s ${pkgs.writeText "userData" userData} $out/1.0/user-data
${optionalString (
userData != null
) "ln -s ${pkgs.writeText "userData" userData} $out/1.0/user-data"}
${optionalString (userData == null) "touch $out/1.0/user-data"}
echo "${hostname}" > $out/1.0/meta-data/hostname
echo "(unknown)" > $out/1.0/meta-data/ami-manifest-path
echo "i-1234567890abcdef0" > $out/1.0/meta-data/instance-id

View File

@@ -51,7 +51,6 @@ in
makeEc2Test {
name = "image-contents";
inherit image;
userData = null;
script = ''
machine.start()
# Test that if contents includes a file, it is copied to the target.