aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/source-path.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-07 04:06:03 +0100
committereldritch horrors <pennae@lix.systems>2024-03-07 00:43:51 -0700
commitb14f88e0d46c61280a69da9559cf54cbce058eb5 (patch)
tree7b1c0be985b3f1aa7ae86ee1727d7a08c36c11a5 /src/libutil/source-path.hh
parent1342c8f18e48afd1577cfdc319c254ce7c42637e (diff)
Merge pull request #9985 from alois31/symlink-resolution
Restore `builtins.pathExists` behavior on broken symlinks (cherry picked from commit d53c8901ef7f2033855dd99063522e3d56a19dab) === note that this variant differs markedly from the source commit because we haven't endured quite as much lazy trees. Change-Id: I0facf282f21fe0db4134be5c65a8368c1b3a06fc
Diffstat (limited to 'src/libutil/source-path.hh')
-rw-r--r--src/libutil/source-path.hh31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/libutil/source-path.hh b/src/libutil/source-path.hh
index 54698de77..03cc998e3 100644
--- a/src/libutil/source-path.hh
+++ b/src/libutil/source-path.hh
@@ -13,6 +13,26 @@
namespace nix {
/**
+ * Note there is a decent chance this type soon goes away because the problem is solved another way.
+ * See the discussion in https://github.com/NixOS/nix/pull/9985.
+ */
+enum class SymlinkResolution {
+ /**
+ * Resolve symlinks in the ancestors only.
+ *
+ * Only the last component of the result is possibly a symlink.
+ */
+ Ancestors,
+
+ /**
+ * Resolve symlinks fully, realpath(3)-style.
+ *
+ * No component of the result will be a symlink.
+ */
+ Full,
+};
+
+/**
* An abstraction for accessing source files during
* evaluation. Currently, it's just a wrapper around `CanonPath` that
* accesses files in the regular filesystem, but in the future it will
@@ -121,11 +141,14 @@ struct SourcePath
}
/**
- * Resolve any symlinks in this `SourcePath` (including its
- * parents). The result is a `SourcePath` in which no element is a
- * symlink.
+ * Resolve any symlinks in this `SourcePath` according to the
+ * given resolution mode.
+ *
+ * @param mode might only be a temporary solution for this.
+ * See the discussion in https://github.com/NixOS/nix/pull/9985.
*/
- SourcePath resolveSymlinks() const;
+ SourcePath resolveSymlinks(
+ SymlinkResolution mode = SymlinkResolution::Full) const;
};
std::ostream & operator << (std::ostream & str, const SourcePath & path);