From 8b1ca49fef54ca0122bdd9b86e76781d577b47b1 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Wed, 18 Feb 2026 15:33:44 +0100 Subject: [PATCH] testing: migrate flakes/develop-r8854.sh Change-Id: Ib993d30edb97d7705acbf5d94f1831ffbe191d92 --- tests/functional/flakes/develop-r8854.sh | 45 ------------------------ tests/functional/meson.build | 1 - tests/functional2/flakes/test_develop.py | 37 ++++++++++++------- 3 files changed, 25 insertions(+), 58 deletions(-) delete mode 100644 tests/functional/flakes/develop-r8854.sh diff --git a/tests/functional/flakes/develop-r8854.sh b/tests/functional/flakes/develop-r8854.sh deleted file mode 100644 index 9cf4e7cf3..000000000 --- a/tests/functional/flakes/develop-r8854.sh +++ /dev/null @@ -1,45 +0,0 @@ -source ../common.sh - -# regression test for #8854 (nix develop fails when lockfile is ignored) - -clearStore -rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local - -# Create flake under test. -mkdir -p $TEST_HOME/t -cp ../shell-hello.nix ../config.nix $TEST_HOME/t -cat <$TEST_HOME/t/flake.nix -{ - inputs.nixpkgs.url = "$TEST_HOME/nixpkgs"; - outputs = {self, nixpkgs}: { - packages.$system.hello = (import ./config.nix).mkDerivation { - name = "hello"; - outputs = [ "out" "dev" ]; - meta.outputsToInstall = [ "out" ]; - buildCommand = ""; - }; - }; -} -EOF - -# Create fake nixpkgs flake. -mkdir -p $TEST_HOME/nixpkgs -cp ../config.nix ../nix-shell/shell.nix $TEST_HOME/nixpkgs -cat <$TEST_HOME/nixpkgs/flake.nix -{ - outputs = {self}: { - legacyPackages.$system.bashInteractive = (import ./shell.nix {}).bashInteractive; - }; -} -EOF - -cd $TEST_HOME/t - -git init . -echo flake.lock > .gitignore -git add config.nix shell-hello.nix flake.nix .gitignore - -# flake.lock is ignored, but nix develop should still not fail -nix develop .#hello <<<"true" - -clearStore diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 8cf8ff32c..dc7ae00d7 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -33,7 +33,6 @@ functional_tests_scripts = [ 'init.sh', 'test-infra.sh', 'flakes/flakes.sh', - 'flakes/develop-r8854.sh', 'flakes/mercurial.sh', 'flakes/follow-paths.sh', 'flakes/flake-in-submodule.sh', diff --git a/tests/functional2/flakes/test_develop.py b/tests/functional2/flakes/test_develop.py index ebe0680ba..a31c47e52 100644 --- a/tests/functional2/flakes/test_develop.py +++ b/tests/functional2/flakes/test_develop.py @@ -1,13 +1,14 @@ from testlib.fixtures.nix import Nix +from testlib.fixtures.git import Git from testlib.fixtures.file_helper import with_files, File, EnvTemplate, CopyFile from testlib.environ import environ -from testlib.utils import get_global_asset +from testlib.utils import get_global_asset, get_global_asset_pack from pathlib import Path import pytest system = environ.get("system") -files = { +flake = { "flake.nix": EnvTemplate(f"""{{ inputs.nixpkgs.url = "@HOME@/nixpkgs"; outputs = {{self, nixpkgs}}: {{ @@ -21,15 +22,15 @@ files = { }}"""), "config.nix": get_global_asset("config.nix"), "shell-hello.nix": CopyFile("assets/shell-hello.nix"), - "nixpkgs": { - "flake.nix": File(f"""{{ - outputs = {{self}}: {{ - legacyPackages.{system}.bashInteractive = (import ./shell.nix {{}}).bashInteractive; - }}; - }}"""), - "config.nix": get_global_asset("config.nix"), - "shell.nix": get_global_asset("shell.nix"), - }, +} +nixpkgs = { + "flake.nix": File(f"""{{ + outputs = {{self}}: {{ + legacyPackages.{system}.bashInteractive = (import ./shell.nix {{}}).bashInteractive; + }}; + }}"""), + "config.nix": get_global_asset("config.nix"), + "shell.nix": get_global_asset("shell.nix"), } @@ -38,7 +39,7 @@ def common_init(nix: Nix): nix.settings.add_xp_feature("nix-command", "flakes") -@with_files(files) +@with_files(flake | {"nixpkgs": nixpkgs}) class TestDevelop: def test_env_passthrough(self, nix: Nix): nix.env["ENVVAR"] = "a" @@ -107,3 +108,15 @@ class TestDevelop: .ok() ) assert result.stdout_s == "impure\n" + + +@with_files( + { + "t": flake | get_global_asset_pack(".git") | {".gitignore": File("flake.lock\n")}, + "nixpkgs": nixpkgs, + } +) +def test_ignoring_lockfile_does_not_break_develop(nix: Nix, files: Path, git: Git): + git(files / "t", "add", "config.nix", "shell-hello.nix", "flake.nix", ".gitignore") + + nix.nix(["develop", ".#hello"], cwd=files / "t").with_stdin(b"true").run().ok()