Document attribute escaping

This commit is contained in:
Robert Hensing 2025-11-29 12:02:24 +01:00
parent 2cccadc735
commit abdf8c99ff
5 changed files with 46 additions and 1 deletions

View file

@ -54,7 +54,16 @@ mkTransposedPerSystemModule {
type = types.lazyAttrsOf appType;
default = { };
description = ''
Programs runnable with nix run `<name>`.
An attribute set of programs runnable with [`nix run`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run.html).
`nix run .#<name>` will run `apps.<name>`.
Attribute names containing special characters like `.` must be doubly quoted when used in installable arguments:
```bash
nix run '.#"example.com"'
```
Consider using `:` or `/` as separators instead (e.g., `foo:bar`) for better command-line usability.
'';
example = lib.literalExpression or lib.literalExample ''
{

View file

@ -16,7 +16,15 @@ mkTransposedPerSystemModule {
default = { };
description = ''
An attribute set of packages to be used as shells.
[`nix develop .#<name>`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html) will run `devShells.<name>`.
Attribute names containing special characters like `.` must be doubly quoted when used in installable arguments:
```bash
nix develop '.#"example.com"'
```
Consider using `:` or `/` as separators instead (e.g., `foo:bar`) for better command-line usability.
'';
example = literalExpression ''
{

View file

@ -15,6 +15,16 @@ mkTransposedPerSystemModule {
default = { };
description = ''
An attribute set of unmergeable values. This is also used by [`nix build .#<attrpath>`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-build.html).
`legacyPackages` supports nested attribute sets. Use `.` to access nested attributes:
`.#foo.bar` refers to the `bar` attribute in `foo`.
Attribute names that literally contain special characters like `.` must be doubly quoted when used in installable arguments:
```bash
nix build '.#"example.com"'
```
Consider using `:` or `/` as separators instead (e.g., `foo:bar`) for better command-line usability.
'';
};
file = ./legacyPackages.nix;

View file

@ -17,6 +17,17 @@ mkTransposedPerSystemModule {
An attribute set of packages to be built by [`nix build`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-build.html).
`nix build .#<name>` will build `packages.<name>`.
You can also build attributes of a package using `.` to access nested attributes:
`.#foo.tests.simple` builds the `simple` attribute in `foo.tests`.
This is a Nixpkgs convention (packages having "passthru" attributes like `tests`) which gets no special treatment in Flakes.
Attribute names containing special characters like `.` must be doubly quoted when used in installable arguments:
```bash
nix build '.#"example.com"'
```
Consider using `:` or `/` as separators instead (e.g., `foo:bar`) for better command-line usability.
'';
};
file = ./packages.nix;