mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
5d834c40d0
It would be incorrect to say that the `sourceInfo` has an `outPath` that isn't the root. `sourceInfo` is about the root, whereas only the flake may not be about the root. Thanks Eelco for pointing that out.
80 lines
1.6 KiB
Bash
80 lines
1.6 KiB
Bash
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
|