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