volta icon indicating copy to clipboard operation
volta copied to clipboard

Is there no command line upgrade?

Open clddup opened this issue 9 months ago • 1 comments

clddup avatar Feb 18 '25 10:02 clddup

I think it's better to be opinionated and discourage/disallow the use of tabs. If there are places in Nixpkgs that use tabs, they should be fixed.

edolstra avatar Jun 03 '19 07:06 edolstra

I think it's better to be opinionated and discourage/disallow the use of tabs. If there are places in Nixpkgs that use tabs, they should be fixed.

What's the benefit of discouraging tabs?

7c6f434c avatar Jun 03 '19 07:06 7c6f434c

To ensure consistency.

edolstra avatar Jun 03 '19 07:06 edolstra

I know a number of languages that recommend using spaces to indent, but none that outright require it.

As far as I'm aware, this is the only place where the nix language cares about whitespace. I personally like to (ab)use elastic tabstops, so having to switch only when writing indented strings in personal derivations is a bit annoying. It isn't breaking anything, but it does make writing .nix feel a little awkward compared to other languages. Maybe some sort of opinionated nix fmt instead would work to ensure consistency across nixpkgs? It seems like some maintainers are already using a nix formatter, since that would explain the packages mentioned above using tabs in indented strings but spaces everywhere else (most tellingly in the ignored last line of indented strings).

Plus, since this would make the behavior of indented strings work consistently with tabs, a formatter would be able to replace tabs with spaces in indented strings without changing behavior.

cslamber avatar Jun 03 '19 11:06 cslamber

Somehow my cursor hit the close button when I closed my laptop. Reopened

cslamber avatar Jun 03 '19 11:06 cslamber

@edolstra could you please expand a bit? Because in another place, you opposed the simplest available way to ensure syntactic consistency…

7c6f434c avatar Jun 03 '19 13:06 7c6f434c

@7c6f434c On the contrary, I'm all in favor of consistent use of URLs.

edolstra avatar Jun 03 '19 17:06 edolstra

Well, at least with spaces and tabs we hopefully won't get a limitation that makes the encouraged option inevitably suboptimal for the most frequent use case.

7c6f434c avatar Jun 03 '19 20:06 7c6f434c

If tabs aren't stripped, I suggest updating https://github.com/NixOS/nix/blob/6924bdf2bf8f50f2e6ec5d490571594450aba13a/doc/manual/expressions/language-values.xml#L113-L115

, since tabs are indentation, but multiline literals in tab-formatted file don't work as I would expect from reading that.

Maybe even make tabs a syntax error, if using them is going to subtly change the meaning of expressions. (I just spent a few minutes figuring out why two identical-looking pieces of code had different outputs...)

scintill avatar Jun 25 '19 02:06 scintill

Nix is also used in user configurations, that don't need to adhere to nixpkgs guidelines. So for a better user experience, I would kindly request that this gets merged.

For consistency in nixpkgs, the CI tools can check that edited files contain only spaces for indentation.

wmertens avatar Jun 28 '19 12:06 wmertens

This has been confusing me for years because I was wondering why the docs said that indentation would be stripped however I was still seeing indentation in my output. This should definitely fixed. Enforcing an indentation style on nixpkgs can be done with a simple linter (and be more effective) however there is no reason to prevent tabs for personal nix configs especially when it is a source of confusion.

kevincox avatar Mar 14 '20 04:03 kevincox

I marked this as stale due to inactivity. → More info

stale[bot] avatar Feb 13 '21 11:02 stale[bot]

How about outputting a warning that tabs should not be used in nix definition files, for consistency?

wmertens avatar Feb 13 '21 18:02 wmertens

I marked this as stale due to inactivity. → More info

stale[bot] avatar Aug 13 '21 22:08 stale[bot]

still relevant AFAIK

scintill avatar Aug 14 '21 07:08 scintill

For reference, issue #3759 is also about this topic. Note that other line terminators (i.e. CRLF) also seem to “break” indented strings.

JojOatXGME avatar Aug 14 '21 18:08 JojOatXGME

Is this discussion still active? I do not understand why only spaces would be stripped when there is a well understood concept of "Whitespace" (see every regex dialect), I don't want nixpkgs strict style guidelines to be forced onto me in my own personal repos where I choose to use tabs for my own reasons, I should be able to do that. Furthermore if it is to be arbitrarily limited to spaces only, the doco should be updated because stating that "whitespace" is removed is misleading.

frogamic avatar Nov 16 '21 02:11 frogamic

I marked this as stale due to inactivity. → More info

stale[bot] avatar Jun 12 '22 19:06 stale[bot]

Not stale AFAIK

scintill avatar Jun 12 '22 19:06 scintill

its 2023 now

ghost avatar Feb 06 '23 00:02 ghost

  • Can't do in its current form because it would be a breaking language change, and we can't do those until https://github.com/NixOS/rfcs/pull/137 is resolved

  • We can however do a warning on tabs, so

    • users are encouraged to match the rest of the ecosystem

    • users are informed that tab indentation in multiline string indents will have surprising behavior

Ericson2314 avatar Jul 14 '23 12:07 Ericson2314

If we do add a warning we need to find a way to make it relatively subtle. Probably would need to be dismissable. The last thing I want is some log noise during every Nix evaluation.

I do agree that if a versioning system is likely to land it would be a good way to roll this out.

kevincox avatar Jul 14 '23 12:07 kevincox

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-14-nix-team-meeting-minutes-71/30472/1

nixos-discourse avatar Jul 15 '23 17:07 nixos-discourse

We can however do a warning on tabs

And please also add a warning on CRLF (and CR), since they cause the same problem. While it is probably less common to use CRLF than tabs in the Linux ecosystem, I guess adding this check in addition to the check for tabs shouldn't be that complicated. [EDIT: Also, if you somehow end up with CRLF, it is often less visible than tabs. Many editors will just start using CRLF for each line termination if they find one occurrence in the file. Some editors[^1] will not even show you an indication which line termination they are using.]

[^1]: I think I even experienced vim not showing me any indication that it is using CRLF for a file while using the default configuration of some Linux distribution, but not sure.

FYI, I don't know why CRLF breaks indented string since the CR (\r) is at the end of the line, not at the beginning, but it does.

JojOatXGME avatar Jul 16 '23 13:07 JojOatXGME

It's probably a good thing to eliminate "surprising behavior" where possible, rather than warn about it IMO. If RFC 137 succeeds, that sounds like the better route to me.

I don't think this will threaten ecosystem consistency, given that nixpkgs and every nix formatter I have seen uses spaces.

buckley310 avatar Jul 20 '23 16:07 buckley310

Marked as draft because this is either blocked on RFC 137 for supporting breaking language changes, or this could be converted to a change that warn appropriately when such tabs are encountered.

roberth avatar Sep 03 '23 17:09 roberth

RFC 137 did not pass.

buckley310 avatar Oct 27 '23 17:10 buckley310

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/satisfaction-survey-from-the-new-rfc-166-formatting/49758/37

nixos-discourse avatar Jun 01 '25 20:06 nixos-discourse