docs: migrate lib.packages to doc-comments

This commit is contained in:
KFears 2025-09-14 22:26:41 +04:00
parent 459a42c163
commit 202ceec461
Signed by: KFearsoff
SSH key fingerprint: SHA256:sn39ts1xvi/KGQNlqDyrj8nNlhp9ilndgIolXKnPraw

View file

@ -1,14 +1,26 @@
lib: {
## Check whether a value is a derivation. Note that this will also return true
## for "fake" derivations which are constructed by helpers such as
## `lib.paths.into.drv` for convenience.
##
## @type a -> Bool
/**
Check whether a value is a derivation. Note that this will also return true
for "fake" derivations which are constructed by helpers such as
`lib.paths.into.drv` for convenience.
# Type
```
isDerivation :: Any -> Bool
```
*/
isDerivation = value: value.type or null == "derivation";
## Sanitize a string to produce a valid name for a derivation.
##
## @type String -> String
/**
Sanitize a string to produce a valid name for a derivation.
# Type
```
sanitizeDerivationName :: String -> String
```
*/
sanitizeDerivationName =
let
validate = builtins.match "[[:alnum:]+_?=-][[:alnum:]+._?=-]*";
@ -38,9 +50,15 @@ lib: {
(x: if builtins.stringLength x == 0 then "unknown" else x)
] value;
## Get an output of a derivation.
##
## @type String -> Derivation -> String
/**
Get an output of a derivation.
# Type
```
getOutput :: String -> Derivation -> String
```
*/
getOutput =
output: package:
if !package ? outputSpecified || !package.outputSpecified then