Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
|
|
|
|
* doc: lib.lists migrate to doc-comments
* Fix extra indentation of docs lines, remove redundant comments, add inputs docs
* fix: indentation & argument references
---------
Co-authored-by: DS <commits@sidhion.com>
|
|
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
|
|
The deprecation warnings in lib were wildly inconsistent. Different
formulations were used in different places for the same meaning. Some warnings
used builtins.trace instead of lib.warn, which prevents silencing; one even
only had a comment instead. Make everything more uniform.
|
|
|
|
A more efficient sort in some cases, and often convenient.
This exposes `lib.lists.sortOn` immediately on `lib`, because it is
a sibling of `sort`, which is already present there.
Omitting it would lead to more confusion, and worse outcomes.
There's no confusion about the types `sort` or `sortOn` operate on.
Haskell agrees about the type for `sortOn`, and it is in its `base`.
|
|
See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0
|
|
|
|
To maintain backwards compatibility, this can't be changed in the Nix language.
We can however ensure that the version Nixpkgs has the more intuitive behavior.
|
|
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
|
|
Nix 2.3, the minimum Nix version supported by Nixpkgs, has
`builtins.foldl'` already.
|
|
`lib.lists.{hasPrefix,removePrefix}`: init
|
|
|
|
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
|
|
|
|
|
|
There's no need to evaluate list elements after a matching element
|
|
lib.lists: add `replicate`
|
|
`replicate` returns n copies of an element as a list.
Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
|
|
There are a number of different syntaxes used for attrset type
signatures in our doc strings, this change standardises upon one that
uses :: for specifying attribute type, and ; terminators to be
consistent with nix syntax. There are no bugs in the functions
themselves, just that different syntaxes may confuse new users.
|
|
caused problems for automated rich text generation such as
https://teu5us.github.io/nix-lib.html#customisation-functions
|
|
- This quote mark should be a backtick
- Using a quote mark instead of a backtick breaks formatting when rendering the docs
|
|
|
|
builtins.groupBy is much more performant. It was introduced in
https://github.com/NixOS/nix/pull/5715
|
|
The current implementation of `mutuallyExclusive` builds a new list with
length subtracted by one on every recursive call which is expensive. When
b is empty, the function still traverses a in its entirety before returning
a result.
The new implementation uses `any` to check if each element of list b is in
list a using `elem`. This maintains short circuiting when list a or b is empty
and has a worst case time complexity of O(nm).
|
|
|
|
|
|
This improves performance by ~30-40% for smaller test cases and makes
larger cases where my laptop would OOM pass in seconds.
|
|
Nix can perform static scope checking, but whenever code is inside
a `with` expression, the analysis breaks down, because it can't
know statically what's in the attribute set whose attributes were
brought into scope. In those cases, Nix has to assume that
everything works out.
Except it doesnt. Removing `with` from lib/ revealed an undefined
variable in an error message.
If that doesn't convince you that we're better off without `with`,
I can tell you that this PR results in a 3% evaluation performance
improvement because Nix can look up local variables by index.
This adds up with applications like the module system.
Furthermore, removing `with` makes the binding site of each
variable obvious, which helps with comprehension.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The main purpose is to bring attention to `flip map`, which improves
code readablity. It is useful when ad-hoc anonymous function
grows two or more lines in `map` application:
```
map (lcfg:
let port = lcfg.port;
portStr = if port != defaultPort then ":${toString port}" else "";
scheme = if cfg.enableSSL then "https" else "http";
in "${scheme}://cfg.hostName${portStr}"
) (getListen cfg);
```
Compare this to `foreach`-style:
```
foreach (getListen cfg) (lcfg:
let port = lcfg.port;
portStr = if port != defaultPort then ":${toString port}" else "";
scheme = if cfg.enableSSL then "https" else "http";
in "${scheme}://cfg.hostName${portStr}"
);
```
This is similar to Haskell's `for` (http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Traversable.html#v:for)
|
|
|
|
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: Profpatsch <mail@profpatsch.de>
|
|
Updates documentation comments with extra information for nixdoc[1]
compatibility.
[1]: https://github.com/tazjin/nixdoc
|
|
Since the `assertOneOf` uses `lib.generators`, they are not really trivial
anymore and should go into their own library file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nixos: doc: implement related packages in the manual (again)
|