aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-02-09 22:10:30 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-02-22 03:30:47 +0100
commit904a107d16b69f28b9d61c677eb27b953d421a54 (patch)
tree7d43c137adb9844e8fb5e5ed433da2353a1b5652 /tests
parent532c70f531a0b61eb0ad506497209e302b8250f3 (diff)
flakes: Ensure that `self.outPath == ./.`
Users expect `self` to refer to the directory where the `flake.nix` file resides.
Diffstat (limited to 'tests')
-rw-r--r--tests/flakes/inputs.sh79
-rw-r--r--tests/local.mk1
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/flakes/inputs.sh b/tests/flakes/inputs.sh
new file mode 100644
index 000000000..d6269fc59
--- /dev/null
+++ b/tests/flakes/inputs.sh
@@ -0,0 +1,79 @@
+source ./common.sh
+
+requireGit
+
+
+test_subdir_self_path() {
+ baseDir=$TEST_ROOT/$RANDOM
+ flakeDir=$baseDir/b-low
+ mkdir -p $flakeDir
+ writeSimpleFlake $baseDir
+ writeSimpleFlake $flakeDir
+
+ echo all good > $flakeDir/message
+ cat > $flakeDir/flake.nix <<EOF
+{
+ outputs = inputs: rec {
+ packages.$system = rec {
+ default =
+ assert builtins.readFile ./message == "all good\n";
+ assert builtins.readFile (inputs.self + "/message") == "all good\n";
+ import ./simple.nix;
+ };
+ };
+}
+EOF
+ (
+ nix build $baseDir?dir=b-low --no-link
+ )
+}
+test_subdir_self_path
+
+
+test_git_subdir_self_path() {
+ repoDir=$TEST_ROOT/repo-$RANDOM
+ createGitRepo $repoDir
+ flakeDir=$repoDir/b-low
+ mkdir -p $flakeDir
+ writeSimpleFlake $repoDir
+ writeSimpleFlake $flakeDir
+
+ echo all good > $flakeDir/message
+ cat > $flakeDir/flake.nix <<EOF
+{
+ outputs = inputs: rec {
+ packages.$system = rec {
+ default =
+ assert builtins.readFile ./message == "all good\n";
+ assert builtins.readFile (inputs.self + "/message") == "all good\n";
+ import ./simple.nix;
+ };
+ };
+}
+EOF
+ (
+ cd $flakeDir
+ git add .
+ git commit -m init
+ # nix build
+ )
+
+ clientDir=$TEST_ROOT/client-$RANDOM
+ mkdir -p $clientDir
+ cat > $clientDir/flake.nix <<EOF
+{
+ inputs.inp = {
+ type = "git";
+ url = "file://$repoDir";
+ dir = "b-low";
+ };
+
+ outputs = inputs: rec {
+ packages = inputs.inp.packages;
+ };
+}
+EOF
+ nix build $clientDir --no-link
+
+}
+test_git_subdir_self_path
diff --git a/tests/local.mk b/tests/local.mk
index b3135fd4d..743dab35d 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -4,6 +4,7 @@ nix_tests = \
flakes/mercurial.sh \
flakes/circular.sh \
flakes/init.sh \
+ flakes/inputs.sh \
flakes/follow-paths.sh \
flakes/bundle.sh \
flakes/check.sh \