From 080950b0fea8df7377f84254728a049149b895d5 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Thu, 20 Mar 2025 13:28:05 +0800 Subject: [PATCH] tests/functional/flakes: Add test case for subflake locking This adds a test case where the lockfile of a relative path flake dependency is updated. It was reported by a user here: https://discourse.nixos.org/t/updating-local-subflakes-inputs-when-building-root-flake/61682 I think this test case relates to issue #7730. Because the issue is not resolved, this test case would fail without the `|| true` clause. (cherry picked from commit 1bc82d1c867463bc1973991c6819912c391013de) --- tests/functional/flakes/meson.build | 1 + .../flakes/relative-paths-lockfile.sh | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 tests/functional/flakes/relative-paths-lockfile.sh diff --git a/tests/functional/flakes/meson.build b/tests/functional/flakes/meson.build index b8c650db4..368c43876 100644 --- a/tests/functional/flakes/meson.build +++ b/tests/functional/flakes/meson.build @@ -28,6 +28,7 @@ suites += { 'commit-lock-file-summary.sh', 'non-flake-inputs.sh', 'relative-paths.sh', + 'relative-paths-lockfile.sh', 'symlink-paths.sh', 'debugger.sh', 'source-paths.sh', diff --git a/tests/functional/flakes/relative-paths-lockfile.sh b/tests/functional/flakes/relative-paths-lockfile.sh new file mode 100644 index 000000000..d91aedd16 --- /dev/null +++ b/tests/functional/flakes/relative-paths-lockfile.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +source ./common.sh + +requireGit + +# Test a "vendored" subflake dependency. This is a relative path flake +# which doesn't reference the root flake and has its own lock file. +# +# This might occur in a monorepo for example. The root flake.lock is +# populated from the dependency's flake.lock. + +rootFlake="$TEST_ROOT/flake1" +subflake="$rootFlake/sub" +depFlakeA="$TEST_ROOT/depFlakeA" +depFlakeB="$TEST_ROOT/depFlakeB" + +rm -rf "$rootFlake" +mkdir -p "$rootFlake" "$subflake" "$depFlakeA" "$depFlakeB" + +cat > "$depFlakeA/flake.nix" < "$depFlakeB/flake.nix" < "$subflake/flake.nix" < "$rootFlake/flake.nix" <