From cfaddae84dbca6b7b77d5f82b24d8dc86e25c901 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Tue, 24 Mar 2026 16:32:03 -0700 Subject: [PATCH] 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. --- nixos/tests/common/ec2.nix | 7 +++++-- nixos/tests/image-contents.nix | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nixos/tests/common/ec2.nix b/nixos/tests/common/ec2.nix index 504a2864fd5f..864afc63cb8b 100644 --- a/nixos/tests/common/ec2.nix +++ b/nixos/tests/common/ec2.nix @@ -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 diff --git a/nixos/tests/image-contents.nix b/nixos/tests/image-contents.nix index bfa4f08adc40..1f2dce786eec 100644 --- a/nixos/tests/image-contents.nix +++ b/nixos/tests/image-contents.nix @@ -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.