about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index b68a4f317189..d3317b67f62e 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -163,9 +163,9 @@ pub(crate) fn validate_name(s: &[u8]) -> Result<String, Error> {
 
     for (i, c) in s.iter().enumerate() {
         if c.is_ascii_alphanumeric()
+            || (*c == b'.' && i != 0) // can't start with a dot
             || *c == b'-'
             || *c == b'_'
-            || *c == b'.'
             || *c == b'+'
             || *c == b'?'
             || *c == b'='
@@ -221,13 +221,15 @@ mod tests {
         assert_eq!(example_nix_path_str, nixpath.to_string())
     }
 
-    /// This is the store path produced after `nix-store --add`'ing an
+    /// This is the store path rejected when `nix-store --add`'ing an
     /// empty `.gitignore` file.
+    ///
+    /// Nix 2.4 accidentally dropped this behaviour, but this is considered a bug.
+    /// See https://github.com/NixOS/nix/pull/9095.
     #[test]
     fn starts_with_dot() {
-        let nix_path_str = "fli4bwscgna7lpm7v5xgnjxrxh0yc7ra-.gitignore";
-        let nixpath = StorePath::from_bytes(nix_path_str.as_bytes()).expect("must succeed");
-        assert_eq!(".gitignore", nixpath.name);
+        StorePath::from_bytes(b"fli4bwscgna7lpm7v5xgnjxrxh0yc7ra-.gitignore")
+            .expect_err("must fail");
     }
 
     #[test]