···16161717 Example:
1818 x = { a = { b = 3; }; }
1919+ # ["a" "b"] is equivalent to x.a.b
2020+ # 6 is a default value to return if the path does not exist in attrset
1921 attrByPath ["a" "b"] 6 x
2022 => 3
2123 attrByPath ["z" "z"] 6 x
···23252426 Type:
2527 attrByPath :: [String] -> Any -> AttrSet -> Any
2828+2629 */
2730 attrByPath =
2831 # A list of strings representing the attribute path to return from `set`
···9699 => error: cannot find attribute `z.z'
9710098101 Type:
9999- getAttrFromPath :: [String] -> AttrSet -> Value
102102+ getAttrFromPath :: [String] -> AttrSet -> Any
100103 */
101104 getAttrFromPath =
102105 # A list of strings representing the attribute path to get from `set`
···109112 /* Map each attribute in the given set and merge them into a new attribute set.
110113111114 Type:
112112- concatMapAttrs ::
113113- (String -> a -> AttrSet)
114114- -> AttrSet
115115- -> AttrSet
115115+ concatMapAttrs :: (String -> a -> AttrSet) -> AttrSet -> AttrSet
116116117117 Example:
118118 concatMapAttrs
···168168 ] { a.b.c = 0; }
169169 => { a = { b = { d = 1; }; }; x = { y = "xy"; }; }
170170171171- Type:
172172- updateManyAttrsByPath :: [AttrSet] -> AttrSet -> AttrSet
171171+ Type: updateManyAttrsByPath :: [{ path :: [String], update :: (Any -> Any) }] -> AttrSet -> AttrSet
173172 */
174173 updateManyAttrsByPath = let
175174 # When recursing into attributes, instead of updating the `path` of each
···252251 Example:
253252 attrValues {c = 3; a = 1; b = 2;}
254253 => [1 2 3]
254254+255255 Type:
256256 attrValues :: AttrSet -> [Any]
257257 */
···341341342342 Type:
343343 foldAttrs :: (Any -> Any -> Any) -> Any -> [AttrSets] -> Any
344344+344345 */
345346 foldAttrs =
346347 # A function, given a value and a collector combines the two.
···394395 { a = 2; b = 20; }
395396 ]
396397 Type:
397397- cartesianProductOfSets :: AttrSet -> [AttrSet]
398398+ cartesianProductOfSets :: AttrSet -> [AttrSet]
398399 */
399400 cartesianProductOfSets =
400401 # Attribute set with attributes that are lists of values
···413414 => { name = "some"; value = 6; }
414415415416 Type:
416416- nameValuePair :: String -> Any -> AttrSet
417417+ nameValuePair :: String -> Any -> { name :: String, value :: Any }
417418 */
418419 nameValuePair =
419420 # Attribute name
···600601 => { }
601602602603 Type:
603603- optionalAttrs :: Bool -> AttrSet
604604+ optionalAttrs :: Bool -> AttrSet -> AttrSet
604605 */
605606 optionalAttrs =
606607 # Condition under which the `as` attribute set is returned.
···646647 => { a = ["x" "y"]; b = ["z"] }
647648648649 Type:
649649- zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
650650+ zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
650651 */
651652 zipAttrsWith =
652653 builtins.zipAttrsWith or (f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets);
···737738 }
738739739740 Type:
740740- recursiveUpdate :: AttrSet -> AttrSet -> AttrSet
741741+ recursiveUpdate :: AttrSet -> AttrSet -> AttrSet
741742 */
742743 recursiveUpdate =
743744 # Left attribute set of the merge.
···795796 /* Turns a list of strings into a human-readable description of those
796797 strings represented as an attribute path. The result of this function is
797798 not intended to be machine-readable.
799799+ Create a new attribute set with `value` set at the nested attribute location specified in `attrPath`.
798800799801 Example:
800802 showAttrPath [ "foo" "10" "bar" ]
···831833 If the output does not exist, fallback to `.out` and then to the default.
832834833835 Example:
834834- getOutput pkgs.openssl
836836+ getBin pkgs.openssl
835837 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r"
836838837839 Type:
838838- getOutput :: Derivation -> String
840840+ getBin :: Derivation -> String
839841 */
840842 getBin = getOutput "bin";
841843···844846 If the output does not exist, fallback to `.out` and then to the default.
845847846848 Example:
847847- getOutput pkgs.openssl
849849+ getLib pkgs.openssl
848850 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-lib"
849851850852 Type:
851851- getOutput :: Derivation -> String
853853+ getLib :: Derivation -> String
852854 */
853855 getLib = getOutput "lib";
854856···857859 If the output does not exist, fallback to `.out` and then to the default.
858860859861 Example:
860860- getOutput pkgs.openssl
862862+ getDev pkgs.openssl
861863 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev"
862864863865 Type:
864864- getOutput :: Derivation -> String
866866+ getDev :: Derivation -> String
865867 */
866868 getDev = getOutput "dev";
867869···870872 If the output does not exist, fallback to `.out` and then to the default.
871873872874 Example:
873873- getOutput pkgs.openssl
875875+ getMan pkgs.openssl
874876 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-man"
875877876878 Type:
877877- getOutput :: Derivation -> String
879879+ getMan :: Derivation -> String
878880 */
879881 getMan = getOutput "man";
880882881881- /* Pick the outputs of packages to place in `buildInputs` */
883883+ /* Pick the outputs of packages to place in `buildInputs`
884884+885885+ Type: chooseDevOutputs :: [Derivation] -> [String]
886886+887887+ */
882888 chooseDevOutputs =
883889 # List of packages to pick `dev` outputs from
884890 drvs:
···900906901907 Type:
902908 recurseIntoAttrs :: AttrSet -> AttrSet
909909+903910 */
904911 recurseIntoAttrs =
905912 # An attribute set to scan for derivations.
···909916 /* Undo the effect of recurseIntoAttrs.
910917911918 Type:
912912- recurseIntoAttrs :: AttrSet -> AttrSet
919919+ dontRecurseIntoAttrs :: AttrSet -> AttrSet
913920 */
914921 dontRecurseIntoAttrs =
915922 # An attribute set to not scan for derivations.
···919926 /* `unionOfDisjoint x y` is equal to `x // y // z` where the
920927 attrnames in `z` are the intersection of the attrnames in `x` and
921928 `y`, and all values `assert` with an error message. This
922922- operator is commutative, unlike (//). */
929929+ operator is commutative, unlike (//).
930930+931931+ Type: unionOfDisjoint :: AttrSet -> AttrSet -> AttrSet
932932+ */
923933 unionOfDisjoint = x: y:
924934 let
925935 intersection = builtins.intersectAttrs x y;
···930940 in
931941 (x // y) // mask;
932942933933- # deprecated
943943+ # DEPRECATED
934944 zipWithNames = zipAttrsWithNames;
935935- # deprecated
945945+946946+ # DEPRECATED
936947 zip = builtins.trace
937948 "lib.zip is deprecated, use lib.zipAttrsWith instead" zipAttrsWith;
938949}
+2-2
lib/options.nix
···104104 /* Creates an Option attribute set for an option that specifies the
105105 package a module should use for some purpose.
106106107107- Type: mkPackageOption :: pkgs -> string -> { default :: [string], example :: null | string | [string] } -> option
108108-109107 The package is specified as a list of strings representing its attribute path in nixpkgs.
110108111109 Because of this, you need to pass nixpkgs itself as the first argument.
···115113 You can also pass an example value, either a literal string or a package's attribute path.
116114117115 You can omit the default path if the name of the option is also attribute path in nixpkgs.
116116+117117+ Type: mkPackageOption :: pkgs -> string -> { default :: [string], example :: null | string | [string] } -> option
118118119119 Example:
120120 mkPackageOption pkgs "hello" { }