+5
-5
lib/attrsets.nix
+5
-5
lib/attrsets.nix
···
44
44
;
45
45
46
46
/**
47
-
Return an attribute from nested attribute sets.
47
+
Returns an attribute from nested attribute sets.
48
48
49
49
Nix has an [attribute selection operator `.`](https://nixos.org/manual/nix/stable/language/operators#attribute-selection) which is sufficient for such queries, as long as the number of attributes is static. For example:
50
50
···
111
111
attrByPath' 0 set;
112
112
113
113
/**
114
-
Return if an attribute from nested attribute set exists.
114
+
Returns if an attribute from nested attribute set exists.
115
115
116
116
Nix has a [has attribute operator `?`](https://nixos.org/manual/nix/stable/language/operators#has-attribute), which is sufficient for such queries, as long as the number of attributes is static. For example:
117
117
···
177
177
hasAttrByPath' 0 e;
178
178
179
179
/**
180
-
Return the longest prefix of an attribute path that refers to an existing attribute in a nesting of attribute sets.
180
+
Returns the longest prefix of an attribute path that refers to an existing attribute in a nesting of attribute sets.
181
181
182
182
Can be used after [`mapAttrsRecursiveCond`](#function-library-lib.attrsets.mapAttrsRecursiveCond) to apply a condition,
183
183
although this will evaluate the predicate function on sibling attributes as well.
···
504
504
updates: value: go 0 true value updates;
505
505
506
506
/**
507
-
Return the specified attributes from a set.
507
+
Returns the specified attributes from a set.
508
508
509
509
# Inputs
510
510
···
536
536
attrVals = nameList: set: map (x: set.${x}) nameList;
537
537
538
538
/**
539
-
Return the values of all attributes in the given set, sorted by
539
+
Returns the values of all attributes in the given set, sorted by
540
540
attribute name.
541
541
542
542
# Type
+2
-2
lib/deprecated/misc.nix
+2
-2
lib/deprecated/misc.nix
···
73
73
name: default: attrs:
74
74
attrs.${name} or default;
75
75
76
-
# Return the second argument if the first one is true or the empty version
76
+
# Returns the second argument if the first one is true or the empty version
77
77
# of the second argument.
78
78
ifEnable =
79
79
cond: val:
···
89
89
else
90
90
null;
91
91
92
-
# Return true only if there is an attribute and it is true.
92
+
# Returns true only if there is an attribute and it is true.
93
93
checkFlag =
94
94
attrSet: name:
95
95
if name == "true" then
+1
-1
lib/fixed-points.nix
+1
-1
lib/fixed-points.nix
+11
-11
lib/lists.nix
+11
-11
lib/lists.nix
···
642
642
if index == null then default else elemAt list index;
643
643
644
644
/**
645
-
Return true if function `pred` returns true for at least one
645
+
Returns true if function `pred` returns true for at least one
646
646
element of `list`.
647
647
648
648
# Inputs
···
677
677
any = builtins.any;
678
678
679
679
/**
680
-
Return true if function `pred` returns true for all elements of
680
+
Returns true if function `pred` returns true for all elements of
681
681
`list`.
682
682
683
683
# Inputs
···
777
777
optional = cond: elem: if cond then [ elem ] else [ ];
778
778
779
779
/**
780
-
Return a list or an empty list, depending on a boolean value.
780
+
Returns a list or an empty list, depending on a boolean value.
781
781
782
782
# Inputs
783
783
···
837
837
toList = x: if isList x then x else [ x ];
838
838
839
839
/**
840
-
Return a list of integers from `first` up to and including `last`.
840
+
Returns a list of integers from `first` up to and including `last`.
841
841
842
842
# Inputs
843
843
···
871
871
range = first: last: if first > last then [ ] else genList (n: first + n) (last - first + 1);
872
872
873
873
/**
874
-
Return a list with `n` copies of an element.
874
+
Returns a list with `n` copies of an element.
875
875
876
876
# Inputs
877
877
···
1429
1429
map (x: elemAt x 1) (sort less prepared);
1430
1430
1431
1431
/**
1432
-
Return the first (at most) N elements of a list.
1432
+
Returns the first (at most) N elements of a list.
1433
1433
1434
1434
# Inputs
1435
1435
···
1463
1463
take = count: sublist 0 count;
1464
1464
1465
1465
/**
1466
-
Return the last (at most) N elements of a list.
1466
+
Returns the last (at most) N elements of a list.
1467
1467
1468
1468
# Inputs
1469
1469
···
1639
1639
throw "lib.lists.removePrefix: First argument is not a list prefix of the second argument";
1640
1640
1641
1641
/**
1642
-
Return a list consisting of at most `count` elements of `list`,
1642
+
Returns a list consisting of at most `count` elements of `list`,
1643
1643
starting at index `start`.
1644
1644
1645
1645
# Inputs
···
1737
1737
take commonPrefixLength list1;
1738
1738
1739
1739
/**
1740
-
Return the last element of a list.
1740
+
Returns the last element of a list.
1741
1741
1742
1742
This function throws an error if the list is empty.
1743
1743
···
1770
1770
elemAt list (length list - 1);
1771
1771
1772
1772
/**
1773
-
Return all elements but the last.
1773
+
Returns all elements but the last.
1774
1774
1775
1775
This function throws an error if the list is empty.
1776
1776
···
1803
1803
take (length list - 1) list;
1804
1804
1805
1805
/**
1806
-
Return the image of the cross product of some lists by a function.
1806
+
Returns the image of the cross product of some lists by a function.
1807
1807
1808
1808
# Examples
1809
1809
:::{.example}
+6
-6
lib/modules.nix
+6
-6
lib/modules.nix
···
1452
1452
};
1453
1453
1454
1454
/**
1455
-
Return a definition with file location information.
1455
+
Returns a definition with file location information.
1456
1456
*/
1457
1457
mkDefinition = args@{ file, value, ... }: args // { _type = "definition"; };
1458
1458
···
1541
1541
};
1542
1542
1543
1543
/**
1544
-
Return a module that causes a warning to be shown if the
1544
+
Returns a module that causes a warning to be shown if the
1545
1545
specified option is defined. For example,
1546
1546
1547
1547
mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ] "<replacement instructions>"
···
1589
1589
};
1590
1590
1591
1591
/**
1592
-
Return a module that causes a warning to be shown if the
1592
+
Returns a module that causes a warning to be shown if the
1593
1593
specified "from" option is defined; the defined value is however
1594
1594
forwarded to the "to" option. This can be used to rename options
1595
1595
while providing backward compatibility. For example,
···
1645
1645
};
1646
1646
1647
1647
/**
1648
-
Return a module that causes a warning to be shown if any of the "from"
1648
+
Returns a module that causes a warning to be shown if any of the "from"
1649
1649
option is defined; the defined values can be used in the "mergeFn" to set
1650
1650
the "to" value.
1651
1651
This function can be used to merge multiple options into one that has a
···
1724
1724
1725
1725
/**
1726
1726
Single "from" version of mkMergedOptionModule.
1727
-
Return a module that causes a warning to be shown if the "from" option is
1727
+
Returns a module that causes a warning to be shown if the "from" option is
1728
1728
defined; the defined value can be used in the "mergeFn" to set the "to"
1729
1729
value.
1730
1730
This function can be used to change an option into another that has a
···
1822
1822
mkDerivedConfig = opt: f: mkOverride (opt.highestPrio or defaultOverridePriority) (f opt.value);
1823
1823
1824
1824
/**
1825
-
Return a module that help declares an option that has been renamed.
1825
+
Returns a module that help declares an option that has been renamed.
1826
1826
When a value is defined for the old option, it is forwarded to the `to` option.
1827
1827
*/
1828
1828
doRename =
+1
-1
lib/options.nix
+1
-1
lib/options.nix
···
503
503
loc: defs:
504
504
if defs == [ ] then
505
505
abort "This case should never happen."
506
-
# Return early if we only have one element
506
+
# Returns early if we only have one element
507
507
# This also makes it work for functions, because the foldl' below would try
508
508
# to compare the first element with itself, which is false for functions
509
509
else if length defs == 1 then
+1
-1
lib/path/default.nix
+1
-1
lib/path/default.nix
+4
-4
lib/strings.nix
+4
-4
lib/strings.nix
···
1806
1806
if len == 0 then [ (addContextFrom str "") ] else map (addContextFrom str) (go 0 "" [ ]);
1807
1807
1808
1808
/**
1809
-
Return a string without the specified prefix, if the prefix matches.
1809
+
Returns a string without the specified prefix, if the prefix matches.
1810
1810
1811
1811
# Inputs
1812
1812
···
1857
1857
);
1858
1858
1859
1859
/**
1860
-
Return a string without the specified suffix, if the suffix matches.
1860
+
Returns a string without the specified suffix, if the suffix matches.
1861
1861
1862
1862
# Inputs
1863
1863
···
1908
1908
);
1909
1909
1910
1910
/**
1911
-
Return true if string `v1` denotes a version older than `v2`.
1911
+
Returns true if string `v1` denotes a version older than `v2`.
1912
1912
1913
1913
# Inputs
1914
1914
···
1940
1940
versionOlder = v1: v2: compareVersions v2 v1 == 1;
1941
1941
1942
1942
/**
1943
-
Return true if string v1 denotes a version equal to or newer than v2.
1943
+
Returns true if string v1 denotes a version equal to or newer than v2.
1944
1944
1945
1945
# Inputs
1946
1946
+3
-3
lib/trivial.nix
+3
-3
lib/trivial.nix
···
327
327
f b a;
328
328
329
329
/**
330
-
Return `maybeValue` if not null, otherwise return `default`.
330
+
Returns `maybeValue` if not null, otherwise return `default`.
331
331
332
332
# Inputs
333
333
···
529
529
## Integer operations
530
530
531
531
/**
532
-
Return minimum of two numbers.
532
+
Returns minimum of two numbers.
533
533
534
534
# Inputs
535
535
···
544
544
min = x: y: if x < y then x else y;
545
545
546
546
/**
547
-
Return maximum of two numbers.
547
+
Returns maximum of two numbers.
548
548
549
549
# Inputs
550
550
+1
-1
lib/types.nix
+1
-1
lib/types.nix