2024-11-07 14:46:37 +02:00
|
|
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
2024-04-10 16:17:39 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
foo_in_store = builtins.toFile "foo" "foo";
|
|
|
|
foo_symlink = mkDerivation {
|
|
|
|
name = "foo-symlink";
|
|
|
|
buildCommand = ''
|
|
|
|
ln -s ${foo_in_store} $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
symlink_to_not_in_store = mkDerivation {
|
|
|
|
name = "symlink-to-not-in-store";
|
|
|
|
buildCommand = ''
|
|
|
|
ln -s ${builtins.toString ./.} $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2024-04-12 16:57:53 +03:00
|
|
|
{
|
|
|
|
depends_on_symlink = mkDerivation {
|
|
|
|
name = "depends-on-symlink";
|
|
|
|
buildCommand = ''
|
|
|
|
(
|
|
|
|
set -x
|
|
|
|
|
|
|
|
# `foo_symlink` should be a symlink pointing to `foo_in_store`
|
|
|
|
[[ -L ${foo_symlink} ]]
|
|
|
|
[[ $(readlink ${foo_symlink}) == ${foo_in_store} ]]
|
|
|
|
|
|
|
|
# `symlink_to_not_in_store` should be a symlink pointing to `./.`, which
|
|
|
|
# is not available in the sandbox
|
|
|
|
[[ -L ${symlink_to_not_in_store} ]]
|
|
|
|
[[ $(readlink ${symlink_to_not_in_store}) == ${builtins.toString ./.} ]]
|
|
|
|
(! ls ${symlink_to_not_in_store}/)
|
|
|
|
|
|
|
|
# Native paths
|
|
|
|
)
|
|
|
|
echo "Success!" > $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
test_sandbox_paths = mkDerivation {
|
|
|
|
# Depends on the caller to set a bunch of `--sandbox-path` arguments
|
|
|
|
name = "test-sandbox-paths";
|
|
|
|
buildCommand = ''
|
|
|
|
(
|
|
|
|
set -x
|
|
|
|
[[ -f /file ]]
|
|
|
|
[[ -d /dir ]]
|
2024-04-10 16:17:39 +03:00
|
|
|
|
2024-04-12 16:57:53 +03:00
|
|
|
# /symlink and /symlinkDir should be available as raw symlinks
|
|
|
|
# (pointing to files outside of the sandbox)
|
|
|
|
[[ -L /symlink ]] && [[ ! -e $(readlink /symlink) ]]
|
|
|
|
[[ -L /symlinkDir ]] && [[ ! -e $(readlink /symlinkDir) ]]
|
|
|
|
)
|
2024-04-10 16:17:39 +03:00
|
|
|
|
2024-04-12 16:57:53 +03:00
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
2024-04-10 16:17:39 +03:00
|
|
|
}
|