aboutsummaryrefslogtreecommitdiff
path: root/tests/flakes/inputs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/flakes/inputs.sh')
-rw-r--r--tests/flakes/inputs.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/flakes/inputs.sh b/tests/flakes/inputs.sh
new file mode 100644
index 000000000..80620488a
--- /dev/null
+++ b/tests/flakes/inputs.sh
@@ -0,0 +1,80 @@
+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";
+ assert inputs.self.outPath == inputs.self.sourceInfo.outPath + "/b-low";
+ 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