Skip to content

Commit

Permalink
unindent inherit semicolon, reshuffle binding/inherit sections (NixOS#14
Browse files Browse the repository at this point in the history
)

* unindent inherit semicolon, reshuffle binding/inherit sections

* fixup! Stuff
  • Loading branch information
infinisil committed Nov 28, 2023
1 parent 9ac50f8 commit 299c16f
Showing 1 changed file with 49 additions and 58 deletions.
107 changes: 49 additions & 58 deletions rfcs/0166-nix-formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ For sequences of items in expressions, like elements in a list, key-value pairs
foo
bar
baz
;
;
}
```

Expand Down Expand Up @@ -902,12 +902,10 @@ else
[ x y ]
```

### Bindings and inherit
### Bindings

Let bindings and attribute sets share the same syntax for their items, which is discussed here together.

#### Bindings

**Description**

Bindings have the most special cases to accommodate for many common Nixpkgs idioms.
Expand All @@ -931,8 +929,7 @@ foo =
function
arg1
arg2
arg3
;
arg3;
#5 simple function arguments (<=2) start on the same line
add = x: y: {
Expand Down Expand Up @@ -994,51 +991,7 @@ some.very.long.attr = callFunction
arg3;
```

#### inherit

**Description**

The items are either all on the same line, or all on a new line each (with indentation).

**Examples**

```nix
inherit foo bar baz;
inherit
foo'
bar'
baz'
;
```

#### inherit from

**Description**

- If the inherit source is single-line, it is placed on the same line as the `inherit`, even if the following items do not fit onto one line.
- Otherwise, it starts on a new line with indentation, like the others.
- In that case, the remaining items are force-expanded too, even if they would have fit onto one line in the first place.

**Examples**

```nix
inherit (pkgs) ap1 ap2 ap3;
inherit (pkgs)
app1
app2
# …
app42
;
inherit
(pkgs.callPackage ./foo.nix {
arg = "val";
})
attr1
attr2
;
```

#### Semicolon placement
#### Bindings semicolon placement

**Description**

Expand Down Expand Up @@ -1108,13 +1061,6 @@ There are four considered semicolon styles:
2. On a new line with one indentation level.
- Just as wasteful on space as (1), but a bit less clear about signaling the end of the binding.
```nix
inherit (pkgs)
app1
app2
# …
app42
;
attr3 =
function call
many
Expand Down Expand Up @@ -1147,3 +1093,48 @@ There are four considered semicolon styles:
&& cond3
;
```

### inherit

**Description**

- The items are either all on the same line, or all on a new line each (with indentation).
- The semicolon is on its own line with indentation.

**Examples**

```nix
inherit foo bar baz;
inherit
foo'
bar'
baz'
;
```

#### inherit from

**Description**

- If the inherit source is single-line, it is placed on the same line as the `inherit`, even if the following items do not fit onto one line.
- Otherwise, it starts on a new line with indentation, like the others.
- In that case, the remaining items are force-expanded too, even if they would have fit onto one line in the first place.

**Examples**

```nix
inherit (pkgs) ap1 ap2 ap3;
inherit (pkgs)
app1
app2
# …
app42
;
inherit
(pkgs.callPackage ./foo.nix {
arg = "val";
})
attr1
attr2
;
```

0 comments on commit 299c16f

Please sign in to comment.