Update fn docs and readability.
This commit is contained in:
parent
923bddbc94
commit
b6b22c2c22
1 changed files with 27 additions and 3 deletions
30
fn.nix
30
fn.nix
|
@ -2,10 +2,34 @@
|
||||||
with builtins;
|
with builtins;
|
||||||
with lib;
|
with lib;
|
||||||
rec {
|
rec {
|
||||||
|
/**
|
||||||
|
Shorthand for "if condition then a else b"
|
||||||
|
|
||||||
|
# Type
|
||||||
|
```
|
||||||
|
ifelse :: Bool -> Any -> Any -> Any
|
||||||
|
```
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
- [condition] A condition evaluating to a boolean
|
||||||
|
- [a] Result if condition evaluates to true
|
||||||
|
- [b] Result if condition evaluates to false
|
||||||
|
|
||||||
|
# Example
|
||||||
|
```nix
|
||||||
|
let
|
||||||
|
myData = { val = "custom"; };
|
||||||
|
in ifelse (myData ? val) myData.val "default"
|
||||||
|
=> "custom"
|
||||||
|
```
|
||||||
|
*/
|
||||||
ifelse =
|
ifelse =
|
||||||
a: b: c:
|
condition: a: b:
|
||||||
if a then b else c;
|
if condition then a else b;
|
||||||
fileContentsOr = a: b: (ifelse (pathIsRegularFile a) a b);
|
|
||||||
|
/**
|
||||||
|
Value of PWD environment variable at evaluation time
|
||||||
|
*/
|
||||||
cwd = builtins.getEnv "PWD";
|
cwd = builtins.getEnv "PWD";
|
||||||
|
|
||||||
# lst (string PATH) (string FILETYPE) (bool RETURNFULLPATH)
|
# lst (string PATH) (string FILETYPE) (bool RETURNFULLPATH)
|
||||||
|
|
Loading…
Reference in a new issue