Repository navigation
fix: quote attribute names in nixCode and stop tack dropping input attributes - #144
Merged
Merged
Conversation
…tributes nixCode now quotes any attribute segment that is not a bare Nix identifier (lib.strings.escapeNixIdentifier), so inputs such as "nixpkgs-25.05", "1password" or "if" render as valid Nix in write-flake, write-inputs and write-unflake. Collapsed paths escape per segment, and null renders as null. The tack serializer carries rev and gitlab host in the synthesised url query, which is where tack reads them, and throws a named error for any input attribute pins.toml cannot represent (github host, ref/rev/host beside url, narHash, lfs, shallow, path, id, top-level follows, follows below a direct input) instead of dropping it.
vic
enabled auto-merge (squash)
October 12, 2026 20:08
vic
approved these changes
Oct 12, 2026
vic
reviewed
Oct 12, 2026
| collapse: name: value: | ||
| collapse: rawName: value: | ||
| let | ||
| name = lib.strings.escapeNixIdentifier rawName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"nixpkgs-25.05"used to render asnixpkgs-25.05.url = …, which broke the write-flake build (unexpected "05")."1password"and keywords such as"if"broke the same way. Each segment now goes throughlib.strings.escapeNixIdentifier. A collapsed path is escaped one segment at a time, soa."b.c".dkeeps three segments. Bare identifiers render exactly as before. This fixes write-flake, write-inputs and write-unflake, which all render throughnixCode.nullasnull. It used to produce{ foo = ; }.hostandrevonly from the url query, and readshostonly ongitlab:urls (src/source/mod.rsparse_query_fields,src/source/gitlab.rs). Itsfollowstable reaches a pin's direct inputs only (README "follows";assets/pins.tomlfield list). The serializer now putsrevand the gitlabhostinto the synthesised url, e.g.github:a/b/main?rev=abcorgitlab:a/b?host=gitlab.example.org. It throwstack serialize: input '<name>' sets <attrs>, which pins.toml cannot representfor anything it cannot carry:hoston a non-gitlab input,ref/rev/hostbesideurl,narHash,lfs,shallow,path,id, top-levelfollows, and follows nested below a direct input.Behaviour change: configs that set any of those attributes on a tack input used to lose them silently.
write-tacknow fails with the error above.Validation
dev/modules/unit-tests/nixCode.nixcover dashed, dotted, numeric-leading and keyword names, a nested dotted path, andnull. New cases intackSerialize.nixcover rev, gitlab host, github host, rev beside url, and nested follows.nix build ./dev#checks.x86_64-linux.nix-unitpasses 43/43.test-flake-quoted-nameruns write-flake with input"nixpkgs-25.05", then runsnix-instantiate --parseon the output and greps for the quoted name. Unpatched, it fails atflake-formattedwithunexpected "05". On the branch it passes.check-flake-filepasses, so the dev flake.nix regenerates byte-identically.nix run ./dev#fmt -- --cireports 0 changed.