From d80f0fb15ac2c6970af22b226d645137a0702236 Mon Sep 17 00:00:00 2001 From: gustavderdrache Date: Wed, 21 May 2025 11:11:09 -0400 Subject: [PATCH] Add test for output warning to ensure stability Co-authored-by: Eelco Dolstra --- tests/functional/flakes/meson.build | 1 + tests/functional/flakes/trace-ifd.sh | 33 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/functional/flakes/trace-ifd.sh diff --git a/tests/functional/flakes/meson.build b/tests/functional/flakes/meson.build index 213c388a6..801fefc6f 100644 --- a/tests/functional/flakes/meson.build +++ b/tests/functional/flakes/meson.build @@ -33,6 +33,7 @@ suites += { 'debugger.sh', 'source-paths.sh', 'old-lockfiles.sh', + 'trace-ifd.sh', ], 'workdir': meson.current_source_dir(), } diff --git a/tests/functional/flakes/trace-ifd.sh b/tests/functional/flakes/trace-ifd.sh new file mode 100644 index 000000000..4879b9732 --- /dev/null +++ b/tests/functional/flakes/trace-ifd.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +source ./common.sh + +requireGit + +flake1Dir="$TEST_ROOT/flake" + +createGitRepo "$flake1Dir" +createSimpleGitFlake "$flake1Dir" + +cat > "$flake1Dir/flake.nix" <<'EOF' +{ + outputs = { self }: let inherit (import ./config.nix) mkDerivation; in { + drv = mkDerivation { + name = "drv"; + buildCommand = '' + echo drv >$out + ''; + }; + + ifd = mkDerivation { + name = "ifd"; + buildCommand = '' + echo ${builtins.readFile self.drv} >$out + ''; + }; + }; +} +EOF + +nix build --no-link "$flake1Dir#ifd" --option trace-import-from-derivation true 2>&1 \ + | grepQuiet 'warning: built .* during evaluation due to an import from derivation'