noogle/models/builtins.json
2022-12-09 16:41:59 +01:00

1 line
45 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[{"category":"builtins","fn_type":"abort :: string","name":"abort","description":["takes 1 arguments: __`s`__ \n","Abort Nix expression evaluation and print the error message *s*.\n"]},{"category":"builtins","fn_type":"add :: number -> number -> number","name":"add","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the sum of the numbers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"all :: (a -> bool) -> [a] -> bool","name":"all","description":["takes 2 arguments: __`pred` `list`__ \n","Return `true` if the function *pred* returns `true` for all elements\nof *list*, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"any :: (a -> bool) -> [a] -> bool","name":"any","description":["takes 2 arguments: __`pred` `list`__ \n","Return `true` if the function *pred* returns `true` for at least one\nelement of *list*, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"attrNames :: AttrSet -> [a]","name":"attrNames","description":["takes 1 arguments: __`set`__ \n","Return the names of the attributes in the set *set* in an\nalphabetically sorted list. For instance, `builtins.attrNames { y\n= 1; x = \"foo\"; }` evaluates to `[ \"x\" \"y\" ]`.\n"]},{"category":"builtins","fn_type":"attrValues :: AttrSet -> [a]","name":"attrValues","description":["takes 1 arguments: __`set`__ \n","Return the values of the attributes in the set *set* in the order\ncorresponding to the sorted attribute names.\n"]},{"category":"builtins","fn_type":"baseNameOf :: string -> string","name":"baseNameOf","description":["takes 1 arguments: __`s`__ \n","Return the *base name* of the string *s*, that is, everything\nfollowing the final slash in the string. This is similar to the GNU\n`basename` command.\n"]},{"category":"builtins","fn_type":"bitAnd :: int -> int -> int","name":"bitAnd","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the bitwise AND of the integers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"bitOr :: int -> int -> int","name":"bitOr","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the bitwise OR of the integers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"bitXor :: int -> int -> int","name":"bitXor","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the bitwise XOR of the integers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"break :: a -> a","name":"break","description":["takes 1 arguments: __`v`__ \n","In debug mode (enabled using `--debugger`), pause Nix expression evaluation and enter the REPL.\nOtherwise, return the argument `v`.\n"]},{"category":"builtins","fn_type":"cattAtrs :: string -> [AttrSet] -> [a]","name":"catAttrs","description":["takes 2 arguments: __`attr` `list`__ \n","Collect each attribute named *attr* from a list of attribute\nsets. Attrsets that don't contain the named attribute are\nignored. For example,\n\n```nix\nbuiltins.catAttrs \"a\" [{a = 1;} {b = 0;} {a = 2;}]\n```\n\nevaluates to `[1 2]`.\n"]},{"category":"builtins","fn_type":"ceil :: double -> int","name":"ceil","description":["takes 1 arguments: __`double`__ \n","Converts an IEEE-754 double-precision floating-point number (*double*) to\nthe next higher integer.\n\nIf the datatype is neither an integer nor a \"float\", an evaluation error will be\nthrown.\n"]},{"category":"builtins","fn_type":"compareVersions :: string -> string -> int","name":"compareVersions","description":["takes 2 arguments: __`s1` `s2`__ \n","Compare two strings representing versions and return `-1` if\nversion *s1* is older than version *s2*, `0` if they are the same,\nand `1` if *s1* is newer than *s2*. The version comparison\nalgorithm is the same as the one used by [`nix-env\n-u`](../command-ref/nix-env.md#operation---upgrade).\n"]},{"category":"builtins","fn_type":"concatLists :: [list] -> []","name":"concatLists","description":["takes 1 arguments: __`lists`__ \n","Concatenate a list of lists into a single list.\n"]},{"category":"builtins","fn_type":"concatMap :: (a -> b) -> [a] -> [b]","name":"concatMap","description":["takes 2 arguments: __`f` `list`__ \n","This function is equivalent to `builtins.concatLists (map f list)`\nbut is more efficient.\n"]},{"category":"builtins","fn_type":"concatStringsSep :: string -> [string] -> string","name":"concatStringsSep","description":["takes 2 arguments: __`separator` `list`__ \n","Concatenate a list of strings with a separator between each\nelement, e.g. `concatStringsSep \"/\" [\"usr\" \"local\" \"bin\"] ==\n\"usr/local/bin\"`.\n"]},{"category":"builtins","fn_type":"deepSeq :: a -> b -> b","name":"deepSeq","description":["takes 2 arguments: __`e1` `e2`__ \n","This is like `seq e1 e2`, except that *e1* is evaluated *deeply*:\nif its a list or set, its elements or attributes are also\nevaluated recursively.\n"]},{"category":"builtins","fn_type":"dirOf :: string -> string","name":"dirOf","description":["takes 1 arguments: __`s`__ \n","Return the directory part of the string *s*, that is, everything\nbefore the final slash in the string. This is similar to the GNU\n`dirname` command.\n"]},{"category":"builtins","fn_type":"div :: number -> number -> number","name":"div","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the quotient of the numbers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"elem :: a -> [b] -> bool","name":"elem","description":["takes 2 arguments: __`x` `xs`__ \n","Return `true` if a value equal to *x* occurs in the list *xs*, and\n`false` otherwise.\n"]},{"category":"builtins","fn_type":"elemAt :: [a] -> int -> b","name":"elemAt","description":["takes 2 arguments: __`xs` `n`__ \n","Return element *n* from the list *xs*. Elements are counted starting\nfrom 0. A fatal error occurs if the index is out of bounds.\n"]},{"category":"builtins","fn_type":"fetchClosure :: attrSet -> attrSet","name":"fetchClosure","description":["takes 1 arguments: __`args`__ \n","Fetch a Nix store closure from a binary cache, rewriting it into\ncontent-addressed form. For example,\n\n```nix\nbuiltins.fetchClosure {\n fromStore = \"https://cache.nixos.org\";\n fromPath = /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1;\n toPath = /nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1;\n}\n```\n\nfetches `/nix/store/r2jd...` from the specified binary cache,\nand rewrites it into the content-addressed store path\n`/nix/store/ldbh...`.\n\nIf `fromPath` is already content-addressed, or if you are\nallowing impure evaluation (`--impure`), then `toPath` may be\nomitted.\n\nTo find out the correct value for `toPath` given a `fromPath`,\nyou can use `nix store make-content-addressed`:\n\n```console\n# nix store make-content-addressed --from https://cache.nixos.org /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1\nrewrote '/nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1' to '/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1'\n```\n\nThis function is similar to `builtins.storePath` in that it\nallows you to use a previously built store path in a Nix\nexpression. However, it is more reproducible because it requires\nspecifying a binary cache from which the path can be fetched.\nAlso, requiring a content-addressed final store path avoids the\nneed for users to configure binary cache public keys.\n\nThis function is only available if you enable the experimental\nfeature `fetch-closure`.\n"]},{"category":"builtins","fn_type":"fetchgit :: attrSet -> attrSet","name":"fetchGit","description":["takes 1 arguments: __`args`__ \n","Fetch a path from git. *args* can be a URL, in which case the HEAD\nof the repo at that URL is fetched. Otherwise, it can be an\nattribute with the following attributes (all except `url` optional):\n\n - url\\\n The URL of the repo.\n\n - name\\\n The name of the directory the repo should be exported to in the\n store. Defaults to the basename of the URL.\n\n - rev\\\n The git revision to fetch. Defaults to the tip of `ref`.\n\n - ref\\\n The git ref to look for the requested revision under. This is\n often a branch or tag name. Defaults to `HEAD`.\n\n By default, the `ref` value is prefixed with `refs/heads/`. As\n of Nix 2.3.0 Nix will not prefix `refs/heads/` if `ref` starts\n with `refs/`.\n\n - submodules\\\n A Boolean parameter that specifies whether submodules should be\n checked out. Defaults to `false`.\n\n - shallow\\\n A Boolean parameter that specifies whether fetching a shallow clone\n is allowed. Defaults to `false`.\n\n - allRefs\\\n Whether to fetch all refs of the repository. With this argument being\n true, it's possible to load a `rev` from *any* `ref` (by default only\n `rev`s from the specified `ref` are supported).\n\nHere are some examples of how to use `fetchGit`.\n\n - To fetch a private repository over SSH:\n\n ```nix\n builtins.fetchGit {\n url = \"git@github.com:my-secret/repository.git\";\n ref = \"master\";\n rev = \"adab8b916a45068c044658c4158d81878f9ed1c3\";\n }\n ```\n\n - To fetch an arbitrary reference:\n\n ```nix\n builtins.fetchGit {\n url = \"https://github.com/NixOS/nix.git\";\n ref = \"refs/heads/0.5-release\";\n }\n ```\n\n - If the revision you're looking for is in the default branch of\n the git repository you don't strictly need to specify the branch\n name in the `ref` attribute.\n\n However, if the revision you're looking for is in a future\n branch for the non-default branch you will need to specify the\n the `ref` attribute as well.\n\n ```nix\n builtins.fetchGit {\n url = \"https://github.com/nixos/nix.git\";\n rev = \"841fcbd04755c7a2865c51c1e2d3b045976b7452\";\n ref = \"1.11-maintenance\";\n }\n ```\n\n > **Note**\n >\n > It is nice to always specify the branch which a revision\n > belongs to. Without the branch being specified, the fetcher\n > might fail if the default branch changes. Additionally, it can\n > be confusing to try a commit from a non-default branch and see\n > the fetch fail. If the branch is specified the fault is much\n > more obvious.\n\n - If the revision you're looking for is in the default branch of\n the git repository you may omit the `ref` attribute.\n\n ```nix\n builtins.fetchGit {\n url = \"https://github.com/nixos/nix.git\";\n rev = \"841fcbd04755c7a2865c51c1e2d3b045976b7452\";\n }\n ```\n\n - To fetch a specific tag:\n\n ```nix\n builtins.fetchGit {\n url = \"https://github.com/nixos/nix.git\";\n ref = \"refs/tags/1.9\";\n }\n ```\n\n - To fetch the latest version of a remote branch:\n\n ```nix\n builtins.fetchGit {\n url = \"ssh://git@github.com/nixos/nix.git\";\n ref = \"master\";\n }\n ```\n\n > **Note**\n >\n > Nix will refetch the branch in accordance with\n > the option `tarball-ttl`.\n\n > **Note**\n >\n > This behavior is disabled in *Pure evaluation mode*.\n"]},{"category":"builtins","fn_type":"fetchTarball :: attrSet -> attrSet","name":"fetchTarball","description":["takes 1 arguments: __`args`__ \n","Download the specified URL, unpack it and return the path of the\nunpacked tree. The file must be a tape archive (`.tar`) compressed\nwith `gzip`, `bzip2` or `xz`. The top-level path component of the\nfiles in the tarball is removed, so it is best if the tarball\ncontains a single directory at top level. The typical use of the\nfunction is to obtain external Nix expression dependencies, such as\na particular version of Nixpkgs, e.g.\n\n```nix\nwith import (fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-14.12.tar.gz) {};\n\nstdenv.mkDerivation { … }\n```\n\nThe fetched tarball is cached for a certain amount of time (1\nhour by default) in `~/.cache/nix/tarballs/`. You can change the\ncache timeout either on the command line with `--tarball-ttl`\n*number-of-seconds* or in the Nix configuration file by adding\nthe line `tarball-ttl = ` *number-of-seconds*.\n\nNote that when obtaining the hash with `nix-prefetch-url` the\noption `--unpack` is required.\n\nThis function can also verify the contents against a hash. In that\ncase, the function takes a set instead of a URL. The set requires\nthe attribute `url` and the attribute `sha256`, e.g.\n\n```nix\nwith import (fetchTarball {\n url = \"https://github.com/NixOS/nixpkgs/archive/nixos-14.12.tar.gz\";\n sha256 = \"1jppksrfvbk5ypiqdz4cddxdl8z6zyzdb2srq8fcffr327ld5jj2\";\n}) {};\n\nstdenv.mkDerivation { … }\n```\n\nThis function is not available if [restricted evaluation\nmode](../command-ref/conf-file.md) is enabled.\n"]},{"category":"builtins","fn_type":"fetchurl :: string -> attrSet","name":"fetchurl","description":["takes 1 arguments: __`url`__ \n","Download the specified URL and return the path of the downloaded\nfile. This function is not available if [restricted evaluation\nmode](../command-ref/conf-file.md) is enabled.\n"]},{"category":"builtins","fn_type":"filter :: (a -> bool) -> [a] -> [b]","name":"filter","description":["takes 2 arguments: __`f` `list`__ \n","Return a list consisting of the elements of *list* for which the\nfunction *f* returns `true`.\n"]},{"category":"builtins","fn_type":"filterSource :: (path :: string -> type :: string -> bool) -> path -> storePath :: string","name":"filterSource","description":["takes 2 arguments: __`e1` `e2`__ \n","> **Warning**\n>\n> `filterSource` should not be used to filter store paths. Since\n> `filterSource` uses the name of the input directory while naming\n> the output directory, doing so will produce a directory name in\n> the form of `<hash2>-<hash>-<name>`, where `<hash>-<name>` is\n> the name of the input directory. Since `<hash>` depends on the\n> unfiltered directory, the name of the output directory will\n> indirectly depend on files that are filtered out by the\n> function. This will trigger a rebuild even when a filtered out\n> file is changed. Use `builtins.path` instead, which allows\n> specifying the name of the output directory.\n\nThis function allows you to copy sources into the Nix store while\nfiltering certain files. For instance, suppose that you want to use\nthe directory `source-dir` as an input to a Nix expression, e.g.\n\n```nix\nstdenv.mkDerivation {\n ...\n src = ./source-dir;\n}\n```\n\nHowever, if `source-dir` is a Subversion working copy, then all\nthose annoying `.svn` subdirectories will also be copied to the\nstore. Worse, the contents of those directories may change a lot,\ncausing lots of spurious rebuilds. With `filterSource` you can\nfilter out the `.svn` directories:\n\n```nix\nsrc = builtins.filterSource\n (path: type: type != \"directory\" || baseNameOf path != \".svn\")\n ./source-dir;\n```\n\nThus, the first argument *e1* must be a predicate function that is\ncalled for each regular file, directory or symlink in the source\ntree *e2*. If the function returns `true`, the file is copied to the\nNix store, otherwise it is omitted. The function is called with two\narguments. The first is the full path of the file. The second is a\nstring that identifies the type of the file, which is either\n`\"regular\"`, `\"directory\"`, `\"symlink\"` or `\"unknown\"` (for other\nkinds of files such as device nodes or fifos — but note that those\ncannot be copied to the Nix store, so if the predicate returns\n`true` for them, the copy will fail). If you exclude a directory,\nthe entire corresponding subtree of *e2* will be excluded.\n"]},{"category":"builtins","fn_type":"floor :: double -> int","name":"floor","description":["takes 1 arguments: __`double`__ \n","Converts an IEEE-754 double-precision floating-point number (*double*) to\nthe next lower integer.\n\nIf the datatype is neither an integer nor a \"float\", an evaluation error will be\nthrown.\n"]},{"category":"builtins","fn_type":"foldl' :: (acc :: a -> curr :: b -> c) -> init :: a -> [b] -> c","name":"foldl'","description":["takes 3 arguments: __`op` `nul` `list`__ \n","Reduce a list by applying a binary operator, from left to right,\ne.g. `foldl' op nul [x0 x1 x2 ...] = op (op (op nul x0) x1) x2)\n...`. The operator is applied strictly, i.e., its arguments are\nevaluated first. For example, `foldl' (x: y: x + y) 0 [1 2 3]`\nevaluates to 6.\n"]},{"category":"builtins","fn_type":"fromJSON :: string -> a","name":"fromJSON","description":["takes 1 arguments: __`e`__ \n","Convert a JSON string to a Nix value. For example,\n\n```nix\nbuiltins.fromJSON ''{\"x\": [1, 2, 3], \"y\": null}''\n```\n\nreturns the value `{ x = [ 1 2 3 ]; y = null; }`.\n"]},{"category":"builtins","fn_type":"functionArgs :: (a) -> attrSet","name":"functionArgs","description":["takes 1 arguments: __`f`__ \n","Return a set containing the names of the formal arguments expected\nby the function *f*. The value of each attribute is a Boolean\ndenoting whether the corresponding argument has a default value. For\ninstance, `functionArgs ({ x, y ? 123}: ...) = { x = false; y =\ntrue; }`.\n\n\"Formal argument\" here refers to the attributes pattern-matched by\nthe function. Plain lambdas are not included, e.g. `functionArgs (x:\n...) = { }`.\n"]},{"category":"builtins","fn_type":"genList :: (a -> b) -> a -> [b]","name":"genList","description":["takes 2 arguments: __`generator` `length`__ \n","Generate list of size *length*, with each element *i* equal to the\nvalue returned by *generator* `i`. For example,\n\n```nix\nbuiltins.genList (x: x * x) 5\n```\n\nreturns the list `[ 0 1 4 9 16 ]`.\n"]},{"category":"builtins","fn_type":"genericClosure :: attrSet -> [attrSet]","name":"genericClosure","description":["takes 1 arguments: __`attrset`__ \n","Take an *attrset* with values named `startSet` and `operator` in order to\nreturn a *list of attrsets* by starting with the `startSet`, recursively\napplying the `operator` function to each element. The *attrsets* in the\n`startSet` and produced by the `operator` must each contain value named\n`key` which are comparable to each other. The result is produced by\nrepeatedly calling the operator for each element encountered with a\nunique key, terminating when no new elements are produced. For example,\n\n```\nbuiltins.genericClosure {\n startSet = [ {key = 5;} ];\n operator = item: [{\n key = if (item.key / 2 ) * 2 == item.key\n then item.key / 2\n else 3 * item.key + 1;\n }];\n}\n```\nevaluates to\n```\n[ { key = 5; } { key = 16; } { key = 8; } { key = 4; } { key = 2; } { key = 1; } ]\n```\n"]},{"category":"builtins","fn_type":"getAttr :: string -> attrSet -> a","name":"getAttr","description":["takes 2 arguments: __`s` `set`__ \n","`getAttr` returns the attribute named *s* from *set*. Evaluation\naborts if the attribute doesnt exist. This is a dynamic version of\nthe `.` operator, since *s* is an expression rather than an\nidentifier.\n"]},{"category":"builtins","fn_type":"getEnv :: string -> string","name":"getEnv","description":["takes 1 arguments: __`s`__ \n","`getEnv` returns the value of the environment variable *s*, or an\nempty string if the variable doesnt exist. This function should be\nused with care, as it can introduce all sorts of nasty environment\ndependencies in your Nix expression.\n\n`getEnv` is used in Nix Packages to locate the file\n`~/.nixpkgs/config.nix`, which contains user-local settings for Nix\nPackages. (That is, it does a `getEnv \"HOME\"` to locate the users\nhome directory.)\n"]},{"category":"builtins","fn_type":"getFlake :: attrSet -> attrSet","name":"getFlake","description":["takes 1 arguments: __`args`__ \n","Fetch a flake from a flake reference, and return its output attributes and some metadata. For example:\n\n```nix\n(builtins.getFlake \"nix/55bc52401966fbffa525c574c14f67b00bc4fb3a\").packages.x86_64-linux.nix\n```\n\nUnless impure evaluation is allowed (`--impure`), the flake reference\nmust be \"locked\", e.g. contain a Git revision or content hash. An\nexample of an unlocked usage is:\n\n```nix\n(builtins.getFlake \"github:edolstra/dwarffs\").rev\n```\n\nThis function is only available if you enable the experimental feature\n`flakes`.\n"]},{"category":"builtins","fn_type":"groupBy :: (a -> b) -> [a] -> attrSet","name":"groupBy","description":["takes 2 arguments: __`f` `list`__ \n","Groups elements of *list* together by the string returned from the\nfunction *f* called on each element. It returns an attribute set\nwhere each attribute value contains the elements of *list* that are\nmapped to the same corresponding attribute name returned by *f*.\n\nFor example,\n\n```nix\nbuiltins.groupBy (builtins.substring 0 1) [\"foo\" \"bar\" \"baz\"]\n```\n\nevaluates to\n\n```nix\n{ b = [ \"bar\" \"baz\" ]; f = [ \"foo\" ]; }\n```\n"]},{"category":"builtins","fn_type":"hasAttr :: string -> attrSet -> bool","name":"hasAttr","description":["takes 2 arguments: __`s` `set`__ \n","`hasAttr` returns `true` if *set* has an attribute named *s*, and\n`false` otherwise. This is a dynamic version of the `?` operator,\nsince *s* is an expression rather than an identifier.\n"]},{"category":"builtins","fn_type":"hashFile :: string -> path -> string","name":"hashFile","description":["takes 2 arguments: __`type` `p`__ \n","Return a base-16 representation of the cryptographic hash of the\nfile at path *p*. The hash algorithm specified by *type* must be one\nof `\"md5\"`, `\"sha1\"`, `\"sha256\"` or `\"sha512\"`.\n"]},{"category":"builtins","fn_type":"hashString :: string -> string -> string","name":"hashString","description":["takes 2 arguments: __`type` `s`__ \n","Return a base-16 representation of the cryptographic hash of string\n*s*. The hash algorithm specified by *type* must be one of `\"md5\"`,\n`\"sha1\"`, `\"sha256\"` or `\"sha512\"`.\n"]},{"category":"builtins","fn_type":"head :: [a] -> a","name":"head","description":["takes 1 arguments: __`list`__ \n","Return the first element of a list; abort evaluation if the argument\nisnt a list or is an empty list. You can test whether a list is\nempty by comparing it with `[]`.\n"]},{"category":"builtins","fn_type":"import :: path -> a","name":"import","description":["takes 1 arguments: __`path`__ \n","Load, parse and return the Nix expression in the file *path*. If\n*path* is a directory, the file ` default.nix ` in that directory\nis loaded. Evaluation aborts if the file doesnt exist or contains\nan incorrect Nix expression. `import` implements Nixs module\nsystem: you can put any Nix expression (such as a set or a\nfunction) in a separate file, and use it from Nix expressions in\nother files.\n\n> **Note**\n>\n> Unlike some languages, `import` is a regular function in Nix.\n> Paths using the angle bracket syntax (e.g., `import` *\\<foo\\>*)\n> are [normal path values](language-values.md).\n\nA Nix expression loaded by `import` must not contain any *free\nvariables* (identifiers that are not defined in the Nix expression\nitself and are not built-in). Therefore, it cannot refer to\nvariables that are in scope at the call site. For instance, if you\nhave a calling expression\n\n```nix\nrec {\n x = 123;\n y = import ./foo.nix;\n}\n```\n\nthen the following `foo.nix` will give an error:\n\n```nix\nx + 456\n```\n\nsince `x` is not in scope in `foo.nix`. If you want `x` to be\navailable in `foo.nix`, you should pass it as a function argument:\n\n```nix\nrec {\n x = 123;\n y = import ./foo.nix x;\n}\n```\n\nand\n\n```nix\nx: x + 456\n```\n\n(The function argument doesnt have to be called `x` in `foo.nix`;\nany name would work.)\n"]},{"category":"builtins","fn_type":"intersectAttrs :: attrSet -> attrSet -> attrSet","name":"intersectAttrs","description":["takes 2 arguments: __`e1` `e2`__ \n","Return a set consisting of the attributes in the set *e2* that also\nexist in the set *e1*.\n"]},{"category":"builtins","fn_type":"isAttrs :: a -> bool","name":"isAttrs","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a set, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isBool :: a -> bool","name":"isBool","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a bool, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isFloat :: a -> bool","name":"isFloat","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a float, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isFunction :: a -> bool","name":"isFunction","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a function, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isInt :: a -> bool","name":"isInt","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to an integer, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isList :: a -> bool","name":"isList","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a list, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isNull :: a -> bool","name":"isNull","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to `null`, and `false` otherwise.\n\n> **Warning**\n>\n> This function is *deprecated*; just write `e == null` instead.\n"]},{"category":"builtins","fn_type":"isPath :: a -> bool","name":"isPath","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a path, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"isString :: a -> bool","name":"isString","description":["takes 1 arguments: __`e`__ \n","Return `true` if *e* evaluates to a string, and `false` otherwise.\n"]},{"category":"builtins","fn_type":"length :: [a] -> int","name":"length","description":["takes 1 arguments: __`e`__ \n","Return the length of the list *e*.\n"]},{"category":"builtins","fn_type":"lessThan :: number -> number -> bool","name":"lessThan","description":["takes 2 arguments: __`e1` `e2`__ \n","Return `true` if the number *e1* is less than the number *e2*, and\n`false` otherwise. Evaluation aborts if either *e1* or *e2* does not\nevaluate to a number.\n"]},{"category":"builtins","fn_type":"listToAttrs :: [{name :: string; value :: a}] -> attrSet","name":"listToAttrs","description":["takes 1 arguments: __`e`__ \n","Construct a set from a list specifying the names and values of each\nattribute. Each element of the list should be a set consisting of a\nstring-valued attribute `name` specifying the name of the attribute,\nand an attribute `value` specifying its value. Example:\n\n```nix\nbuiltins.listToAttrs\n [ { name = \"foo\"; value = 123; }\n { name = \"bar\"; value = 456; }\n ]\n```\n\nevaluates to\n\n```nix\n{ foo = 123; bar = 456; }\n```\n"]},{"category":"builtins","fn_type":"map :: (a -> b) -> [a] -> [b]","name":"map","description":["takes 2 arguments: __`f` `list`__ \n","Apply the function *f* to each element in the list *list*. For\nexample,\n\n```nix\nmap (x: \"foo\" + x) [ \"bar\" \"bla\" \"abc\" ]\n```\n\nevaluates to `[ \"foobar\" \"foobla\" \"fooabc\" ]`.\n"]},{"category":"builtins","fn_type":"mapAttrs :: (a -> b -> c) -> attrSet -> attrSet","name":"mapAttrs","description":["takes 2 arguments: __`f` `attrset`__ \n","Apply function *f* to every element of *attrset*. For example,\n\n```nix\nbuiltins.mapAttrs (name: value: value * 10) { a = 1; b = 2; }\n```\n\nevaluates to `{ a = 10; b = 20; }`.\n"]},{"category":"builtins","fn_type":"match :: string -> string -> bool","name":"match","description":["takes 2 arguments: __`regex` `str`__ \n","Returns a list if the [extended POSIX regular\nexpression](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04)\n*regex* matches *str* precisely, otherwise returns `null`. Each item\nin the list is a regex group.\n\n```nix\nbuiltins.match \"ab\" \"abc\"\n```\n\nEvaluates to `null`.\n\n```nix\nbuiltins.match \"abc\" \"abc\"\n```\n\nEvaluates to `[ ]`.\n\n```nix\nbuiltins.match \"a(b)(c)\" \"abc\"\n```\n\nEvaluates to `[ \"b\" \"c\" ]`.\n\n```nix\nbuiltins.match \"[[:space:]]+([[:upper:]]+)[[:space:]]+\" \" FOO \"\n```\n\nEvaluates to `[ \"FOO\" ]`.\n"]},{"category":"builtins","fn_type":"mul :: number -> number -> number","name":"mul","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the product of the numbers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"parseDrvName :: string -> attrSet","name":"parseDrvName","description":["takes 1 arguments: __`s`__ \n","Split the string *s* into a package name and version. The package\nname is everything up to but not including the first dash followed\nby a digit, and the version is everything following that dash. The\nresult is returned in a set `{ name, version }`. Thus,\n`builtins.parseDrvName \"nix-0.12pre12876\"` returns `{ name =\n\"nix\"; version = \"0.12pre12876\"; }`.\n"]},{"category":"builtins","fn_type":"partition :: (a -> bool) -> [a] -> attrSet","name":"partition","description":["takes 2 arguments: __`pred` `list`__ \n","Given a predicate function *pred*, this function returns an\nattrset containing a list named `right`, containing the elements\nin *list* for which *pred* returned `true`, and a list named\n`wrong`, containing the elements for which it returned\n`false`. For example,\n\n```nix\nbuiltins.partition (x: x > 10) [1 23 9 3 42]\n```\n\nevaluates to\n\n```nix\n{ right = [ 23 42 ]; wrong = [ 1 9 3 ]; }\n```\n"]},{"category":"builtins","fn_type":"path :: attrSet -> storePath","name":"path","description":["takes 1 arguments: __`args`__ \n","An enrichment of the built-in path type, based on the attributes\npresent in *args*. All are optional except `path`:\n\n - path\\\n The underlying path.\n\n - name\\\n The name of the path when added to the store. This can used to\n reference paths that have nix-illegal characters in their names,\n like `@`.\n\n - filter\\\n A function of the type expected by `builtins.filterSource`,\n with the same semantics.\n\n - recursive\\\n When `false`, when `path` is added to the store it is with a\n flat hash, rather than a hash of the NAR serialization of the\n file. Thus, `path` must refer to a regular file, not a\n directory. This allows similar behavior to `fetchurl`. Defaults\n to `true`.\n\n - sha256\\\n When provided, this is the expected hash of the file at the\n path. Evaluation will fail if the hash is incorrect, and\n providing a hash allows `builtins.path` to be used even when the\n `pure-eval` nix config option is on.\n"]},{"category":"builtins","fn_type":"pathExists :: path -> bool","name":"pathExists","description":["takes 1 arguments: __`path`__ \n","Return `true` if the path *path* exists at evaluation time, and\n`false` otherwise.\n"]},{"category":"builtins","fn_type":"placeholder :: string -> string","name":"placeholder","description":["takes 1 arguments: __`output`__ \n","Return a placeholder string for the specified *output* that will be\nsubstituted by the corresponding output path at build time. Typical\noutputs would be `\"out\"`, `\"bin\"` or `\"dev\"`.\n"]},{"category":"builtins","fn_type":"readDir :: path -> attrSet","name":"readDir","description":["takes 1 arguments: __`path`__ \n","Return the contents of the directory *path* as a set mapping\ndirectory entries to the corresponding file type. For instance, if\ndirectory `A` contains a regular file `B` and another directory\n`C`, then `builtins.readDir ./A` will return the set\n\n```nix\n{ B = \"regular\"; C = \"directory\"; }\n```\n\nThe possible values for the file type are `\"regular\"`,\n`\"directory\"`, `\"symlink\"` and `\"unknown\"`.\n"]},{"category":"builtins","fn_type":"readFile :: path -> string","name":"readFile","description":["takes 1 arguments: __`path`__ \n","Return the contents of the file *path* as a string.\n"]},{"category":"builtins","fn_type":"removeAttrs :: attrSet -> [a] -> attrSet","name":"removeAttrs","description":["takes 2 arguments: __`set` `list`__ \n","Remove the attributes listed in *list* from *set*. The attributes\ndont have to exist in *set*. For instance,\n\n```nix\nremoveAttrs { x = 1; y = 2; z = 3; } [ \"a\" \"x\" \"z\" ]\n```\n\nevaluates to `{ y = 2; }`.\n"]},{"category":"builtins","fn_type":"replaceStrings :: [string] -> [string] -> string -> string","name":"replaceStrings","description":["takes 3 arguments: __`from` `to` `s`__ \n","Given string *s*, replace every occurrence of the strings in *from*\nwith the corresponding string in *to*. For example,\n\n```nix\nbuiltins.replaceStrings [\"oo\" \"a\"] [\"a\" \"i\"] \"foobar\"\n```\n\nevaluates to `\"fabir\"`.\n"]},{"category":"builtins","fn_type":"seq :: a -> b -> b","name":"seq","description":["takes 2 arguments: __`e1` `e2`__ \n","Evaluate *e1*, then evaluate and return *e2*. This ensures that a\ncomputation is strict in the value of *e1*.\n"]},{"category":"builtins","fn_type":"sort :: (a -> b -> bool) -> [a] -> [b]","name":"sort","description":["takes 2 arguments: __`comparator` `list`__ \n","Return *list* in sorted order. It repeatedly calls the function\n*comparator* with two elements. The comparator should return `true`\nif the first element is less than the second, and `false` otherwise.\nFor example,\n\n```nix\nbuiltins.sort builtins.lessThan [ 483 249 526 147 42 77 ]\n```\n\nproduces the list `[ 42 77 147 249 483 526 ]`.\n\nThis is a stable sort: it preserves the relative order of elements\ndeemed equal by the comparator.\n"]},{"category":"builtins","fn_type":"split :: string -> string -> [string]","name":"split","description":["takes 2 arguments: __`regex` `str`__ \n","Returns a list composed of non matched strings interleaved with the\nlists of the [extended POSIX regular\nexpression](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04)\n*regex* matches of *str*. Each item in the lists of matched\nsequences is a regex group.\n\n```nix\nbuiltins.split \"(a)b\" \"abc\"\n```\n\nEvaluates to `[ \"\" [ \"a\" ] \"c\" ]`.\n\n```nix\nbuiltins.split \"([ac])\" \"abc\"\n```\n\nEvaluates to `[ \"\" [ \"a\" ] \"b\" [ \"c\" ] \"\" ]`.\n\n```nix\nbuiltins.split \"(a)|(c)\" \"abc\"\n```\n\nEvaluates to `[ \"\" [ \"a\" null ] \"b\" [ null \"c\" ] \"\" ]`.\n\n```nix\nbuiltins.split \"([[:upper:]]+)\" \" FOO \"\n```\n\nEvaluates to `[ \" \" [ \"FOO\" ] \" \" ]`.\n"]},{"category":"builtins","fn_type":"splitVersion :: string -> [string]","name":"splitVersion","description":["takes 1 arguments: __`s`__ \n","Split a string representing a version into its components, by the\nsame version splitting logic underlying the version comparison in\n[`nix-env -u`](../command-ref/nix-env.md#operation---upgrade).\n"]},{"category":"builtins","fn_type":"storePath :: storePath -> storePath","name":"storePath","description":["takes 1 arguments: __`path`__ \n","This function allows you to define a dependency on an already\nexisting store path. For example, the derivation attribute `src\n= builtins.storePath /nix/store/f1d18v1y…-source` causes the\nderivation to depend on the specified path, which must exist or\nbe substitutable. Note that this differs from a plain path\n(e.g. `src = /nix/store/f1d18v1y…-source`) in that the latter\ncauses the path to be *copied* again to the Nix store, resulting\nin a new path (e.g. `/nix/store/ld01dnzc…-source-source`).\n\nThis function is not available in pure evaluation mode.\n"]},{"category":"builtins","fn_type":"stringLength :: string -> int","name":"stringLength","description":["takes 1 arguments: __`e`__ \n","Return the length of the string *e*. If *e* is not a string,\nevaluation is aborted.\n"]},{"category":"builtins","fn_type":"sub :: number -> number -> number","name":"sub","description":["takes 2 arguments: __`e1` `e2`__ \n","Return the difference between the numbers *e1* and *e2*.\n"]},{"category":"builtins","fn_type":"substring :: int -> int -> string -> string","name":"substring","description":["takes 3 arguments: __`start` `len` `s`__ \n","Return the substring of *s* from character position *start*\n(zero-based) up to but not including *start + len*. If *start* is\ngreater than the length of the string, an empty string is returned,\nand if *start + len* lies beyond the end of the string, only the\nsubstring up to the end of the string is returned. *start* must be\nnon-negative. For example,\n\n```nix\nbuiltins.substring 0 3 \"nixos\"\n```\n\nevaluates to `\"nix\"`.\n"]},{"category":"builtins","fn_type":"tail :: [a] -> a","name":"tail","description":["takes 1 arguments: __`list`__ \n","Return the second to last elements of a list; abort evaluation if\nthe argument isnt a list or is an empty list.\n\n> **Warning**\n>\n> This function should generally be avoided since it's inefficient:\n> unlike Haskell's `tail`, it takes O(n) time, so recursing over a\n> list by repeatedly calling `tail` takes O(n^2) time.\n"]},{"category":"builtins","fn_type":"throw :: string","name":"throw","description":["takes 1 arguments: __`s`__ \n","Throw an error message *s*. This usually aborts Nix expression\nevaluation, but in `nix-env -qa` and other commands that try to\nevaluate a set of derivations to get information about those\nderivations, a derivation that throws an error is silently skipped\n(which is not the case for `abort`).\n"]},{"category":"builtins","fn_type":"toFile :: path -> string -> storePath","name":"toFile","description":["takes 2 arguments: __`name` `s`__ \n","Store the string *s* in a file in the Nix store and return its\npath. The file has suffix *name*. This file can be used as an\ninput to derivations. One application is to write builders\n“inline”. For instance, the following Nix expression combines the\n[Nix expression for GNU Hello](expression-syntax.md) and its\n[build script](build-script.md) into one file:\n\n```nix\n{ stdenv, fetchurl, perl }:\n\nstdenv.mkDerivation {\n name = \"hello-2.1.1\";\n\n builder = builtins.toFile \"builder.sh\" \"\n source $stdenv/setup\n\n PATH=$perl/bin:$PATH\n\n tar xvfz $src\n cd hello-*\n ./configure --prefix=$out\n make\n make install\n \";\n\n src = fetchurl {\n url = \"http://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz\";\n sha256 = \"1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465\";\n };\n inherit perl;\n}\n```\n\nIt is even possible for one file to refer to another, e.g.,\n\n```nix\nbuilder = let\n configFile = builtins.toFile \"foo.conf\" \"\n # This is some dummy configuration file.\n ...\n \";\nin builtins.toFile \"builder.sh\" \"\n source $stdenv/setup\n ...\n cp ${configFile} $out/etc/foo.conf\n\";\n```\n\nNote that `${configFile}` is an\n[antiquotation](language-values.md), so the result of the\nexpression `configFile`\n(i.e., a path like `/nix/store/m7p7jfny445k...-foo.conf`) will be\nspliced into the resulting string.\n\nIt is however *not* allowed to have files mutually referring to each\nother, like so:\n\n```nix\nlet\n foo = builtins.toFile \"foo\" \"...${bar}...\";\n bar = builtins.toFile \"bar\" \"...${foo}...\";\nin foo\n```\n\nThis is not allowed because it would cause a cyclic dependency in\nthe computation of the cryptographic hashes for `foo` and `bar`.\n\nIt is also not possible to reference the result of a derivation. If\nyou are using Nixpkgs, the `writeTextFile` function is able to do\nthat.\n"]},{"category":"builtins","fn_type":"toJSON :: a -> string","name":"toJSON","description":["takes 1 arguments: __`e`__ \n","Return a string containing a JSON representation of *e*. Strings,\nintegers, floats, booleans, nulls and lists are mapped to their JSON\nequivalents. Sets (except derivations) are represented as objects.\nDerivations are translated to a JSON string containing the\nderivations output path. Paths are copied to the store and\nrepresented as a JSON string of the resulting store path.\n"]},{"category":"builtins","fn_type":"toPath :: string -> path","name":"toPath","description":["takes 1 arguments: __`s`__ \n","**DEPRECATED.** Use `/. + \"/path\"` to convert a string into an absolute\npath. For relative paths, use `./. + \"/path\"`.\n"]},{"category":"builtins","fn_type":"toString :: a -> string","name":"toString","description":["takes 1 arguments: __`e`__ \n","Convert the expression *e* to a string. *e* can be:\n\n - A string (in which case the string is returned unmodified).\n\n - A path (e.g., `toString /foo/bar` yields `\"/foo/bar\"`.\n\n - A set containing `{ __toString = self: ...; }` or `{ outPath = ...; }`.\n\n - An integer.\n\n - A list, in which case the string representations of its elements\n are joined with spaces.\n\n - A Boolean (`false` yields `\"\"`, `true` yields `\"1\"`).\n\n - `null`, which yields the empty string.\n"]},{"category":"builtins","fn_type":"toXML :: a -> string","name":"toXML","description":["takes 1 arguments: __`e`__ \n","Return a string containing an XML representation of *e*. The main\napplication for `toXML` is to communicate information with the\nbuilder in a more structured format than plain environment\nvariables.\n\nHere is an example where this is the case:\n\n```nix\n{ stdenv, fetchurl, libxslt, jira, uberwiki }:\n\nstdenv.mkDerivation (rec {\n name = \"web-server\";\n\n buildInputs = [ libxslt ];\n\n builder = builtins.toFile \"builder.sh\" \"\n source $stdenv/setup\n mkdir $out\n echo \"$servlets\" | xsltproc ${stylesheet} - > $out/server-conf.xml ①\n \";\n\n stylesheet = builtins.toFile \"stylesheet.xsl\" ②\n \"<?xml version='1.0' encoding='UTF-8'?>\n <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>\n <xsl:template match='/'>\n <Configure>\n <xsl:for-each select='/expr/list/attrs'>\n <Call name='addWebApplication'>\n <Arg><xsl:value-of select=\\\"attr[@name = 'path']/string/@value\\\" /></Arg>\n <Arg><xsl:value-of select=\\\"attr[@name = 'war']/path/@value\\\" /></Arg>\n </Call>\n </xsl:for-each>\n </Configure>\n </xsl:template>\n </xsl:stylesheet>\n \";\n\n servlets = builtins.toXML [ ③\n { path = \"/bugtracker\"; war = jira + \"/lib/atlassian-jira.war\"; }\n { path = \"/wiki\"; war = uberwiki + \"/uberwiki.war\"; }\n ];\n})\n```\n\nThe builder is supposed to generate the configuration file for a\n[Jetty servlet container](http://jetty.mortbay.org/). A servlet\ncontainer contains a number of servlets (`*.war` files) each\nexported under a specific URI prefix. So the servlet configuration\nis a list of sets containing the `path` and `war` of the servlet\n(①). This kind of information is difficult to communicate with the\nnormal method of passing information through an environment\nvariable, which just concatenates everything together into a\nstring (which might just work in this case, but wouldnt work if\nfields are optional or contain lists themselves). Instead the Nix\nexpression is converted to an XML representation with `toXML`,\nwhich is unambiguous and can easily be processed with the\nappropriate tools. For instance, in the example an XSLT stylesheet\n(at point ②) is applied to it (at point ①) to generate the XML\nconfiguration file for the Jetty server. The XML representation\nproduced at point ③ by `toXML` is as follows:\n\n```xml\n<?xml version='1.0' encoding='utf-8'?>\n<expr>\n <list>\n <attrs>\n <attr name=\"path\">\n <string value=\"/bugtracker\" />\n </attr>\n <attr name=\"war\">\n <path value=\"/nix/store/d1jh9pasa7k2...-jira/lib/atlassian-jira.war\" />\n </attr>\n </attrs>\n <attrs>\n <attr name=\"path\">\n <string value=\"/wiki\" />\n </attr>\n <attr name=\"war\">\n <path value=\"/nix/store/y6423b1yi4sx...-uberwiki/uberwiki.war\" />\n </attr>\n </attrs>\n </list>\n</expr>\n```\n\nNote that we used the `toFile` built-in to write the builder and\nthe stylesheet “inline” in the Nix expression. The path of the\nstylesheet is spliced into the builder using the syntax `xsltproc\n${stylesheet}`.\n"]},{"category":"builtins","fn_type":"trace :: a -> b -> b","name":"trace","description":["takes 2 arguments: __`e1` `e2`__ \n","Evaluate *e1* and print its abstract syntax representation on\nstandard error. Then return *e2*. This function is useful for\ndebugging.\n"]},{"category":"builtins","fn_type":"traceVerbose :: a -> b -> b","name":"traceVerbose","description":["takes 2 arguments: __`e1` `e2`__ \n","Evaluate *e1* and print its abstract syntax representation on standard\nerror if `--trace-verbose` is enabled. Then return *e2*. This function\nis useful for debugging.\n"]},{"category":"builtins","fn_type":"tryEval :: a","name":"tryEval","description":["takes 1 arguments: __`e`__ \n","Try to shallowly evaluate *e*. Return a set containing the\nattributes `success` (`true` if *e* evaluated successfully,\n`false` if an error was thrown) and `value`, equalling *e* if\nsuccessful and `false` otherwise. `tryEval` will only prevent\nerrors created by `throw` or `assert` from being thrown.\nErrors `tryEval` will not catch are for example those created\nby `abort` and type errors generated by builtins. Also note that\nthis doesn't evaluate *e* deeply, so `let e = { x = throw \"\"; };\nin (builtins.tryEval e).success` will be `true`. Using\n`builtins.deepSeq` one can get the expected result:\n`let e = { x = throw \"\"; }; in\n(builtins.tryEval (builtins.deepSeq e e)).success` will be\n`false`.\n"]},{"category":"builtins","fn_type":"typeOf :: a -> string","name":"typeOf","description":["takes 1 arguments: __`e`__ \n","Return a string representing the type of the value *e*, namely\n`\"int\"`, `\"bool\"`, `\"string\"`, `\"path\"`, `\"null\"`, `\"set\"`,\n`\"list\"`, `\"lambda\"` or `\"float\"`.\n"]},{"category":"builtins","fn_type":"zipAttrsWith :: (name:: string -> values :: [a]) -> [a] -> attrSet","name":"zipAttrsWith","description":["takes 2 arguments: __`f` `list`__ \n","Transpose a list of attribute sets into an attribute set of lists,\nthen apply `mapAttrs`.\n\n`f` receives two arguments: the attribute name and a non-empty\nlist of all values encountered for that attribute name.\n\nThe result is an attribute set where the attribute names are the\nunion of the attribute names in each element of `list`. The attribute\nvalues are the return values of `f`.\n\n```nix\nbuiltins.zipAttrsWith\n (name: values: { inherit name values; })\n [ { a = \"x\"; } { a = \"y\"; b = \"z\"; } ]\n```\n\nevaluates to\n\n```\n{\n a = { name = \"a\"; values = [ \"x\" \"y\" ]; };\n b = { name = \"b\"; values = [ \"z\" ]; };\n}\n```\n"]}]