Skip to content

flake.nix: drop broken \. string escapes in sourceByRegex - #394

Merged
Sereja313 merged 1 commit into
serokell:masterfrom
yottanami:agent/66-fix-regex-escapes
Aug 10, 2026
Merged

flake.nix: drop broken \. string escapes in sourceByRegex#394
Sereja313 merged 1 commit into
serokell:masterfrom
yottanami:agent/66-fix-regex-escapes

Conversation

@yottanami

Copy link
Copy Markdown
Contributor

What

Drops the backslash from the four \. occurrences in flake.nix's sourceByRegex argument list.

Why

As reported in #388, Lix warns that \. inside a Nix double-quoted string is an ill-defined escape. Nix's string-literal escaping already drops the backslash for unrecognized escapes like \., so these strings were evaluating to a bare . at runtime all along — the regex engine never actually saw an escaped dot. Writing . directly produces the identical runtime string and silences the warning; no behavior change.

How this was tested

I don't have nix available in my sandbox, so I could not run nix build/the flake checks locally. This is a 1:1 textual substitution (dropping 4 backslash characters) with no structural change, so I'm relying on CI to confirm the flake still evaluates and builds.

Closes #388


AI disclosure: This PR (diff, commit message, and this description) was authored by an AI coding agent (Claude). I found no CONTRIBUTING.md or AI-usage policy in this repo to check against.

Inside a Nix double-quoted string, \. is an ill-defined escape that
Nix (and Lix, which now warns about it) resolves by dropping the
backslash, so these strings were already evaluating to a bare "."
at runtime -- the backslash never reached the regex engine. Removing
it silences the deprecation warning with no change in behavior.

Closes serokell#388
@Sereja313

Copy link
Copy Markdown
Member

Thank you!

@Sereja313
Sereja313 merged commit 1690127 into serokell:master Aug 10, 2026
14 checks passed
antonmosich added a commit to antonmosich/deploy-rs that referenced this pull request Aug 23, 2026
In nixlang "\." is escaped to just ".". That is, it does nothing. For
there to be a "\." in the resulting string, two backslashes are needed.
Lix on main now emits a warning in such cases. See the example nix repl
output:
	nix-repl> :p "Cargo\.lock"
	Cargo.lock

	nix-repl> :p "Cargo\\.lock"
	Cargo\.lock

PR serokell#394 removed four `\.` in regular expressions in flake.nix and replaced
them with `.`. While this is a non-breaking change in the sense that it
did not change the regular expressions, this is not the correct change.
`.` is a wildcard character in regular expressions so if you want to
match a `.` you _do_ need the \, which needs to appear twice in the nix
code to be escaped properly.
@antonmosich

Copy link
Copy Markdown

I want to point out that the regular expressions still don't match what they were intending to match. In order to actually match e.g. lib.rs but not cars as is currently the case, an additional backslash should have been added. That is .*\\.rs actually matches files ending in .rs, not just rs. This is implemented in #361.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake.nix has broken string escapes

3 participants