testing: migrate flakes/develop-r8854.sh
Change-Id: Ib993d30edb97d7705acbf5d94f1831ffbe191d92
This commit is contained in:
@@ -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 <<EOF >$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 <<EOF >$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
|
||||
@@ -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',
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user