···1617 Example:
18 x = { a = { b = 3; }; }
0019 attrByPath ["a" "b"] 6 x
20 => 3
21 attrByPath ["z" "z"] 6 x
···2324 Type:
25 attrByPath :: [String] -> Any -> AttrSet -> Any
026 */
27 attrByPath =
28 # A list of strings representing the attribute path to return from `set`
···96 => error: cannot find attribute `z.z'
9798 Type:
99- getAttrFromPath :: [String] -> AttrSet -> Value
100 */
101 getAttrFromPath =
102 # A list of strings representing the attribute path to get from `set`
···109 /* Map each attribute in the given set and merge them into a new attribute set.
110111 Type:
112- concatMapAttrs ::
113- (String -> a -> AttrSet)
114- -> AttrSet
115- -> AttrSet
116117 Example:
118 concatMapAttrs
···168 ] { a.b.c = 0; }
169 => { a = { b = { d = 1; }; }; x = { y = "xy"; }; }
170171- Type:
172- updateManyAttrsByPath :: [AttrSet] -> AttrSet -> AttrSet
173 */
174 updateManyAttrsByPath = let
175 # When recursing into attributes, instead of updating the `path` of each
···252 Example:
253 attrValues {c = 3; a = 1; b = 2;}
254 => [1 2 3]
0255 Type:
256 attrValues :: AttrSet -> [Any]
257 */
···341342 Type:
343 foldAttrs :: (Any -> Any -> Any) -> Any -> [AttrSets] -> Any
0344 */
345 foldAttrs =
346 # A function, given a value and a collector combines the two.
···394 { a = 2; b = 20; }
395 ]
396 Type:
397- cartesianProductOfSets :: AttrSet -> [AttrSet]
398 */
399 cartesianProductOfSets =
400 # Attribute set with attributes that are lists of values
···413 => { name = "some"; value = 6; }
414415 Type:
416- nameValuePair :: String -> Any -> AttrSet
417 */
418 nameValuePair =
419 # Attribute name
···600 => { }
601602 Type:
603- optionalAttrs :: Bool -> AttrSet
604 */
605 optionalAttrs =
606 # Condition under which the `as` attribute set is returned.
···646 => { a = ["x" "y"]; b = ["z"] }
647648 Type:
649- zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
650 */
651 zipAttrsWith =
652 builtins.zipAttrsWith or (f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets);
···737 }
738739 Type:
740- recursiveUpdate :: AttrSet -> AttrSet -> AttrSet
741 */
742 recursiveUpdate =
743 # Left attribute set of the merge.
···795 /* Turns a list of strings into a human-readable description of those
796 strings represented as an attribute path. The result of this function is
797 not intended to be machine-readable.
0798799 Example:
800 showAttrPath [ "foo" "10" "bar" ]
···831 If the output does not exist, fallback to `.out` and then to the default.
832833 Example:
834- getOutput pkgs.openssl
835 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r"
836837 Type:
838- getOutput :: Derivation -> String
839 */
840 getBin = getOutput "bin";
841···844 If the output does not exist, fallback to `.out` and then to the default.
845846 Example:
847- getOutput pkgs.openssl
848 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-lib"
849850 Type:
851- getOutput :: Derivation -> String
852 */
853 getLib = getOutput "lib";
854···857 If the output does not exist, fallback to `.out` and then to the default.
858859 Example:
860- getOutput pkgs.openssl
861 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev"
862863 Type:
864- getOutput :: Derivation -> String
865 */
866 getDev = getOutput "dev";
867···870 If the output does not exist, fallback to `.out` and then to the default.
871872 Example:
873- getOutput pkgs.openssl
874 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-man"
875876 Type:
877- getOutput :: Derivation -> String
878 */
879 getMan = getOutput "man";
880881- /* Pick the outputs of packages to place in `buildInputs` */
0000882 chooseDevOutputs =
883 # List of packages to pick `dev` outputs from
884 drvs:
···900901 Type:
902 recurseIntoAttrs :: AttrSet -> AttrSet
0903 */
904 recurseIntoAttrs =
905 # An attribute set to scan for derivations.
···909 /* Undo the effect of recurseIntoAttrs.
910911 Type:
912- recurseIntoAttrs :: AttrSet -> AttrSet
913 */
914 dontRecurseIntoAttrs =
915 # An attribute set to not scan for derivations.
···919 /* `unionOfDisjoint x y` is equal to `x // y // z` where the
920 attrnames in `z` are the intersection of the attrnames in `x` and
921 `y`, and all values `assert` with an error message. This
922- operator is commutative, unlike (//). */
000923 unionOfDisjoint = x: y:
924 let
925 intersection = builtins.intersectAttrs x y;
···930 in
931 (x // y) // mask;
932933- # deprecated
934 zipWithNames = zipAttrsWithNames;
935- # deprecated
0936 zip = builtins.trace
937 "lib.zip is deprecated, use lib.zipAttrsWith instead" zipAttrsWith;
938}
···1617 Example:
18 x = { a = { b = 3; }; }
19+ # ["a" "b"] is equivalent to x.a.b
20+ # 6 is a default value to return if the path does not exist in attrset
21 attrByPath ["a" "b"] 6 x
22 => 3
23 attrByPath ["z" "z"] 6 x
···2526 Type:
27 attrByPath :: [String] -> Any -> AttrSet -> Any
28+29 */
30 attrByPath =
31 # A list of strings representing the attribute path to return from `set`
···99 => error: cannot find attribute `z.z'
100101 Type:
102+ getAttrFromPath :: [String] -> AttrSet -> Any
103 */
104 getAttrFromPath =
105 # A list of strings representing the attribute path to get from `set`
···112 /* Map each attribute in the given set and merge them into a new attribute set.
113114 Type:
115+ concatMapAttrs :: (String -> a -> AttrSet) -> AttrSet -> AttrSet
000116117 Example:
118 concatMapAttrs
···168 ] { a.b.c = 0; }
169 => { a = { b = { d = 1; }; }; x = { y = "xy"; }; }
170171+ Type: updateManyAttrsByPath :: [{ path :: [String], update :: (Any -> Any) }] -> AttrSet -> AttrSet
0172 */
173 updateManyAttrsByPath = let
174 # When recursing into attributes, instead of updating the `path` of each
···251 Example:
252 attrValues {c = 3; a = 1; b = 2;}
253 => [1 2 3]
254+255 Type:
256 attrValues :: AttrSet -> [Any]
257 */
···341342 Type:
343 foldAttrs :: (Any -> Any -> Any) -> Any -> [AttrSets] -> Any
344+345 */
346 foldAttrs =
347 # A function, given a value and a collector combines the two.
···395 { a = 2; b = 20; }
396 ]
397 Type:
398+ cartesianProductOfSets :: AttrSet -> [AttrSet]
399 */
400 cartesianProductOfSets =
401 # Attribute set with attributes that are lists of values
···414 => { name = "some"; value = 6; }
415416 Type:
417+ nameValuePair :: String -> Any -> { name :: String, value :: Any }
418 */
419 nameValuePair =
420 # Attribute name
···601 => { }
602603 Type:
604+ optionalAttrs :: Bool -> AttrSet -> AttrSet
605 */
606 optionalAttrs =
607 # Condition under which the `as` attribute set is returned.
···647 => { a = ["x" "y"]; b = ["z"] }
648649 Type:
650+ zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
651 */
652 zipAttrsWith =
653 builtins.zipAttrsWith or (f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets);
···738 }
739740 Type:
741+ recursiveUpdate :: AttrSet -> AttrSet -> AttrSet
742 */
743 recursiveUpdate =
744 # Left attribute set of the merge.
···796 /* Turns a list of strings into a human-readable description of those
797 strings represented as an attribute path. The result of this function is
798 not intended to be machine-readable.
799+ Create a new attribute set with `value` set at the nested attribute location specified in `attrPath`.
800801 Example:
802 showAttrPath [ "foo" "10" "bar" ]
···833 If the output does not exist, fallback to `.out` and then to the default.
834835 Example:
836+ getBin pkgs.openssl
837 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r"
838839 Type:
840+ getBin :: Derivation -> String
841 */
842 getBin = getOutput "bin";
843···846 If the output does not exist, fallback to `.out` and then to the default.
847848 Example:
849+ getLib pkgs.openssl
850 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-lib"
851852 Type:
853+ getLib :: Derivation -> String
854 */
855 getLib = getOutput "lib";
856···859 If the output does not exist, fallback to `.out` and then to the default.
860861 Example:
862+ getDev pkgs.openssl
863 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev"
864865 Type:
866+ getDev :: Derivation -> String
867 */
868 getDev = getOutput "dev";
869···872 If the output does not exist, fallback to `.out` and then to the default.
873874 Example:
875+ getMan pkgs.openssl
876 => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-man"
877878 Type:
879+ getMan :: Derivation -> String
880 */
881 getMan = getOutput "man";
882883+ /* Pick the outputs of packages to place in `buildInputs`
884+885+ Type: chooseDevOutputs :: [Derivation] -> [String]
886+887+ */
888 chooseDevOutputs =
889 # List of packages to pick `dev` outputs from
890 drvs:
···906907 Type:
908 recurseIntoAttrs :: AttrSet -> AttrSet
909+910 */
911 recurseIntoAttrs =
912 # An attribute set to scan for derivations.
···916 /* Undo the effect of recurseIntoAttrs.
917918 Type:
919+ dontRecurseIntoAttrs :: AttrSet -> AttrSet
920 */
921 dontRecurseIntoAttrs =
922 # An attribute set to not scan for derivations.
···926 /* `unionOfDisjoint x y` is equal to `x // y // z` where the
927 attrnames in `z` are the intersection of the attrnames in `x` and
928 `y`, and all values `assert` with an error message. This
929+ operator is commutative, unlike (//).
930+931+ Type: unionOfDisjoint :: AttrSet -> AttrSet -> AttrSet
932+ */
933 unionOfDisjoint = x: y:
934 let
935 intersection = builtins.intersectAttrs x y;
···940 in
941 (x // y) // mask;
942943+ # DEPRECATED
944 zipWithNames = zipAttrsWithNames;
945+946+ # DEPRECATED
947 zip = builtins.trace
948 "lib.zip is deprecated, use lib.zipAttrsWith instead" zipAttrsWith;
949}
+2-2
lib/options.nix
···104 /* Creates an Option attribute set for an option that specifies the
105 package a module should use for some purpose.
106107- Type: mkPackageOption :: pkgs -> string -> { default :: [string], example :: null | string | [string] } -> option
108-109 The package is specified as a list of strings representing its attribute path in nixpkgs.
110111 Because of this, you need to pass nixpkgs itself as the first argument.
···115 You can also pass an example value, either a literal string or a package's attribute path.
116117 You can omit the default path if the name of the option is also attribute path in nixpkgs.
00118119 Example:
120 mkPackageOption pkgs "hello" { }
···104 /* Creates an Option attribute set for an option that specifies the
105 package a module should use for some purpose.
10600107 The package is specified as a list of strings representing its attribute path in nixpkgs.
108109 Because of this, you need to pass nixpkgs itself as the first argument.
···113 You can also pass an example value, either a literal string or a package's attribute path.
114115 You can omit the default path if the name of the option is also attribute path in nixpkgs.
116+117+ Type: mkPackageOption :: pkgs -> string -> { default :: [string], example :: null | string | [string] } -> option
118119 Example:
120 mkPackageOption pkgs "hello" { }