Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indented strings do not work with tabs #9117

Closed
usagi-flow opened this issue Oct 7, 2023 · 2 comments
Closed

Indented strings do not work with tabs #9117

usagi-flow opened this issue Oct 7, 2023 · 2 comments
Labels

Comments

@usagi-flow
Copy link

usagi-flow commented Oct 7, 2023

Describe the bug

Indented strings do not work with tabs: The "smart indentation" as described in the documentation does not work:

This kind of string literal intelligently strips indentation from the start of each line. To be precise, it strips from each line a number of spaces equal to the minimal indentation of the string as a whole (disregarding the indentation of empty lines)

Steps To Reproduce

In a nix file, include something like this and indent with tabs:

	home.file."myfile".text = ''
		# This should not be indented in the generated file.
	'';

This results in the generation of myfile as follows, with unwanted indentation, with an unwanted empty line, and with trailing space on the empty line:

>	>	# This should not be indented in the generated file.
>	

(where > represents a tab character)

Expected behavior

"myfile" contains the text (without indentation and without additional empty line):

# This should not be indented in the generated file.

nix-env --version output

nix-env (Nix) 2.13.5

Additional context

I did come across #3759, but it was closed without an understandable reason, other than:

We can't change this because it would be incompatible (it could cause the result of evaluating a derivation to change).

(The author of that comment is against the use of tabs in general.)

Supporting tabs (and different newline formats) is an absolutely basic aspect of programming languages. Nix should not require any special handling/attention when working with tabs.

Priorities

Add 👍 to issues you find important.

@usagi-flow usagi-flow added the bug label Oct 7, 2023
@Artturin
Copy link
Member

Artturin commented Oct 9, 2023

Related #7834

@fricklerhandwerk
Copy link
Contributor

Closing as duplicate of #7834

Thanks @usagi-flow for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants