Skip to content

Indented strings do not work with tabs #9117

Closed
@usagi-flow

Description

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.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions