aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/symlink-derivation.nix
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2024-04-11 13:41:49 +0200
committerK900 <me@0upti.me>2024-04-11 15:43:58 +0300
commit07b627cc6d1224df75ea2d4979c4c83bb67392f1 (patch)
treed4c46eb2c75b55154f78d9ef1cb1ffbbe84edf72 /tests/functional/symlink-derivation.nix
parentaeee22e5a17404b10dd14b5289e302eaf546e1aa (diff)
Merge pull request #10456 from NixOS/fixpermdeniedbind
Fix adding symlink to the sandbox paths (cherry-picked from commit da1e977bf48cff2a635034c85e7c13878e38efc2) Change-Id: I221c85a38180800ec6552d2e86a88df48398fad8
Diffstat (limited to 'tests/functional/symlink-derivation.nix')
-rw-r--r--tests/functional/symlink-derivation.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/functional/symlink-derivation.nix b/tests/functional/symlink-derivation.nix
new file mode 100644
index 000000000..17ba37424
--- /dev/null
+++ b/tests/functional/symlink-derivation.nix
@@ -0,0 +1,36 @@
+with import ./config.nix;
+
+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
+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}/)
+ )
+ echo "Success!" > $out
+ '';
+}