about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-02-17T22·48+0100
committersterni <sternenseemann@systemli.org>2021-02-18T00·07+0000
commit2469f0b423518ef4bee1641f04c3283bed374567 (patch)
treebfed6fbff4405243e32f3b9f46780579e43f9cff /nix
parentfa99c128f806d5015b6f4c31585c78f76a5e07df (diff)
fix(nix/readTree): make nixFileName only match .nix extensions r/2218
Nix unfortunately has terrible escaping syntax: If something is an
escape sequence it does not know, like \0, it just swallows the
backslash and returns the second character (byte) as is (yes,
"\0" == "0" is true). This created the following bug in nixFileName
which should have resulted in at least a parse error: "(.*)\.nix" is
the same as "(.*).nix" which meant that nixFileName matched anything
that is at least 4 characters long and ends in "nix". This lead to
readTree creating double attributes when directories are involved or
attributes for non-nix files.

Change-Id: Ibf3be2bd189d48881c82ee795c50151bfb365627
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2535
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'nix')
-rw-r--r--nix/readTree/default.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix
index 55da146be2dc..0c323bbdc8eb 100644
--- a/nix/readTree/default.nix
+++ b/nix/readTree/default.nix
@@ -44,7 +44,7 @@ let
       else imported;
 
   nixFileName = file:
-    let res = match "(.*)\.nix" file;
+    let res = match "(.*)\\.nix" file;
     in if res == null then null else head res;
 
   readTree = args: initPath: parts: