2024-05-28 19:43:04 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-02-09 23:10:30 +02:00
|
|
|
source ./common.sh
|
|
|
|
|
|
|
|
requireGit
|
|
|
|
|
|
|
|
|
|
|
|
test_subdir_self_path() {
|
|
|
|
baseDir=$TEST_ROOT/$RANDOM
|
|
|
|
flakeDir=$baseDir/b-low
|
2024-06-04 23:33:24 +03:00
|
|
|
mkdir -p "$flakeDir"
|
|
|
|
writeSimpleFlake "$baseDir"
|
|
|
|
writeSimpleFlake "$flakeDir"
|
2023-02-09 23:10:30 +02:00
|
|
|
|
2024-06-04 23:33:24 +03:00
|
|
|
echo all good > "$flakeDir/message"
|
|
|
|
cat > "$flakeDir"/flake.nix <<EOF
|
2023-02-09 23:10:30 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
(
|
2024-06-04 23:33:24 +03:00
|
|
|
nix build "$baseDir"?dir=b-low --no-link
|
2023-02-09 23:10:30 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
test_subdir_self_path
|
|
|
|
|
|
|
|
|
|
|
|
test_git_subdir_self_path() {
|
|
|
|
repoDir=$TEST_ROOT/repo-$RANDOM
|
2024-06-04 23:33:24 +03:00
|
|
|
createGitRepo "$repoDir"
|
2023-02-09 23:10:30 +02:00
|
|
|
flakeDir=$repoDir/b-low
|
2024-06-04 23:33:24 +03:00
|
|
|
mkdir -p "$flakeDir"
|
|
|
|
writeSimpleFlake "$repoDir"
|
|
|
|
writeSimpleFlake "$flakeDir"
|
2023-02-09 23:10:30 +02:00
|
|
|
|
2024-06-04 23:33:24 +03:00
|
|
|
echo all good > "$flakeDir/message"
|
|
|
|
cat > "$flakeDir"/flake.nix <<EOF
|
2023-02-09 23:10:30 +02:00
|
|
|
{
|
|
|
|
outputs = inputs: rec {
|
|
|
|
packages.$system = rec {
|
|
|
|
default =
|
|
|
|
assert builtins.readFile ./message == "all good\n";
|
|
|
|
assert builtins.readFile (inputs.self + "/message") == "all good\n";
|
2023-02-22 04:28:30 +02:00
|
|
|
assert inputs.self.outPath == inputs.self.sourceInfo.outPath + "/b-low";
|
2023-02-09 23:10:30 +02:00
|
|
|
import ./simple.nix;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
(
|
2024-06-04 23:33:24 +03:00
|
|
|
cd "$flakeDir"
|
2023-02-09 23:10:30 +02:00
|
|
|
git add .
|
|
|
|
git commit -m init
|
|
|
|
# nix build
|
|
|
|
)
|
|
|
|
|
|
|
|
clientDir=$TEST_ROOT/client-$RANDOM
|
2024-06-04 23:33:24 +03:00
|
|
|
mkdir -p "$clientDir"
|
|
|
|
cat > "$clientDir"/flake.nix <<EOF
|
2023-02-09 23:10:30 +02:00
|
|
|
{
|
|
|
|
inputs.inp = {
|
|
|
|
type = "git";
|
|
|
|
url = "file://$repoDir";
|
|
|
|
dir = "b-low";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = inputs: rec {
|
|
|
|
packages = inputs.inp.packages;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
2024-06-04 23:33:24 +03:00
|
|
|
nix build "$clientDir" --no-link
|
2023-02-09 23:10:30 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
test_git_subdir_self_path
|