diff --git a/.gitignore b/.gitignore
index 4588e2d..5d0844b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,8 @@
# testing
/coverage
+/models/data/*
+# !/models/data/index.ts
# nix
.direnv/
diff --git a/components/codeHighlight/codeHighlight.tsx b/components/codeHighlight/codeHighlight.tsx
index a8bfbf2..8a9ea78 100644
--- a/components/codeHighlight/codeHighlight.tsx
+++ b/components/codeHighlight/codeHighlight.tsx
@@ -1,4 +1,5 @@
import { Box } from "@mui/material";
+import { ThemeOptions } from "@mui/system";
import { useEffect } from "react";
import Highlight, { HighlightProps } from "react-highlight";
import styles from "./codeHighlight.module.css";
@@ -6,10 +7,12 @@ import styles from "./codeHighlight.module.css";
interface CodeHighlightProps {
theme: "light" | "dark";
code: HighlightProps["children"];
+ lang?: string;
+ background?: ThemeOptions["palette"] | string;
}
export const CodeHighlight = (props: CodeHighlightProps) => {
- const { theme, code } = props;
+ const { theme, code, lang, background } = props;
useEffect(() => {
if (theme === "dark") {
// @ts-ignore - dont check type of css module
@@ -23,13 +26,21 @@ export const CodeHighlight = (props: CodeHighlightProps) => {
return (
pre": {
+ "&.MuiBox-root": {
width: "100%",
marginTop: 0,
},
+ "&.MuiBox-root>pre": {
+ marginTop: 0,
+ },
+ "&.MuiBox-root>pre code.hljs": {
+ bgcolor: background || undefined,
+ },
}}
>
- {code}
+
+ {code}
+
);
};
diff --git a/components/preview/preview.tsx b/components/preview/preview.tsx
index fbc50e4..1771182 100644
--- a/components/preview/preview.tsx
+++ b/components/preview/preview.tsx
@@ -75,9 +75,11 @@ export const Preview = (props: PreviewProps) => {
)}
- {prefix !== "builtins" && (
+ {prefix !== "builtins" && id.includes("lib.") && (
- {`short form: lib.${name}`}
+
+ {`short form: lib.${name}`}
+
)}
@@ -172,13 +174,24 @@ export const Preview = (props: PreviewProps) => {
}}
primaryTypographyProps={{
color: "text.secondary",
+ gutterBottom: true,
fontSize: 14,
}}
secondaryTypographyProps={{
- color: "text.primary",
+ color: fn_type ? "text.primary" : "text.secondary",
fontSize: "1rem",
}}
- secondary={fn_type || "no type provided yet."}
+ secondary={
+ fn_type ? (
+
+ ) : (
+ "no type provided yet."
+ )
+ }
primary="function signature "
/>
@@ -209,7 +222,13 @@ export const Preview = (props: PreviewProps) => {
}
secondary={
-
+
}
/>
diff --git a/flake.lock b/flake.lock
index ab1de49..5b181f0 100644
--- a/flake.lock
+++ b/flake.lock
@@ -315,11 +315,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
- "lastModified": 1673195125,
- "narHash": "sha256-tXasChqzT2L2r3m3wRUIOLpiuxJRRONeknxchPUYiCA=",
+ "lastModified": 1675069119,
+ "narHash": "sha256-iEIPjUIZ3NYcESF5AWj/BPCuO5//r7NvyTzYSZlCaTk=",
"owner": "hsjobeki",
"repo": "nixdoc",
- "rev": "70481a4b453be9e5e24cb357d85036d32150330c",
+ "rev": "c3e3dde0af8f7e2a61db7e3f51768e764b7643e0",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index a55beef..ef1aa37 100644
--- a/flake.nix
+++ b/flake.nix
@@ -12,6 +12,11 @@
system = "x86_64-linux";
pkgs = inp.nixpkgs.legacyPackages.${system};
inherit (builtins.fromJSON (builtins.readFile ./package.json)) name;
+ prepareData = ''
+ cp ${inp.nixdoc-fork.packages.${system}.data.lib} ./models/data/lib.json
+ cp ${inp.nixdoc-fork.packages.${system}.data.build_support} ./models/data/trivial-builders.json
+ node ./scripts/make-builtins.js
+ '';
in
(inp.dream2nix.lib.makeFlakeOutputs {
systemsFromFile = ./nix_systems;
@@ -24,9 +29,7 @@
];
packageOverrides = {
${name}.staticPage = {
- preBuild = ''
- cp ${inp.nixdoc-fork.packages.${system}.data} ./models/lib.json
- '';
+ preBuild = prepareData;
installPhase = ''
runHook preInstall
@@ -43,6 +46,7 @@
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [ nodejs-18_x ];
shellHook = ''
+ ${prepareData}
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
diff --git a/models/data/builtins.json b/models/data/builtins.json
deleted file mode 100644
index 945322d..0000000
--- a/models/data/builtins.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"id":"builtins.abort","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"]},{"id":"builtins.add","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"]},{"id":"builtins.all","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"]},{"id":"builtins.any","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"]},{"id":"builtins.attrNames","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"]},{"id":"builtins.attrValues","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"]},{"id":"builtins.baseNameOf","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"]},{"id":"builtins.bitAnd","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"]},{"id":"builtins.bitOr","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"]},{"id":"builtins.bitXor","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"]},{"id":"builtins.break","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"]},{"id":"builtins.catAttrs","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"]},{"id":"builtins.ceil","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"]},{"id":"builtins.compareVersions","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"]},{"id":"builtins.concatLists","category":"builtins","fn_type":"concatLists :: [list] -> []","name":"concatLists","description":["takes 1 arguments: __`lists`__ \n","Concatenate a list of lists into a single list.\n"]},{"id":"builtins.concatMap","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"]},{"id":"builtins.concatStringsSep","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"]},{"id":"builtins.deepSeq","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 it’s a list or set, its elements or attributes are also\nevaluated recursively.\n"]},{"id":"builtins.dirOf","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"]},{"id":"builtins.div","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"]},{"id":"builtins.elem","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"]},{"id":"builtins.elemAt","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"]},{"id":"builtins.fetchClosure","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"]},{"id":"builtins.fetchGit","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"]},{"id":"builtins.fetchTarball","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"]},{"id":"builtins.fetchurl","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"]},{"id":"builtins.filter","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"]},{"id":"builtins.filterSource","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 `--`, where `-` is\n> the name of the input directory. Since `` 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"]},{"id":"builtins.floor","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"]},{"id":"builtins.foldl'","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"]},{"id":"builtins.fromJSON","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"]},{"id":"builtins.functionArgs","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"]},{"id":"builtins.genList","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"]},{"id":"builtins.genericClosure","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"]},{"id":"builtins.getAttr","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 doesn’t exist. This is a dynamic version of\nthe `.` operator, since *s* is an expression rather than an\nidentifier.\n"]},{"id":"builtins.getEnv","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 doesn’t 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 user’s\nhome directory.)\n"]},{"id":"builtins.getFlake","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"]},{"id":"builtins.groupBy","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"]},{"id":"builtins.hasAttr","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"]},{"id":"builtins.hashFile","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"]},{"id":"builtins.hashString","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"]},{"id":"builtins.head","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\nisn’t a list or is an empty list. You can test whether a list is\nempty by comparing it with `[]`.\n"]},{"id":"builtins.import","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 doesn’t exist or contains\nan incorrect Nix expression. `import` implements Nix’s 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` *\\*)\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 doesn’t have to be called `x` in `foo.nix`;\nany name would work.)\n"]},{"id":"builtins.intersectAttrs","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"]},{"id":"builtins.isAttrs","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"]},{"id":"builtins.isBool","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"]},{"id":"builtins.isFloat","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"]},{"id":"builtins.isFunction","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"]},{"id":"builtins.isInt","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"]},{"id":"builtins.isList","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"]},{"id":"builtins.isNull","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"]},{"id":"builtins.isPath","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"]},{"id":"builtins.isString","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"]},{"id":"builtins.length","category":"builtins","fn_type":"length :: [a] -> int","name":"length","description":["takes 1 arguments: __`e`__ \n","Return the length of the list *e*.\n"]},{"id":"builtins.lessThan","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"]},{"id":"builtins.listToAttrs","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"]},{"id":"builtins.map","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"]},{"id":"builtins.mapAttrs","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"]},{"id":"builtins.match","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"]},{"id":"builtins.mul","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"]},{"id":"builtins.parseDrvName","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"]},{"id":"builtins.partition","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"]},{"id":"builtins.path","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"]},{"id":"builtins.pathExists","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"]},{"id":"builtins.placeholder","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"]},{"id":"builtins.readDir","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"]},{"id":"builtins.readFile","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"]},{"id":"builtins.removeAttrs","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\ndon’t 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"]},{"id":"builtins.replaceStrings","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"]},{"id":"builtins.seq","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"]},{"id":"builtins.sort","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"]},{"id":"builtins.split","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"]},{"id":"builtins.splitVersion","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"]},{"id":"builtins.storePath","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"]},{"id":"builtins.stringLength","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"]},{"id":"builtins.sub","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"]},{"id":"builtins.substring","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"]},{"id":"builtins.tail","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 isn’t 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"]},{"id":"builtins.throw","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"]},{"id":"builtins.toFile","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"]},{"id":"builtins.toJSON","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\nderivation’s output path. Paths are copied to the store and\nrepresented as a JSON string of the resulting store path.\n"]},{"id":"builtins.toPath","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"]},{"id":"builtins.toString","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"]},{"id":"builtins.toXML","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 \"\n \n \n \n \n \n \n \n \n \n \n \n \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 wouldn’t 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\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n\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"]},{"id":"builtins.trace","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"]},{"id":"builtins.traceVerbose","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"]},{"id":"builtins.tryEval","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"]},{"id":"builtins.typeOf","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"]},{"id":"builtins.zipAttrsWith","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"]}]
\ No newline at end of file
diff --git a/models/data/lib.json b/models/data/lib.json
deleted file mode 100644
index ee4615a..0000000
--- a/models/data/lib.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"id":"lib.versions.splitVersion","category":"./lib/versions.nix","name":"splitVersion","fn_type":null,"description":["Break a version string into its component parts."],"example":"\nsplitVersion \"1.2.3\"\n=> [\"1\" \"2\" \"3\"]\n"},{"id":"lib.versions.major","category":"./lib/versions.nix","name":"major","fn_type":null,"description":["Get the major version string from a string."],"example":"\nmajor \"1.2.3\"\n=> \"1\"\n"},{"id":"lib.versions.minor","category":"./lib/versions.nix","name":"minor","fn_type":null,"description":["Get the minor version string from a string."],"example":"\nminor \"1.2.3\"\n=> \"2\"\n"},{"id":"lib.versions.patch","category":"./lib/versions.nix","name":"patch","fn_type":null,"description":["Get the patch version string from a string."],"example":"\npatch \"1.2.3\"\n=> \"3\"\n"},{"id":"lib.versions.majorMinor","category":"./lib/versions.nix","name":"majorMinor","fn_type":null,"description":["Get string of the first two parts (major and minor)\nof a version string."],"example":"\nmajorMinor \"1.2.3\"\n=> \"1.2\"\n"},{"id":"lib.trivial.id","category":"./lib/trivial.nix","name":"id","fn_type":"id :: a -> a","description":["The identity function\nFor when you need a function that does “nothing”."],"example":null},{"id":"lib.trivial.const","category":"./lib/trivial.nix","name":"const","fn_type":"const :: a -> b -> a","description":["The constant function","Ignores the second argument. If called with only one argument,\nconstructs a function that always returns a static value."],"example":"\nlet f = const 5; in f 10\n=> 5\n"},{"id":"lib.trivial.pipe","category":"./lib/trivial.nix","name":"pipe","fn_type":"pipe :: a -> [] -> ","description":["Pipes a value through a list of functions, left to right."],"example":"\npipe 2 [\n(x: x + 2) # 2 + 2 = 4\n(x: x * 2) # 4 * 2 = 8\n]\n=> 8\n\n# ideal to do text transformations\npipe [ \"a/b\" \"a/c\" ] [\n\n# create the cp command\n(map (file: ''cp \"${src}/${file}\" $out\\n''))\n\n# concatenate all commands into one string\nlib.concatStrings\n\n# make that string into a nix derivation\n(pkgs.runCommand \"copy-to-out\" {})\n\n]\n=> \n\nThe output type of each function has to be the input type\nof the next function, and the last function returns the\nfinal value.\n"},{"id":"lib.trivial.concat","category":"./lib/trivial.nix","name":"concat","fn_type":"concat :: [a] -> [a] -> [a]","description":["Concatenate two lists"],"example":"\nconcat [ 1 2 ] [ 3 4 ]\n=> [ 1 2 3 4 ]\n"},{"id":"lib.trivial.or","category":"./lib/trivial.nix","name":"or","fn_type":null,"description":["boolean “or”"],"example":null},{"id":"lib.trivial.and","category":"./lib/trivial.nix","name":"and","fn_type":null,"description":["boolean “and”"],"example":null},{"id":"lib.trivial.bitAnd","category":"./lib/trivial.nix","name":"bitAnd","fn_type":null,"description":["bitwise “and”"],"example":null},{"id":"lib.trivial.bitOr","category":"./lib/trivial.nix","name":"bitOr","fn_type":null,"description":["bitwise “or”"],"example":null},{"id":"lib.trivial.bitXor","category":"./lib/trivial.nix","name":"bitXor","fn_type":null,"description":["bitwise “xor”"],"example":null},{"id":"lib.trivial.bitNot","category":"./lib/trivial.nix","name":"bitNot","fn_type":null,"description":["bitwise “not”"],"example":null},{"id":"lib.trivial.boolToString","category":"./lib/trivial.nix","name":"boolToString","fn_type":"boolToString :: bool -> string","description":["Convert a boolean to a string.","This function uses the strings \"true\" and \"false\" to represent\nboolean values. Calling `toString` on a bool instead returns \"1\"\nand \"\" (sic!)."],"example":null},{"id":"lib.trivial.mergeAttrs","category":"./lib/trivial.nix","name":"mergeAttrs","fn_type":null,"description":["Merge two attribute sets shallowly, right side trumps left","mergeAttrs :: attrs -> attrs -> attrs"],"example":"\nmergeAttrs { a = 1; b = 2; } { b = 3; c = 4; }\n=> { a = 1; b = 3; c = 4; }\n"},{"id":"lib.trivial.flip","category":"./lib/trivial.nix","name":"flip","fn_type":"flip :: (a -> b -> c) -> (b -> a -> c)","description":["Flip the order of the arguments of a binary function."],"example":"\nflip concat [1] [2]\n=> [ 2 1 ]\n"},{"id":"lib.trivial.mapNullable","category":"./lib/trivial.nix","name":"mapNullable","fn_type":null,"description":["Apply function if the supplied argument is non-null."],"example":"\nmapNullable (x: x+1) null\n=> null\nmapNullable (x: x+1) 22\n=> 23\n"},{"id":"lib.trivial.version","category":"./lib/trivial.nix","name":"version","fn_type":null,"description":["Returns the current full nixpkgs version number."],"example":null},{"id":"lib.trivial.release","category":"./lib/trivial.nix","name":"release","fn_type":null,"description":["Returns the current nixpkgs release number as string."],"example":null},{"id":"lib.trivial.oldestSupportedRelease","category":"./lib/trivial.nix","name":"oldestSupportedRelease","fn_type":null,"description":["The latest release that is supported, at the time of release branch-off,\nif applicable.","Ideally, out-of-tree modules should be able to evaluate cleanly with all\nsupported Nixpkgs versions (master, release and old release until EOL).\nSo if possible, deprecation warnings should take effect only when all\nout-of-tree expressions/libs/modules can upgrade to the new way without\nlosing support for supported Nixpkgs versions.","This release number allows deprecation warnings to be implemented such that\nthey take effect as soon as the oldest release reaches end of life."],"example":null},{"id":"lib.trivial.isInOldestRelease","category":"./lib/trivial.nix","name":"isInOldestRelease","fn_type":null,"description":["Whether a feature is supported in all supported releases (at the time of\nrelease branch-off, if applicable). See `oldestSupportedRelease`."],"example":null},{"id":"lib.trivial.codeName","category":"./lib/trivial.nix","name":"codeName","fn_type":null,"description":["Returns the current nixpkgs release code name.","On each release the first letter is bumped and a new animal is chosen\nstarting with that new letter."],"example":null},{"id":"lib.trivial.versionSuffix","category":"./lib/trivial.nix","name":"versionSuffix","fn_type":null,"description":["Returns the current nixpkgs version suffix as string."],"example":null},{"id":"lib.trivial.revisionWithDefault","category":"./lib/trivial.nix","name":"revisionWithDefault","fn_type":"revisionWithDefault :: string -> string","description":["Attempts to return the the current revision of nixpkgs and\nreturns the supplied default value otherwise."],"example":null},{"id":"lib.trivial.inNixShell","category":"./lib/trivial.nix","name":"inNixShell","fn_type":"inNixShell :: bool","description":["Determine whether the function is being called from inside a Nix\nshell."],"example":null},{"id":"lib.trivial.inPureEvalMode","category":"./lib/trivial.nix","name":"inPureEvalMode","fn_type":"inPureEvalMode :: bool","description":["Determine whether the function is being called from inside pure-eval mode\nby seeing whether `builtins` contains `currentSystem`. If not, we must be in\npure-eval mode."],"example":null},{"id":"lib.trivial.min","category":"./lib/trivial.nix","name":"min","fn_type":null,"description":["Return minimum of two numbers."],"example":null},{"id":"lib.trivial.max","category":"./lib/trivial.nix","name":"max","fn_type":null,"description":["Return maximum of two numbers."],"example":null},{"id":"lib.trivial.mod","category":"./lib/trivial.nix","name":"mod","fn_type":null,"description":["Integer modulus"],"example":"\nmod 11 10\n=> 1\nmod 1 10\n=> 1\n"},{"id":"lib.trivial.compare","category":"./lib/trivial.nix","name":"compare","fn_type":null,"description":["C-style comparisons","a < b, compare a b => -1\na == b, compare a b => 0\na > b, compare a b => 1"],"example":null},{"id":"lib.trivial.splitByAndCompare","category":"./lib/trivial.nix","name":"splitByAndCompare","fn_type":"(a -> bool) -> (a -> a -> int) -> (a -> a -> int) -> (a -> a -> int)","description":["Split type into two subtypes by predicate `p`, take all elements\nof the first subtype to be less than all the elements of the\nsecond subtype, compare elements of a single subtype with `yes`\nand `no` respectively."],"example":"\nlet cmp = splitByAndCompare (hasPrefix \"foo\") compare compare; in\n\ncmp \"a\" \"z\" => -1\ncmp \"fooa\" \"fooz\" => -1\n\ncmp \"f\" \"a\" => 1\ncmp \"fooa\" \"a\" => -1\n# while\ncompare \"fooa\" \"a\" => 1\n"},{"id":"lib.trivial.importJSON","category":"./lib/trivial.nix","name":"importJSON","fn_type":null,"description":["Reads a JSON file.","Type :: path -> any"],"example":null},{"id":"lib.trivial.importTOML","category":"./lib/trivial.nix","name":"importTOML","fn_type":null,"description":["Reads a TOML file.","Type :: path -> any"],"example":null},{"id":"lib.trivial.warn","category":"./lib/trivial.nix","name":"warn","fn_type":"string -> a -> a","description":["Print a warning before returning the second argument. This function behaves\nlike `builtins.trace`, but requires a string message and formats it as a\nwarning, including the `warning: ` prefix.","To get a call stack trace and abort evaluation, set the environment variable\n`NIX_ABORT_ON_WARN=true` and set the Nix options `--option pure-eval false --show-trace`"],"example":null},{"id":"lib.trivial.warnIf","category":"./lib/trivial.nix","name":"warnIf","fn_type":"bool -> string -> a -> a","description":["Like warn, but only warn when the first argument is `true`."],"example":null},{"id":"lib.trivial.warnIfNot","category":"./lib/trivial.nix","name":"warnIfNot","fn_type":"bool -> string -> a -> a","description":["Like warnIf, but negated (warn if the first argument is `false`)."],"example":null},{"id":"lib.trivial.throwIfNot","category":"./lib/trivial.nix","name":"throwIfNot","fn_type":"bool -> string -> a -> a","description":["Like the `assert b; e` expression, but with a custom error message and\nwithout the semicolon.","If true, return the identity function, `r: r`.","If false, throw the error message.","Calls can be juxtaposed using function application, as `(r: r) a = a`, so\n`(r: r) (r: r) a = a`, and so forth."],"example":"\n\nthrowIfNot (lib.isList overlays) \"The overlays argument to nixpkgs must be a list.\"\nlib.foldr (x: throwIfNot (lib.isFunction x) \"All overlays passed to nixpkgs must be functions.\") (r: r) overlays\npkgs\n"},{"id":"lib.trivial.throwIf","category":"./lib/trivial.nix","name":"throwIf","fn_type":"bool -> string -> a -> a","description":["Like throwIfNot, but negated (throw if the first argument is `true`)."],"example":null},{"id":"lib.trivial.checkListOfEnum","category":"./lib/trivial.nix","name":"checkListOfEnum","fn_type":"String -> List ComparableVal -> List ComparableVal -> a -> a","description":["Check if the elements in a list are valid values from a enum, returning the identity function, or throwing an error message otherwise."],"example":"\nlet colorVariants = [\"bright\" \"dark\" \"black\"]\nin checkListOfEnum \"color variants\" [ \"standard\" \"light\" \"dark\" ] colorVariants;\n=>\nerror: color variants: bright, black unexpected; valid ones: standard, light, dark\n\n"},{"id":"lib.trivial.setFunctionArgs","category":"./lib/trivial.nix","name":"setFunctionArgs","fn_type":null,"description":["Add metadata about expected function arguments to a function.\nThe metadata should match the format given by\nbuiltins.functionArgs, i.e. a set from expected argument to a bool\nrepresenting whether that argument has a default or not.\nsetFunctionArgs : (a → b) → Map String Bool → (a → b)","This function is necessary because you can't dynamically create a\nfunction of the { a, b ? foo, ... }: format, but some facilities\nlike callPackage expect to be able to query expected arguments."],"example":null},{"id":"lib.trivial.functionArgs","category":"./lib/trivial.nix","name":"functionArgs","fn_type":null,"description":["Extract the expected function arguments from a function.\nThis works both with nix-native { a, b ? foo, ... }: style\nfunctions and functions with args set with 'setFunctionArgs'. It\nhas the same return type and semantics as builtins.functionArgs.\nsetFunctionArgs : (a → b) → Map String Bool."],"example":null},{"id":"lib.trivial.isFunction","category":"./lib/trivial.nix","name":"isFunction","fn_type":null,"description":["Check whether something is a function or something\nannotated with function args."],"example":null},{"id":"lib.trivial.toFunction","category":"./lib/trivial.nix","name":"toFunction","fn_type":null,"description":["Turns any non-callable values into constant functions.\nReturns callable values as is."],"example":"\n\nnix-repl> lib.toFunction 1 2\n1\n\nnix-repl> lib.toFunction (x: x + 1) 2\n3\n"},{"id":"lib.trivial.toHexString","category":"./lib/trivial.nix","name":"toHexString","fn_type":null,"description":["Convert the given positive integer to a string of its hexadecimal\nrepresentation. For example:","toHexString 0 => \"0\"","toHexString 16 => \"10\"","toHexString 250 => \"FA\""],"example":null},{"id":"lib.trivial.toBaseDigits","category":"./lib/trivial.nix","name":"toBaseDigits","fn_type":null,"description":["`toBaseDigits base i` converts the positive integer i to a list of its\ndigits in the given base. For example:","toBaseDigits 10 123 => [ 1 2 3 ]","toBaseDigits 2 6 => [ 1 1 0 ]","toBaseDigits 16 250 => [ 15 10 ]"],"example":null},{"id":"lib.strings.concatStrings","category":"./lib/strings.nix","name":"concatStrings","fn_type":"concatStrings :: [string] -> string","description":["Concatenate a list of strings."],"example":"\nconcatStrings [\"foo\" \"bar\"]\n=> \"foobar\"\n"},{"id":"lib.strings.concatMapStrings","category":"./lib/strings.nix","name":"concatMapStrings","fn_type":"concatMapStrings :: (a -> string) -> [a] -> string","description":["Map a function over a list and concatenate the resulting strings."],"example":"\nconcatMapStrings (x: \"a\" + x) [\"foo\" \"bar\"]\n=> \"afooabar\"\n"},{"id":"lib.strings.concatImapStrings","category":"./lib/strings.nix","name":"concatImapStrings","fn_type":"concatImapStrings :: (int -> a -> string) -> [a] -> string","description":["Like `concatMapStrings` except that the f functions also gets the\nposition as a parameter."],"example":"\nconcatImapStrings (pos: x: \"${toString pos}-${x}\") [\"foo\" \"bar\"]\n=> \"1-foo2-bar\"\n"},{"id":"lib.strings.intersperse","category":"./lib/strings.nix","name":"intersperse","fn_type":"intersperse :: a -> [a] -> [a]","description":["Place an element between each element of a list"],"example":"\nintersperse \"/\" [\"usr\" \"local\" \"bin\"]\n=> [\"usr\" \"/\" \"local\" \"/\" \"bin\"].\n"},{"id":"lib.strings.concatStringsSep","category":"./lib/strings.nix","name":"concatStringsSep","fn_type":"concatStringsSep :: string -> [string] -> string","description":["Concatenate a list of strings with a separator between each element"],"example":"\nconcatStringsSep \"/\" [\"usr\" \"local\" \"bin\"]\n=> \"usr/local/bin\"\n"},{"id":"lib.strings.concatMapStringsSep","category":"./lib/strings.nix","name":"concatMapStringsSep","fn_type":"concatMapStringsSep :: string -> (a -> string) -> [a] -> string","description":["Maps a function over a list of strings and then concatenates the\nresult with the specified separator interspersed between\nelements."],"example":"\nconcatMapStringsSep \"-\" (x: toUpper x) [\"foo\" \"bar\" \"baz\"]\n=> \"FOO-BAR-BAZ\"\n"},{"id":"lib.strings.concatImapStringsSep","category":"./lib/strings.nix","name":"concatImapStringsSep","fn_type":"concatIMapStringsSep :: string -> (int -> a -> string) -> [a] -> string","description":["Same as `concatMapStringsSep`, but the mapping function\nadditionally receives the position of its argument."],"example":"\nconcatImapStringsSep \"-\" (pos: x: toString (x / pos)) [ 6 6 6 ]\n=> \"6-3-2\"\n"},{"id":"lib.strings.makeSearchPath","category":"./lib/strings.nix","name":"makeSearchPath","fn_type":"makeSearchPath :: string -> [string] -> string","description":["Construct a Unix-style, colon-separated search path consisting of\nthe given `subDir` appended to each of the given paths."],"example":"\nmakeSearchPath \"bin\" [\"/root\" \"/usr\" \"/usr/local\"]\n=> \"/root/bin:/usr/bin:/usr/local/bin\"\nmakeSearchPath \"bin\" [\"\"]\n=> \"/bin\"\n"},{"id":"lib.strings.makeSearchPathOutput","category":"./lib/strings.nix","name":"makeSearchPathOutput","fn_type":"string -> string -> [package] -> string","description":["Construct a Unix-style search path by appending the given\n`subDir` to the specified `output` of each of the packages. If no\noutput by the given name is found, fallback to `.out` and then to\nthe default."],"example":"\nmakeSearchPathOutput \"dev\" \"bin\" [ pkgs.openssl pkgs.zlib ]\n=> \"/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev/bin:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/bin\"\n"},{"id":"lib.strings.makeLibraryPath","category":"./lib/strings.nix","name":"makeLibraryPath","fn_type":null,"description":["Construct a library search path (such as RPATH) containing the\nlibraries for a set of packages"],"example":"\nmakeLibraryPath [ \"/usr\" \"/usr/local\" ]\n=> \"/usr/lib:/usr/local/lib\"\npkgs = import { }\nmakeLibraryPath [ pkgs.openssl pkgs.zlib ]\n=> \"/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r/lib:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/lib\"\n"},{"id":"lib.strings.makeBinPath","category":"./lib/strings.nix","name":"makeBinPath","fn_type":null,"description":["Construct a binary search path (such as $PATH) containing the\nbinaries for a set of packages."],"example":"\nmakeBinPath [\"/root\" \"/usr\" \"/usr/local\"]\n=> \"/root/bin:/usr/bin:/usr/local/bin\"\n"},{"id":"lib.strings.normalizePath","category":"./lib/strings.nix","name":"normalizePath","fn_type":"normalizePath :: string -> string","description":["Normalize path, removing extranous /s"],"example":"\nnormalizePath \"/a//b///c/\"\n=> \"/a/b/c/\"\n"},{"id":"lib.strings.optionalString","category":"./lib/strings.nix","name":"optionalString","fn_type":"optionalString :: bool -> string -> string","description":["Depending on the boolean `cond', return either the given string\nor the empty string. Useful to concatenate against a bigger string."],"example":"\noptionalString true \"some-string\"\n=> \"some-string\"\noptionalString false \"some-string\"\n=> \"\"\n"},{"id":"lib.strings.hasPrefix","category":"./lib/strings.nix","name":"hasPrefix","fn_type":"hasPrefix :: string -> string -> bool","description":["Determine whether a string has given prefix."],"example":"\nhasPrefix \"foo\" \"foobar\"\n=> true\nhasPrefix \"foo\" \"barfoo\"\n=> false\n"},{"id":"lib.strings.hasSuffix","category":"./lib/strings.nix","name":"hasSuffix","fn_type":"hasSuffix :: string -> string -> bool","description":["Determine whether a string has given suffix."],"example":"\nhasSuffix \"foo\" \"foobar\"\n=> false\nhasSuffix \"foo\" \"barfoo\"\n=> true\n"},{"id":"lib.strings.hasInfix","category":"./lib/strings.nix","name":"hasInfix","fn_type":"hasInfix :: string -> string -> bool","description":["Determine whether a string contains the given infix"],"example":"\nhasInfix \"bc\" \"abcd\"\n=> true\nhasInfix \"ab\" \"abcd\"\n=> true\nhasInfix \"cd\" \"abcd\"\n=> true\nhasInfix \"foo\" \"abcd\"\n=> false\n"},{"id":"lib.strings.stringToCharacters","category":"./lib/strings.nix","name":"stringToCharacters","fn_type":"stringToCharacters :: string -> [string]","description":["Convert a string to a list of characters (i.e. singleton strings).\nThis allows you to, e.g., map a function over each character. However,\nnote that this will likely be horribly inefficient; Nix is not a\ngeneral purpose programming language. Complex string manipulations\nshould, if appropriate, be done in a derivation.\nAlso note that Nix treats strings as a list of bytes and thus doesn't\nhandle unicode."],"example":"\nstringToCharacters \"\"\n=> [ ]\nstringToCharacters \"abc\"\n=> [ \"a\" \"b\" \"c\" ]\nstringToCharacters \"💩\"\n=> [ \"�\" \"�\" \"�\" \"�\" ]\n"},{"id":"lib.strings.stringAsChars","category":"./lib/strings.nix","name":"stringAsChars","fn_type":"stringAsChars :: (string -> string) -> string -> string","description":["Manipulate a string character by character and replace them by\nstrings before concatenating the results."],"example":"\nstringAsChars (x: if x == \"a\" then \"i\" else x) \"nax\"\n=> \"nix\"\n"},{"id":"lib.strings.charToInt","category":"./lib/strings.nix","name":"charToInt","fn_type":"charToInt :: string -> int","description":["Convert char to ascii value, must be in printable range"],"example":"\ncharToInt \"A\"\n=> 65\ncharToInt \"(\"\n=> 40\n"},{"id":"lib.strings.escape","category":"./lib/strings.nix","name":"escape","fn_type":"escape :: [string] -> string -> string","description":["Escape occurrence of the elements of `list` in `string` by\nprefixing it with a backslash."],"example":"\nescape [\"(\" \")\"] \"(foo)\"\n=> \"\\\\(foo\\\\)\"\n"},{"id":"lib.strings.escapeC","category":"./lib/strings.nix","name":"escapeC","fn_type":"escapeC = [string] -> string -> string","description":["Escape occurence of the element of `list` in `string` by\nconverting to its ASCII value and prefixing it with \\\\x.\nOnly works for printable ascii characters."],"example":"\nescapeC [\" \"] \"foo bar\"\n=> \"foo\\\\x20bar\"\n"},{"id":"lib.strings.escapeShellArg","category":"./lib/strings.nix","name":"escapeShellArg","fn_type":"escapeShellArg :: string -> string","description":["Quote string to be used safely within the Bourne shell."],"example":"\nescapeShellArg \"esc'ape\\nme\"\n=> \"'esc'\\\\''ape\\nme'\"\n"},{"id":"lib.strings.escapeShellArgs","category":"./lib/strings.nix","name":"escapeShellArgs","fn_type":"escapeShellArgs :: [string] -> string","description":["Quote all arguments to be safely passed to the Bourne shell."],"example":"\nescapeShellArgs [\"one\" \"two three\" \"four'five\"]\n=> \"'one' 'two three' 'four'\\\\''five'\"\n"},{"id":"lib.strings.isValidPosixName","category":"./lib/strings.nix","name":"isValidPosixName","fn_type":"string -> bool","description":["Test whether the given name is a valid POSIX shell variable name."],"example":"\nisValidPosixName \"foo_bar000\"\n=> true\nisValidPosixName \"0-bad.jpg\"\n=> false\n"},{"id":"lib.strings.toShellVar","category":"./lib/strings.nix","name":"toShellVar","fn_type":"string -> (string | listOf string | attrsOf string) -> string","description":["Translate a Nix value into a shell variable declaration, with proper escaping.","The value can be a string (mapped to a regular variable), a list of strings\n(mapped to a Bash-style array) or an attribute set of strings (mapped to a\nBash-style associative array). Note that \"string\" includes string-coercible\nvalues like paths or derivations.","Strings are translated into POSIX sh-compatible code; lists and attribute sets\nassume a shell that understands Bash syntax (e.g. Bash or ZSH)."],"example":"\n''\n${toShellVar \"foo\" \"some string\"}\n[[ \"$foo\" == \"some string\" ]]\n''\n"},{"id":"lib.strings.toShellVars","category":"./lib/strings.nix","name":"toShellVars","fn_type":"attrsOf (string | listOf string | attrsOf string) -> string","description":["Translate an attribute set into corresponding shell variable declarations\nusing `toShellVar`."],"example":"\nlet\nfoo = \"value\";\nbar = foo;\nin ''\n${toShellVars { inherit foo bar; }}\n[[ \"$foo\" == \"$bar\" ]]\n''\n"},{"id":"lib.strings.escapeNixString","category":"./lib/strings.nix","name":"escapeNixString","fn_type":"string -> string","description":["Turn a string into a Nix expression representing that string"],"example":"\nescapeNixString \"hello\\${}\\n\"\n=> \"\\\"hello\\\\\\${}\\\\n\\\"\"\n"},{"id":"lib.strings.escapeRegex","category":"./lib/strings.nix","name":"escapeRegex","fn_type":"string -> string","description":["Turn a string into an exact regular expression"],"example":"\nescapeRegex \"[^a-z]*\"\n=> \"\\\\[\\\\^a-z]\\\\*\"\n"},{"id":"lib.strings.escapeNixIdentifier","category":"./lib/strings.nix","name":"escapeNixIdentifier","fn_type":"string -> string","description":["Quotes a string if it can't be used as an identifier directly."],"example":"\nescapeNixIdentifier \"hello\"\n=> \"hello\"\nescapeNixIdentifier \"0abc\"\n=> \"\\\"0abc\\\"\"\n"},{"id":"lib.strings.escapeXML","category":"./lib/strings.nix","name":"escapeXML","fn_type":"string -> string","description":["Escapes a string such that it is safe to include verbatim in an XML\ndocument."],"example":"\nescapeXML ''\"test\" 'test' < & >''\n=> \""test" 'test' < & >\"\n"},{"id":"lib.strings.toLower","category":"./lib/strings.nix","name":"toLower","fn_type":"toLower :: string -> string","description":["Converts an ASCII string to lower-case."],"example":"\ntoLower \"HOME\"\n=> \"home\"\n"},{"id":"lib.strings.toUpper","category":"./lib/strings.nix","name":"toUpper","fn_type":"toUpper :: string -> string","description":["Converts an ASCII string to upper-case."],"example":"\ntoUpper \"home\"\n=> \"HOME\"\n"},{"id":"lib.strings.addContextFrom","category":"./lib/strings.nix","name":"addContextFrom","fn_type":null,"description":["Appends string context from another string. This is an implementation\ndetail of Nix.","Strings in Nix carry an invisible `context` which is a list of strings\nrepresenting store paths. If the string is later used in a derivation\nattribute, the derivation will properly populate the inputDrvs and\ninputSrcs."],"example":"\npkgs = import { };\naddContextFrom pkgs.coreutils \"bar\"\n=> \"bar\"\n"},{"id":"lib.strings.splitString","category":"./lib/strings.nix","name":"splitString","fn_type":null,"description":["Cut a string with a separator and produces a list of strings which\nwere separated by this separator."],"example":"\nsplitString \".\" \"foo.bar.baz\"\n=> [ \"foo\" \"bar\" \"baz\" ]\nsplitString \"/\" \"/usr/local/bin\"\n=> [ \"\" \"usr\" \"local\" \"bin\" ]\n"},{"id":"lib.strings.removePrefix","category":"./lib/strings.nix","name":"removePrefix","fn_type":"string -> string -> string","description":["Return a string without the specified prefix, if the prefix matches."],"example":"\nremovePrefix \"foo.\" \"foo.bar.baz\"\n=> \"bar.baz\"\nremovePrefix \"xxx\" \"foo.bar.baz\"\n=> \"foo.bar.baz\"\n"},{"id":"lib.strings.removeSuffix","category":"./lib/strings.nix","name":"removeSuffix","fn_type":"string -> string -> string","description":["Return a string without the specified suffix, if the suffix matches."],"example":"\nremoveSuffix \"front\" \"homefront\"\n=> \"home\"\nremoveSuffix \"xxx\" \"homefront\"\n=> \"homefront\"\n"},{"id":"lib.strings.versionOlder","category":"./lib/strings.nix","name":"versionOlder","fn_type":null,"description":["Return true if string v1 denotes a version older than v2."],"example":"\nversionOlder \"1.1\" \"1.2\"\n=> true\nversionOlder \"1.1\" \"1.1\"\n=> false\n"},{"id":"lib.strings.versionAtLeast","category":"./lib/strings.nix","name":"versionAtLeast","fn_type":null,"description":["Return true if string v1 denotes a version equal to or newer than v2."],"example":"\nversionAtLeast \"1.1\" \"1.0\"\n=> true\nversionAtLeast \"1.1\" \"1.1\"\n=> true\nversionAtLeast \"1.1\" \"1.2\"\n=> false\n"},{"id":"lib.strings.getName","category":"./lib/strings.nix","name":"getName","fn_type":null,"description":["This function takes an argument that's either a derivation or a\nderivation's \"name\" attribute and extracts the name part from that\nargument."],"example":"\ngetName \"youtube-dl-2016.01.01\"\n=> \"youtube-dl\"\ngetName pkgs.youtube-dl\n=> \"youtube-dl\"\n"},{"id":"lib.strings.getVersion","category":"./lib/strings.nix","name":"getVersion","fn_type":null,"description":["This function takes an argument that's either a derivation or a\nderivation's \"name\" attribute and extracts the version part from that\nargument."],"example":"\ngetVersion \"youtube-dl-2016.01.01\"\n=> \"2016.01.01\"\ngetVersion pkgs.youtube-dl\n=> \"2016.01.01\"\n"},{"id":"lib.strings.nameFromURL","category":"./lib/strings.nix","name":"nameFromURL","fn_type":null,"description":["Extract name with version from URL. Ask for separator which is\nsupposed to start extension."],"example":"\nnameFromURL \"https://nixos.org/releases/nix/nix-1.7/nix-1.7-x86_64-linux.tar.bz2\" \"-\"\n=> \"nix\"\nnameFromURL \"https://nixos.org/releases/nix/nix-1.7/nix-1.7-x86_64-linux.tar.bz2\" \"_\"\n=> \"nix-1.7-x86\"\n"},{"id":"lib.strings.enableFeature","category":"./lib/strings.nix","name":"enableFeature","fn_type":null,"description":["Create an --{enable,disable}- string that can be passed to\nstandard GNU Autoconf scripts."],"example":"\nenableFeature true \"shared\"\n=> \"--enable-shared\"\nenableFeature false \"shared\"\n=> \"--disable-shared\"\n"},{"id":"lib.strings.enableFeatureAs","category":"./lib/strings.nix","name":"enableFeatureAs","fn_type":null,"description":["Create an --{enable-=,disable-} string that can be passed to\nstandard GNU Autoconf scripts."],"example":"\nenableFeatureAs true \"shared\" \"foo\"\n=> \"--enable-shared=foo\"\nenableFeatureAs false \"shared\" (throw \"ignored\")\n=> \"--disable-shared\"\n"},{"id":"lib.strings.withFeature","category":"./lib/strings.nix","name":"withFeature","fn_type":null,"description":["Create an --{with,without}- string that can be passed to\nstandard GNU Autoconf scripts."],"example":"\nwithFeature true \"shared\"\n=> \"--with-shared\"\nwithFeature false \"shared\"\n=> \"--without-shared\"\n"},{"id":"lib.strings.withFeatureAs","category":"./lib/strings.nix","name":"withFeatureAs","fn_type":null,"description":["Create an --{with-=,without-} string that can be passed to\nstandard GNU Autoconf scripts."],"example":"\nwithFeatureAs true \"shared\" \"foo\"\n=> \"--with-shared=foo\"\nwithFeatureAs false \"shared\" (throw \"ignored\")\n=> \"--without-shared\"\n"},{"id":"lib.strings.fixedWidthString","category":"./lib/strings.nix","name":"fixedWidthString","fn_type":"fixedWidthString :: int -> string -> string -> string","description":["Create a fixed width string with additional prefix to match\nrequired width.","This function will fail if the input string is longer than the\nrequested length."],"example":"\nfixedWidthString 5 \"0\" (toString 15)\n=> \"00015\"\n"},{"id":"lib.strings.fixedWidthNumber","category":"./lib/strings.nix","name":"fixedWidthNumber","fn_type":null,"description":["Format a number adding leading zeroes up to fixed width."],"example":"\nfixedWidthNumber 5 15\n=> \"00015\"\n"},{"id":"lib.strings.floatToString","category":"./lib/strings.nix","name":"floatToString","fn_type":null,"description":["Convert a float to a string, but emit a warning when precision is lost\nduring the conversion"],"example":"\nfloatToString 0.000001\n=> \"0.000001\"\nfloatToString 0.0000001\n=> trace: warning: Imprecise conversion from float to string 0.000000\n\"0.000000\"\n"},{"id":"lib.strings.isCoercibleToString","category":"./lib/strings.nix","name":"isCoercibleToString","fn_type":null,"description":["Check whether a value can be coerced to a string"],"example":null},{"id":"lib.strings.isStorePath","category":"./lib/strings.nix","name":"isStorePath","fn_type":null,"description":["Check whether a value is a store path."],"example":"\nisStorePath \"/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11/bin/python\"\n=> false\nisStorePath \"/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11\"\n=> true\nisStorePath pkgs.python\n=> true\nisStorePath [] || isStorePath 42 || isStorePath {} || …\n=> false\n"},{"id":"lib.strings.toInt","category":"./lib/strings.nix","name":"toInt","fn_type":"string -> int","description":["Parse a string as an int. Does not support parsing of integers with preceding zero due to\nambiguity between zero-padded and octal numbers. See toIntBase10."],"example":"\n\ntoInt \"1337\"\n=> 1337\n\ntoInt \"-4\"\n=> -4\n\ntoInt \" 123 \"\n=> 123\n\ntoInt \"00024\"\n=> error: Ambiguity in interpretation of 00024 between octal and zero padded integer.\n\ntoInt \"3.14\"\n=> error: floating point JSON numbers are not supported\n"},{"id":"lib.strings.toIntBase10","category":"./lib/strings.nix","name":"toIntBase10","fn_type":"string -> int","description":["Parse a string as a base 10 int. This supports parsing of zero-padded integers."],"example":"\ntoIntBase10 \"1337\"\n=> 1337\n\ntoIntBase10 \"-4\"\n=> -4\n\ntoIntBase10 \" 123 \"\n=> 123\n\ntoIntBase10 \"00024\"\n=> 24\n\ntoIntBase10 \"3.14\"\n=> error: floating point JSON numbers are not supported\n"},{"id":"lib.strings.readPathsFromFile","category":"./lib/strings.nix","name":"readPathsFromFile","fn_type":null,"description":["Read a list of paths from `file`, relative to the `rootPath`.\nLines beginning with `#` are treated as comments and ignored.\nWhitespace is significant.","NOTE: This function is not performant and should be avoided."],"example":"\nreadPathsFromFile /prefix\n./pkgs/development/libraries/qt-5/5.4/qtbase/series\n=> [ \"/prefix/dlopen-resolv.patch\" \"/prefix/tzdir.patch\"\n\"/prefix/dlopen-libXcursor.patch\" \"/prefix/dlopen-openssl.patch\"\n\"/prefix/dlopen-dbus.patch\" \"/prefix/xdg-config-dirs.patch\"\n\"/prefix/nix-profiles-library-paths.patch\"\n\"/prefix/compose-search-path.patch\" ]\n"},{"id":"lib.strings.fileContents","category":"./lib/strings.nix","name":"fileContents","fn_type":"fileContents :: path -> string","description":["Read the contents of a file removing the trailing \\n"],"example":"\n$ echo \"1.0\" > ./version\n\nfileContents ./version\n=> \"1.0\"\n"},{"id":"lib.strings.sanitizeDerivationName","category":"./lib/strings.nix","name":"sanitizeDerivationName","fn_type":"sanitizeDerivationName :: String -> String","description":["Creates a valid derivation name from a potentially invalid one."],"example":"\nsanitizeDerivationName \"../hello.bar # foo\"\n=> \"-hello.bar-foo\"\nsanitizeDerivationName \"\"\n=> \"unknown\"\nsanitizeDerivationName pkgs.hello\n=> \"-nix-store-2g75chlbpxlrqn15zlby2dfh8hr9qwbk-hello-2.10\"\n"},{"id":"lib.strings.levenshtein","category":"./lib/strings.nix","name":"levenshtein","fn_type":"levenshtein :: string -> string -> int","description":["Computes the Levenshtein distance between two strings.\nComplexity O(n*m) where n and m are the lengths of the strings.\nAlgorithm adjusted from https://stackoverflow.com/a/9750974/6605742"],"example":"\nlevenshtein \"foo\" \"foo\"\n=> 0\nlevenshtein \"book\" \"hook\"\n=> 1\nlevenshtein \"hello\" \"Heyo\"\n=> 3\n"},{"id":"lib.strings.commonPrefixLength","category":"./lib/strings.nix","name":"commonPrefixLength","fn_type":null,"description":["Returns the length of the prefix common to both strings."],"example":null},{"id":"lib.strings.commonSuffixLength","category":"./lib/strings.nix","name":"commonSuffixLength","fn_type":null,"description":["Returns the length of the suffix common to both strings."],"example":null},{"id":"lib.strings.levenshteinAtMost","category":"./lib/strings.nix","name":"levenshteinAtMost","fn_type":"levenshteinAtMost :: int -> string -> string -> bool","description":["Returns whether the levenshtein distance between two strings is at most some value\nComplexity is O(min(n,m)) for k <= 2 and O(n*m) otherwise"],"example":"\nlevenshteinAtMost 0 \"foo\" \"foo\"\n=> true\nlevenshteinAtMost 1 \"foo\" \"boa\"\n=> false\nlevenshteinAtMost 2 \"foo\" \"boa\"\n=> true\nlevenshteinAtMost 2 \"This is a sentence\" \"this is a sentense.\"\n=> false\nlevenshteinAtMost 3 \"This is a sentence\" \"this is a sentense.\"\n=> true\n"},{"id":"lib.strings-with-deps.textClosureList","category":"./lib/strings-with-deps.nix","name":"textClosureList","fn_type":null,"description":["!!! The interface of this function is kind of messed up, since\nit's way too overloaded and almost but not quite computes a\ntopological sort of the depstrings."],"example":null},{"id":"lib.sources.pathType","category":"./lib/sources.nix","name":"pathType","fn_type":null,"description":["Returns the type of a path: regular (for file), symlink, or directory."],"example":null},{"id":"lib.sources.pathIsDirectory","category":"./lib/sources.nix","name":"pathIsDirectory","fn_type":null,"description":["Returns true if the path exists and is a directory, false otherwise."],"example":null},{"id":"lib.sources.pathIsRegularFile","category":"./lib/sources.nix","name":"pathIsRegularFile","fn_type":null,"description":["Returns true if the path exists and is a regular file, false otherwise."],"example":null},{"id":"lib.sources.cleanSourceFilter","category":"./lib/sources.nix","name":"cleanSourceFilter","fn_type":null,"description":["A basic filter for `cleanSourceWith` that removes\ndirectories of version control system, backup files (*~)\nand some generated files."],"example":null},{"id":"lib.sources.cleanSource","category":"./lib/sources.nix","name":"cleanSource","fn_type":null,"description":["Filters a source tree removing version control files and directories using cleanSourceFilter."],"example":"\ncleanSource ./.\n"},{"id":"lib.sources.cleanSourceWith","category":"./lib/sources.nix","name":"cleanSourceWith","fn_type":null,"description":["Like `builtins.filterSource`, except it will compose with itself,\nallowing you to chain multiple calls together without any\nintermediate copies being put in the nix store."],"example":"\nlib.cleanSourceWith {\nfilter = f;\nsrc = lib.cleanSourceWith {\nfilter = g;\nsrc = ./.;\n};\n}\n# Succeeds!\n\nbuiltins.filterSource f (builtins.filterSource g ./.)\n# Fails!\n"},{"id":"lib.sources.trace","category":"./lib/sources.nix","name":"trace","fn_type":"sources.trace :: sourceLike -> Source","description":["Add logging to a source, for troubleshooting the filtering behavior."],"example":null},{"id":"lib.sources.sourceByRegex","category":"./lib/sources.nix","name":"sourceByRegex","fn_type":null,"description":["Filter sources by a list of regular expressions."],"example":"src = sourceByRegex ./my-subproject [\".*\\.py$\" \"^database.sql$\"]\n"},{"id":"lib.sources.sourceFilesBySuffices","category":"./lib/sources.nix","name":"sourceFilesBySuffices","fn_type":"sourceLike -> [String] -> Source","description":["Get all files ending with the specified suffices from the given\nsource directory or its descendants, omitting files that do not match\nany suffix. The result of the example below will include files like\n`./dir/module.c` and `./dir/subdir/doc.xml` if present."],"example":"\nsourceFilesBySuffices ./. [ \".xml\" \".c\" ]\n"},{"id":"lib.sources.commitIdFromGitRepo","category":"./lib/sources.nix","name":"commitIdFromGitRepo","fn_type":null,"description":["Get the commit id of a git repo."],"example":"commitIdFromGitRepo \n"},{"id":"lib.options.isOption","category":"./lib/options.nix","name":"isOption","fn_type":"isOption :: a -> bool","description":["Returns true when the given argument is an option"],"example":"\nisOption 1 // => false\nisOption (mkOption {}) // => true\n"},{"id":"lib.options.mkOption","category":"./lib/options.nix","name":"mkOption","fn_type":null,"description":["Creates an Option attribute set. mkOption accepts an attribute set with the following keys:","All keys default to `null` when not given."],"example":"\nmkOption { } // => { _type = \"option\"; }\nmkOption { default = \"foo\"; } // => { _type = \"option\"; default = \"foo\"; }\n"},{"id":"lib.options.mkEnableOption","category":"./lib/options.nix","name":"mkEnableOption","fn_type":null,"description":["Creates an Option attribute set for a boolean value option i.e an\noption to be toggled on or off:"],"example":"\nmkEnableOption \"foo\"\n=> { _type = \"option\"; default = false; description = \"Whether to enable foo.\"; example = true; type = { ... }; }\n"},{"id":"lib.options.mkPackageOption","category":"./lib/options.nix","name":"mkPackageOption","fn_type":"mkPackageOption :: pkgs -> string -> { default :: [string], example :: null | string | [string] } -> option","description":["Creates an Option attribute set for an option that specifies the\npackage a module should use for some purpose.","The package is specified as a list of strings representing its attribute path in nixpkgs.","Because of this, you need to pass nixpkgs itself as the first argument.","The second argument is the name of the option, used in the description \"The package to use.\".","You can also pass an example value, either a literal string or a package's attribute path.","You can omit the default path if the name of the option is also attribute path in nixpkgs."],"example":"\nmkPackageOption pkgs \"hello\" { }\n=> { _type = \"option\"; default = «derivation /nix/store/3r2vg51hlxj3cx5vscp0vkv60bqxkaq0-hello-2.10.drv»; defaultText = { ... }; description = \"The hello package to use.\"; type = { ... }; }\n\n\nmkPackageOption pkgs \"GHC\" {\ndefault = [ \"ghc\" ];\nexample = \"pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])\";\n}\n=> { _type = \"option\"; default = «derivation /nix/store/jxx55cxsjrf8kyh3fp2ya17q99w7541r-ghc-8.10.7.drv»; defaultText = { ... }; description = \"The GHC package to use.\"; example = { ... }; type = { ... }; }\n"},{"id":"lib.options.mkSinkUndeclaredOptions","category":"./lib/options.nix","name":"mkSinkUndeclaredOptions","fn_type":null,"description":["This option accepts anything, but it does not produce any result.","This is useful for sharing a module across different module sets\nwithout having to implement similar features as long as the\nvalues of the options are not accessed."],"example":null},{"id":"lib.options.mergeEqualOption","category":"./lib/options.nix","name":"mergeEqualOption","fn_type":null,"description":["\"Merge\" option definitions by checking that they all have the same value."],"example":null},{"id":"lib.options.getValues","category":"./lib/options.nix","name":"getValues","fn_type":"getValues :: [ { value :: a } ] -> [a]","description":["Extracts values of all \"value\" keys of the given list."],"example":"\ngetValues [ { value = 1; } { value = 2; } ] // => [ 1 2 ]\ngetValues [ ] // => [ ]\n"},{"id":"lib.options.getFiles","category":"./lib/options.nix","name":"getFiles","fn_type":"getFiles :: [ { file :: a } ] -> [a]","description":["Extracts values of all \"file\" keys of the given list"],"example":"\ngetFiles [ { file = \"file1\"; } { file = \"file2\"; } ] // => [ \"file1\" \"file2\" ]\ngetFiles [ ] // => [ ]\n"},{"id":"lib.options.scrubOptionValue","category":"./lib/options.nix","name":"scrubOptionValue","fn_type":null,"description":["This function recursively removes all derivation attributes from\n`x` except for the `name` attribute.","This is to make the generation of `options.xml` much more\nefficient: the XML representation of derivations is very large\n(on the order of megabytes) and is not actually used by the\nmanual generator."],"example":null},{"id":"lib.options.literalExpression","category":"./lib/options.nix","name":"literalExpression","fn_type":null,"description":["For use in the `defaultText` and `example` option attributes. Causes the\ngiven string to be rendered verbatim in the documentation as Nix code. This\nis necessary for complex values, e.g. functions, or values that depend on\nother values or packages."],"example":null},{"id":"lib.options.literalDocBook","category":"./lib/options.nix","name":"literalDocBook","fn_type":null,"description":["For use in the `defaultText` and `example` option attributes. Causes the\ngiven DocBook text to be inserted verbatim in the documentation, for when\na `literalExpression` would be too hard to read."],"example":null},{"id":"lib.options.mdDoc","category":"./lib/options.nix","name":"mdDoc","fn_type":null,"description":["Transition marker for documentation that's already migrated to markdown\nsyntax."],"example":null},{"id":"lib.options.literalMD","category":"./lib/options.nix","name":"literalMD","fn_type":null,"description":["For use in the `defaultText` and `example` option attributes. Causes the\ngiven MD text to be inserted verbatim in the documentation, for when\na `literalExpression` would be too hard to read."],"example":null},{"id":"lib.options.showOption","category":"./lib/options.nix","name":"showOption","fn_type":null,"description":["Convert an option, described as a list of the option parts in to a\nsafe, human readable version."],"example":"\n(showOption [\"foo\" \"bar\" \"baz\"]) == \"foo.bar.baz\"\n(showOption [\"foo\" \"bar.baz\" \"tux\"]) == \"foo.bar.baz.tux\"\n\nPlaceholders will not be quoted as they are not actual values:\n(showOption [\"foo\" \"*\" \"bar\"]) == \"foo.*.bar\"\n(showOption [\"foo\" \"\" \"bar\"]) == \"foo..bar\"\n\nUnlike attributes, options can also start with numbers:\n(showOption [\"windowManager\" \"2bwm\" \"enable\"]) == \"windowManager.2bwm.enable\"\n"},{"id":"lib.modules.evalModules","category":"./lib/modules.nix","name":"evalModules","fn_type":null,"description":["Evaluate a set of modules. The result is a set with the attributes:","‘options’: The nested set of all option declarations,","‘config’: The nested set of all option values.","‘type’: A module system type representing the module set as a submodule,\nto be extended by configuration from the containing module set.","This is also available as the module argument ‘moduleType’.","‘extendModules’: A function similar to ‘evalModules’ but building on top\nof the module set. Its arguments, ‘modules’ and ‘specialArgs’ are\nadded to the existing values.","Using ‘extendModules’ a few times has no performance impact as long\nas you only reference the final ‘options’ and ‘config’.\nIf you do reference multiple ‘config’ (or ‘options’) from before and\nafter ‘extendModules’, performance is the same as with multiple\n‘evalModules’ invocations, because the new modules' ability to\noverride existing configuration fundamentally requires a new\nfixpoint to be constructed.","This is also available as a module argument.","‘_module’: A portion of the configuration tree which is elided from\n‘config’. It contains some values that are mostly internal to the\nmodule system implementation.","!!! Please think twice before adding to this argument list! The more\nthat is specified here instead of in the modules themselves the harder\nit is to transparently move a set of modules to be a submodule of another\nconfig (as the proper arguments need to be replicated at each call to\nevalModules) and the less declarative the module set is."],"example":null},{"id":"lib.modules.collectStructuredModules","category":"./lib/modules.nix","name":"collectStructuredModules","fn_type":null,"description":["Collects all modules recursively into the form","{\ndisabled = [ ];\n# All modules of the main module list\nmodules = [\n{\nkey = ;\nmodule = ;\n# All modules imported by the module for key1\nmodules = [\n{\nkey = ;\nmodule = ;\n# All modules imported by the module for key1-1\nmodules = [ ... ];\n}\n...\n];\n}\n...\n];\n}"],"example":null},{"id":"lib.modules.setDefaultModuleLocation","category":"./lib/modules.nix","name":"setDefaultModuleLocation","fn_type":null,"description":["Wrap a module with a default location for reporting errors."],"example":null},{"id":"lib.modules.unifyModuleSyntax","category":"./lib/modules.nix","name":"unifyModuleSyntax","fn_type":null,"description":["Massage a module into canonical form, that is, a set consisting\nof ‘options’, ‘config’ and ‘imports’ attributes."],"example":null},{"id":"lib.modules.mergeModules","category":"./lib/modules.nix","name":"mergeModules","fn_type":null,"description":["Merge a list of modules. This will recurse over the option\ndeclarations in all modules, combining them into a single set.\nAt the same time, for each option declaration, it will merge the\ncorresponding option definitions in all machines, returning them\nin the ‘value’ attribute of each option.","This returns a set like\n{\n# A recursive set of options along with their final values\nmatchedOptions = {\nfoo = { _type = \"option\"; value = \"option value of foo\"; ... };\nbar.baz = { _type = \"option\"; value = \"option value of bar.baz\"; ... };\n...\n};\n# A list of definitions that weren't matched by any option\nunmatchedDefns = [\n{ file = \"file.nix\"; prefix = [ \"qux\" ]; value = \"qux\"; }\n...\n];\n}"],"example":null},{"id":"lib.modules.byName","category":"./lib/modules.nix","name":"byName","fn_type":null,"description":["byName is like foldAttrs, but will look for attributes to merge in the\nspecified attribute name.","byName \"foo\" (module: value: [\"module.hidden=${module.hidden},value=${value}\"])\n[\n{\nhidden=\"baz\";\nfoo={qux=\"bar\"; gla=\"flop\";};\n}\n{\nhidden=\"fli\";\nfoo={qux=\"gne\"; gli=\"flip\";};\n}\n]\n===>\n{\ngla = [ \"module.hidden=baz,value=flop\" ];\ngli = [ \"module.hidden=fli,value=flip\" ];\nqux = [ \"module.hidden=baz,value=bar\" \"module.hidden=fli,value=gne\" ];\n}"],"example":null},{"id":"lib.modules.mergeOptionDecls","category":"./lib/modules.nix","name":"mergeOptionDecls","fn_type":null,"description":["Merge multiple option declarations into a single declaration. In\ngeneral, there should be only one declaration of each option.\nThe exception is the ‘options’ attribute, which specifies\nsub-options. These can be specified multiple times to allow one\nmodule to add sub-options to an option declared somewhere else\n(e.g. multiple modules define sub-options for ‘fileSystems’).","'loc' is the list of attribute names where the option is located.","'opts' is a list of modules. Each module has an options attribute which\ncorrespond to the definition of 'loc' in 'opt.file'."],"example":null},{"id":"lib.modules.evalOptionValue","category":"./lib/modules.nix","name":"evalOptionValue","fn_type":null,"description":["Merge all the definitions of an option to produce the final\nconfig value."],"example":null},{"id":"lib.modules.pushDownProperties","category":"./lib/modules.nix","name":"pushDownProperties","fn_type":null,"description":["Given a config set, expand mkMerge properties, and push down the\nother properties into the children. The result is a list of\nconfig sets that do not have properties at top-level. For\nexample,","mkMerge [ { boot = set1; } (mkIf cond { boot = set2; services = set3; }) ]","is transformed into","[ { boot = set1; } { boot = mkIf cond set2; services = mkIf cond set3; } ].","This transform is the critical step that allows mkIf conditions\nto refer to the full configuration without creating an infinite\nrecursion."],"example":null},{"id":"lib.modules.dischargeProperties","category":"./lib/modules.nix","name":"dischargeProperties","fn_type":null,"description":["Given a config value, expand mkMerge properties, and discharge\nany mkIf conditions. That is, this is the place where mkIf\nconditions are actually evaluated. The result is a list of\nconfig values. For example, ‘mkIf false x’ yields ‘[]’,\n‘mkIf true x’ yields ‘[x]’, and","mkMerge [ 1 (mkIf true 2) (mkIf true (mkIf false 3)) ]","yields ‘[ 1 2 ]’."],"example":null},{"id":"lib.modules.filterOverrides","category":"./lib/modules.nix","name":"filterOverrides","fn_type":null,"description":["Given a list of config values, process the mkOverride properties,\nthat is, return the values that have the highest (that is,\nnumerically lowest) priority, and strip the mkOverride\nproperties. For example,","[ { file = \"/1\"; value = mkOverride 10 \"a\"; }\n{ file = \"/2\"; value = mkOverride 20 \"b\"; }\n{ file = \"/3\"; value = \"z\"; }\n{ file = \"/4\"; value = mkOverride 10 \"d\"; }\n]","yields","[ { file = \"/1\"; value = \"a\"; }\n{ file = \"/4\"; value = \"d\"; }\n]","Note that \"z\" has the default priority 100."],"example":null},{"id":"lib.modules.sortProperties","category":"./lib/modules.nix","name":"sortProperties","fn_type":null,"description":["Sort a list of properties. The sort priority of a property is\ndefaultOrderPriority by default, but can be overridden by wrapping the property\nusing mkOrder."],"example":null},{"id":"lib.modules.mkIf","category":"./lib/modules.nix","name":"mkIf","fn_type":null,"description":["Properties."],"example":null},{"id":"lib.modules.fixMergeModules","category":"./lib/modules.nix","name":"fixMergeModules","fn_type":null,"description":["Compatibility."],"example":null},{"id":"lib.modules.mkRemovedOptionModule","category":"./lib/modules.nix","name":"mkRemovedOptionModule","fn_type":null,"description":["Return a module that causes a warning to be shown if the\nspecified option is defined. For example,","mkRemovedOptionModule [ \"boot\" \"loader\" \"grub\" \"bootDevice\" ] \"\"","causes a assertion if the user defines boot.loader.grub.bootDevice.","replacementInstructions is a string that provides instructions on\nhow to achieve the same functionality without the removed option,\nor alternatively a reasoning why the functionality is not needed.\nreplacementInstructions SHOULD be provided!"],"example":null},{"id":"lib.modules.mkRenamedOptionModule","category":"./lib/modules.nix","name":"mkRenamedOptionModule","fn_type":null,"description":["Return a module that causes a warning to be shown if the\nspecified \"from\" option is defined; the defined value is however\nforwarded to the \"to\" option. This can be used to rename options\nwhile providing backward compatibility. For example,","mkRenamedOptionModule [ \"boot\" \"copyKernels\" ] [ \"boot\" \"loader\" \"grub\" \"copyKernels\" ]","forwards any definitions of boot.copyKernels to\nboot.loader.grub.copyKernels while printing a warning.","This also copies over the priority from the aliased option to the\nnon-aliased option."],"example":null},{"id":"lib.modules.mkMergedOptionModule","category":"./lib/modules.nix","name":"mkMergedOptionModule","fn_type":null,"description":["Return a module that causes a warning to be shown if any of the \"from\"\noption is defined; the defined values can be used in the \"mergeFn\" to set\nthe \"to\" value.\nThis function can be used to merge multiple options into one that has a\ndifferent type.","\"mergeFn\" takes the module \"config\" as a parameter and must return a value\nof \"to\" option type.","mkMergedOptionModule\n[ [ \"a\" \"b\" \"c\" ]\n[ \"d\" \"e\" \"f\" ] ]\n[ \"x\" \"y\" \"z\" ]\n(config:\nlet value = p: getAttrFromPath p config;\nin\nif (value [ \"a\" \"b\" \"c\" ]) == true then \"foo\"\nelse if (value [ \"d\" \"e\" \"f\" ]) == true then \"bar\"\nelse \"baz\")","- options.a.b.c is a removed boolean option\n- options.d.e.f is a removed boolean option\n- options.x.y.z is a new str option that combines a.b.c and d.e.f\nfunctionality","This show a warning if any a.b.c or d.e.f is set, and set the value of\nx.y.z to the result of the merge function"],"example":null},{"id":"lib.modules.mkChangedOptionModule","category":"./lib/modules.nix","name":"mkChangedOptionModule","fn_type":null,"description":["Single \"from\" version of mkMergedOptionModule.\nReturn a module that causes a warning to be shown if the \"from\" option is\ndefined; the defined value can be used in the \"mergeFn\" to set the \"to\"\nvalue.\nThis function can be used to change an option into another that has a\ndifferent type.","\"mergeFn\" takes the module \"config\" as a parameter and must return a value of\n\"to\" option type.","mkChangedOptionModule [ \"a\" \"b\" \"c\" ] [ \"x\" \"y\" \"z\" ]\n(config:\nlet value = getAttrFromPath [ \"a\" \"b\" \"c\" ] config;\nin\nif value > 100 then \"high\"\nelse \"normal\")","- options.a.b.c is a removed int option\n- options.x.y.z is a new str option that supersedes a.b.c","This show a warning if a.b.c is set, and set the value of x.y.z to the\nresult of the change function"],"example":null},{"id":"lib.modules.mkAliasOptionModule","category":"./lib/modules.nix","name":"mkAliasOptionModule","fn_type":null,"description":["Like ‘mkRenamedOptionModule’, but doesn't show a warning."],"example":null},{"id":"lib.modules.mkDerivedConfig","category":"./lib/modules.nix","name":"mkDerivedConfig","fn_type":null,"description":["mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b","Create config definitions with the same priority as the definition of another option.\nThis should be used for option definitions where one option sets the value of another as a convenience.\nFor instance a config file could be set with a `text` or `source` option, where text translates to a `source`\nvalue using `mkDerivedConfig options.text (pkgs.writeText \"filename.conf\")`.","It takes care of setting the right priority using `mkOverride`."],"example":null},{"id":"lib.modules.importJSON","category":"./lib/modules.nix","name":"importJSON","fn_type":null,"description":["Use this function to import a JSON file as NixOS configuration.","modules.importJSON :: path -> attrs"],"example":null},{"id":"lib.modules.importTOML","category":"./lib/modules.nix","name":"importTOML","fn_type":null,"description":["Use this function to import a TOML file as NixOS configuration.","modules.importTOML :: path -> attrs"],"example":null},{"id":"lib.meta.addMetaAttrs","category":"./lib/meta.nix","name":"addMetaAttrs","fn_type":null,"description":["Add to or override the meta attributes of the given\nderivation."],"example":"\naddMetaAttrs {description = \"Bla blah\";} somePkg\n"},{"id":"lib.meta.dontDistribute","category":"./lib/meta.nix","name":"dontDistribute","fn_type":null,"description":["Disable Hydra builds of given derivation."],"example":null},{"id":"lib.meta.setName","category":"./lib/meta.nix","name":"setName","fn_type":null,"description":["Change the symbolic name of a package for presentation purposes\n(i.e., so that nix-env users can tell them apart)."],"example":null},{"id":"lib.meta.updateName","category":"./lib/meta.nix","name":"updateName","fn_type":null,"description":["Like `setName', but takes the previous name as an argument."],"example":"\nupdateName (oldName: oldName + \"-experimental\") somePkg\n"},{"id":"lib.meta.appendToName","category":"./lib/meta.nix","name":"appendToName","fn_type":null,"description":["Append a suffix to the name of a package (before the version\npart)."],"example":null},{"id":"lib.meta.mapDerivationAttrset","category":"./lib/meta.nix","name":"mapDerivationAttrset","fn_type":null,"description":["Apply a function to each derivation and only to derivations in an attrset."],"example":null},{"id":"lib.meta.setPrio","category":"./lib/meta.nix","name":"setPrio","fn_type":null,"description":["Set the nix-env priority of the package."],"example":null},{"id":"lib.meta.lowPrio","category":"./lib/meta.nix","name":"lowPrio","fn_type":null,"description":["Decrease the nix-env priority of the package, i.e., other\nversions/variants of the package will be preferred."],"example":null},{"id":"lib.meta.lowPrioSet","category":"./lib/meta.nix","name":"lowPrioSet","fn_type":null,"description":["Apply lowPrio to an attrset with derivations"],"example":null},{"id":"lib.meta.hiPrio","category":"./lib/meta.nix","name":"hiPrio","fn_type":null,"description":["Increase the nix-env priority of the package, i.e., this\nversion/variant of the package will be preferred."],"example":null},{"id":"lib.meta.hiPrioSet","category":"./lib/meta.nix","name":"hiPrioSet","fn_type":null,"description":["Apply hiPrio to an attrset with derivations"],"example":null},{"id":"lib.meta.platformMatch","category":"./lib/meta.nix","name":"platformMatch","fn_type":null,"description":["Check to see if a platform is matched by the given `meta.platforms`\nelement.","A `meta.platform` pattern is either","1. (legacy) a system string.","2. (modern) a pattern for the platform `parsed` field.","We can inject these into a pattern for the whole of a structured platform,\nand then match that."],"example":null},{"id":"lib.meta.availableOn","category":"./lib/meta.nix","name":"availableOn","fn_type":null,"description":["Check if a package is available on a given platform.","A package is available on a platform if both","1. One of `meta.platforms` pattern matches the given platform.","2. None of `meta.badPlatforms` pattern matches the given platform."],"example":null},{"id":"lib.meta.getLicenseFromSpdxId","category":"./lib/meta.nix","name":"getLicenseFromSpdxId","fn_type":"getLicenseFromSpdxId :: str -> AttrSet","description":["Get the corresponding attribute in lib.licenses\nfrom the SPDX ID.\nFor SPDX IDs, see\nhttps://spdx.org/licenses"],"example":"\nlib.getLicenseFromSpdxId \"MIT\" == lib.licenses.mit\n=> true\nlib.getLicenseFromSpdxId \"mIt\" == lib.licenses.mit\n=> true\nlib.getLicenseFromSpdxId \"MY LICENSE\"\n=> trace: warning: getLicenseFromSpdxId: No license matches the given SPDX ID: MY LICENSE\n=> { shortName = \"MY LICENSE\"; }\n"},{"id":"lib.meta.getExe","category":"./lib/meta.nix","name":"getExe","fn_type":"getExe :: derivation -> string","description":["Get the path to the main program of a derivation with either\nmeta.mainProgram or pname or name"],"example":"\ngetExe pkgs.hello\n=> \"/nix/store/g124820p9hlv4lj8qplzxw1c44dxaw1k-hello-2.12/bin/hello\"\ngetExe pkgs.mustache-go\n=> \"/nix/store/am9ml4f4ywvivxnkiaqwr0hyxka1xjsf-mustache-go-1.3.0/bin/mustache\"\n"},{"id":"lib.lists.singleton","category":"./lib/lists.nix","name":"singleton","fn_type":"singleton :: a -> [a]","description":["Create a list consisting of a single element. `singleton x` is\nsometimes more convenient with respect to indentation than `[x]`\nwhen x spans multiple lines."],"example":"\nsingleton \"foo\"\n=> [ \"foo\" ]\n"},{"id":"lib.lists.forEach","category":"./lib/lists.nix","name":"forEach","fn_type":"forEach :: [a] -> (a -> b) -> [b]","description":["Apply the function to each element in the list. Same as `map`, but arguments\nflipped."],"example":"\nforEach [ 1 2 ] (x:\ntoString x\n)\n=> [ \"1\" \"2\" ]\n"},{"id":"lib.lists.foldr","category":"./lib/lists.nix","name":"foldr","fn_type":"foldr :: (a -> b -> b) -> b -> [a] -> b","description":["“right fold” a binary function `op` between successive elements of\n`list` with `nul` as the starting value, i.e.,\n`foldr op nul [x_1 x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))`."],"example":"\nconcat = foldr (a: b: a + b) \"z\"\nconcat [ \"a\" \"b\" \"c\" ]\n=> \"abcz\"\n# different types\nstrange = foldr (int: str: toString (int + 1) + str) \"a\"\nstrange [ 1 2 3 4 ]\n=> \"2345a\"\n"},{"id":"lib.lists.fold","category":"./lib/lists.nix","name":"fold","fn_type":null,"description":["`fold` is an alias of `foldr` for historic reasons"],"example":null},{"id":"lib.lists.foldl","category":"./lib/lists.nix","name":"foldl","fn_type":"foldl :: (b -> a -> b) -> b -> [a] -> b","description":["“left fold”, like `foldr`, but from the left:\n`foldl op nul [x_1 x_2 ... x_n] == op (... (op (op nul x_1) x_2) ... x_n)`."],"example":"\nlconcat = foldl (a: b: a + b) \"z\"\nlconcat [ \"a\" \"b\" \"c\" ]\n=> \"zabc\"\n# different types\nlstrange = foldl (str: int: str + toString (int + 1)) \"a\"\nlstrange [ 1 2 3 4 ]\n=> \"a2345\"\n"},{"id":"lib.lists.foldl'","category":"./lib/lists.nix","name":"foldl'","fn_type":"foldl' :: (b -> a -> b) -> b -> [a] -> b","description":["Strict version of `foldl`.","The difference is that evaluation is forced upon access. Usually used\nwith small whole results (in contrast with lazily-generated list or large\nlists where only a part is consumed.)"],"example":null},{"id":"lib.lists.imap0","category":"./lib/lists.nix","name":"imap0","fn_type":"imap0 :: (int -> a -> b) -> [a] -> [b]","description":["Map with index starting from 0"],"example":"\nimap0 (i: v: \"${v}-${toString i}\") [\"a\" \"b\"]\n=> [ \"a-0\" \"b-1\" ]\n"},{"id":"lib.lists.imap1","category":"./lib/lists.nix","name":"imap1","fn_type":"imap1 :: (int -> a -> b) -> [a] -> [b]","description":["Map with index starting from 1"],"example":"\nimap1 (i: v: \"${v}-${toString i}\") [\"a\" \"b\"]\n=> [ \"a-1\" \"b-2\" ]\n"},{"id":"lib.lists.concatMap","category":"./lib/lists.nix","name":"concatMap","fn_type":"concatMap :: (a -> [b]) -> [a] -> [b]","description":["Map and concatenate the result."],"example":"\nconcatMap (x: [x] ++ [\"z\"]) [\"a\" \"b\"]\n=> [ \"a\" \"z\" \"b\" \"z\" ]\n"},{"id":"lib.lists.flatten","category":"./lib/lists.nix","name":"flatten","fn_type":null,"description":["Flatten the argument into a single list; that is, nested lists are\nspliced into the top-level lists."],"example":"\nflatten [1 [2 [3] 4] 5]\n=> [1 2 3 4 5]\nflatten 1\n=> [1]\n"},{"id":"lib.lists.remove","category":"./lib/lists.nix","name":"remove","fn_type":"remove :: a -> [a] -> [a]","description":["Remove elements equal to 'e' from a list. Useful for buildInputs."],"example":"\nremove 3 [ 1 3 4 3 ]\n=> [ 1 4 ]\n"},{"id":"lib.lists.findSingle","category":"./lib/lists.nix","name":"findSingle","fn_type":"findSingle :: (a -> bool) -> a -> a -> [a] -> a","description":["Find the sole element in the list matching the specified\npredicate, returns `default` if no such element exists, or\n`multiple` if there are multiple matching elements."],"example":"\nfindSingle (x: x == 3) \"none\" \"multiple\" [ 1 3 3 ]\n=> \"multiple\"\nfindSingle (x: x == 3) \"none\" \"multiple\" [ 1 3 ]\n=> 3\nfindSingle (x: x == 3) \"none\" \"multiple\" [ 1 9 ]\n=> \"none\"\n"},{"id":"lib.lists.findFirst","category":"./lib/lists.nix","name":"findFirst","fn_type":"findFirst :: (a -> bool) -> a -> [a] -> a","description":["Find the first element in the list matching the specified\npredicate or return `default` if no such element exists."],"example":"\nfindFirst (x: x > 3) 7 [ 1 6 4 ]\n=> 6\nfindFirst (x: x > 9) 7 [ 1 6 4 ]\n=> 7\n"},{"id":"lib.lists.any","category":"./lib/lists.nix","name":"any","fn_type":"any :: (a -> bool) -> [a] -> bool","description":["Return true if function `pred` returns true for at least one\nelement of `list`."],"example":"\nany isString [ 1 \"a\" { } ]\n=> true\nany isString [ 1 { } ]\n=> false\n"},{"id":"lib.lists.all","category":"./lib/lists.nix","name":"all","fn_type":"all :: (a -> bool) -> [a] -> bool","description":["Return true if function `pred` returns true for all elements of\n`list`."],"example":"\nall (x: x < 3) [ 1 2 ]\n=> true\nall (x: x < 3) [ 1 2 3 ]\n=> false\n"},{"id":"lib.lists.count","category":"./lib/lists.nix","name":"count","fn_type":"count :: (a -> bool) -> [a] -> int","description":["Count how many elements of `list` match the supplied predicate\nfunction."],"example":"\ncount (x: x == 3) [ 3 2 3 4 6 ]\n=> 2\n"},{"id":"lib.lists.optional","category":"./lib/lists.nix","name":"optional","fn_type":"optional :: bool -> a -> [a]","description":["Return a singleton list or an empty list, depending on a boolean\nvalue. Useful when building lists with optional elements\n(e.g. `++ optional (system == \"i686-linux\") firefox')."],"example":"\noptional true \"foo\"\n=> [ \"foo\" ]\noptional false \"foo\"\n=> [ ]\n"},{"id":"lib.lists.optionals","category":"./lib/lists.nix","name":"optionals","fn_type":"optionals :: bool -> [a] -> [a]","description":["Return a list or an empty list, depending on a boolean value."],"example":"\noptionals true [ 2 3 ]\n=> [ 2 3 ]\noptionals false [ 2 3 ]\n=> [ ]\n"},{"id":"lib.lists.toList","category":"./lib/lists.nix","name":"toList","fn_type":null,"description":["If argument is a list, return it; else, wrap it in a singleton\nlist. If you're using this, you should almost certainly\nreconsider if there isn't a more \"well-typed\" approach."],"example":"\ntoList [ 1 2 ]\n=> [ 1 2 ]\ntoList \"hi\"\n=> [ \"hi \"]\n"},{"id":"lib.lists.range","category":"./lib/lists.nix","name":"range","fn_type":"range :: int -> int -> [int]","description":["Return a list of integers from `first' up to and including `last'."],"example":"\nrange 2 4\n=> [ 2 3 4 ]\nrange 3 2\n=> [ ]\n"},{"id":"lib.lists.partition","category":"./lib/lists.nix","name":"partition","fn_type":"(a -> bool) -> [a] -> { right :: [a], wrong :: [a] }","description":["Splits the elements of a list in two lists, `right` and\n`wrong`, depending on the evaluation of a predicate."],"example":"\npartition (x: x > 2) [ 5 1 2 3 4 ]\n=> { right = [ 5 3 4 ]; wrong = [ 1 2 ]; }\n"},{"id":"lib.lists.groupBy'","category":"./lib/lists.nix","name":"groupBy'","fn_type":null,"description":["Splits the elements of a list into many lists, using the return value of a predicate.\nPredicate should return a string which becomes keys of attrset `groupBy' returns.","`groupBy'` allows to customise the combining function and initial value"],"example":"\ngroupBy (x: boolToString (x > 2)) [ 5 1 2 3 4 ]\n=> { true = [ 5 3 4 ]; false = [ 1 2 ]; }\ngroupBy (x: x.name) [ {name = \"icewm\"; script = \"icewm &\";}\n{name = \"xfce\"; script = \"xfce4-session &\";}\n{name = \"icewm\"; script = \"icewmbg &\";}\n{name = \"mate\"; script = \"gnome-session &\";}\n]\n=> { icewm = [ { name = \"icewm\"; script = \"icewm &\"; }\n{ name = \"icewm\"; script = \"icewmbg &\"; } ];\nmate = [ { name = \"mate\"; script = \"gnome-session &\"; } ];\nxfce = [ { name = \"xfce\"; script = \"xfce4-session &\"; } ];\n}\n\ngroupBy' builtins.add 0 (x: boolToString (x > 2)) [ 5 1 2 3 4 ]\n=> { true = 12; false = 3; }\n"},{"id":"lib.lists.zipListsWith","category":"./lib/lists.nix","name":"zipListsWith","fn_type":"zipListsWith :: (a -> b -> c) -> [a] -> [b] -> [c]","description":["Merges two lists of the same size together. If the sizes aren't the same\nthe merging stops at the shortest. How both lists are merged is defined\nby the first argument."],"example":"\nzipListsWith (a: b: a + b) [\"h\" \"l\"] [\"e\" \"o\"]\n=> [\"he\" \"lo\"]\n"},{"id":"lib.lists.zipLists","category":"./lib/lists.nix","name":"zipLists","fn_type":"zipLists :: [a] -> [b] -> [{ fst :: a, snd :: b}]","description":["Merges two lists of the same size together. If the sizes aren't the same\nthe merging stops at the shortest."],"example":"\nzipLists [ 1 2 ] [ \"a\" \"b\" ]\n=> [ { fst = 1; snd = \"a\"; } { fst = 2; snd = \"b\"; } ]\n"},{"id":"lib.lists.reverseList","category":"./lib/lists.nix","name":"reverseList","fn_type":"reverseList :: [a] -> [a]","description":["Reverse the order of the elements of a list."],"example":"\n\nreverseList [ \"b\" \"o\" \"j\" ]\n=> [ \"j\" \"o\" \"b\" ]\n"},{"id":"lib.lists.listDfs","category":"./lib/lists.nix","name":"listDfs","fn_type":null,"description":["Depth-First Search (DFS) for lists `list != []`.","`before a b == true` means that `b` depends on `a` (there's an\nedge from `b` to `a`)."],"example":"\nlistDfs true hasPrefix [ \"/home/user\" \"other\" \"/\" \"/home\" ]\n== { minimal = \"/\"; # minimal element\nvisited = [ \"/home/user\" ]; # seen elements (in reverse order)\nrest = [ \"/home\" \"other\" ]; # everything else\n}\n\nlistDfs true hasPrefix [ \"/home/user\" \"other\" \"/\" \"/home\" \"/\" ]\n== { cycle = \"/\"; # cycle encountered at this element\nloops = [ \"/\" ]; # and continues to these elements\nvisited = [ \"/\" \"/home/user\" ]; # elements leading to the cycle (in reverse order)\nrest = [ \"/home\" \"other\" ]; # everything else\n"},{"id":"lib.lists.toposort","category":"./lib/lists.nix","name":"toposort","fn_type":null,"description":["Sort a list based on a partial ordering using DFS. This\nimplementation is O(N^2), if your ordering is linear, use `sort`\ninstead.","`before a b == true` means that `b` should be after `a`\nin the result."],"example":"\n\ntoposort hasPrefix [ \"/home/user\" \"other\" \"/\" \"/home\" ]\n== { result = [ \"/\" \"/home\" \"/home/user\" \"other\" ]; }\n\ntoposort hasPrefix [ \"/home/user\" \"other\" \"/\" \"/home\" \"/\" ]\n== { cycle = [ \"/home/user\" \"/\" \"/\" ]; # path leading to a cycle\nloops = [ \"/\" ]; } # loops back to these elements\n\ntoposort hasPrefix [ \"other\" \"/home/user\" \"/home\" \"/\" ]\n== { result = [ \"other\" \"/\" \"/home\" \"/home/user\" ]; }\n\ntoposort (a: b: a < b) [ 3 2 1 ] == { result = [ 1 2 3 ]; }\n"},{"id":"lib.lists.sort","category":"./lib/lists.nix","name":"sort","fn_type":null,"description":["Sort a list based on a comparator function which compares two\nelements and returns true if the first argument is strictly below\nthe second argument. The returned list is sorted in an increasing\norder. The implementation does a quick-sort."],"example":"\nsort (a: b: a < b) [ 5 3 7 ]\n=> [ 3 5 7 ]\n"},{"id":"lib.lists.compareLists","category":"./lib/lists.nix","name":"compareLists","fn_type":null,"description":["Compare two lists element-by-element."],"example":"\ncompareLists compare [] []\n=> 0\ncompareLists compare [] [ \"a\" ]\n=> -1\ncompareLists compare [ \"a\" ] []\n=> 1\ncompareLists compare [ \"a\" \"b\" ] [ \"a\" \"c\" ]\n=> -1\n"},{"id":"lib.lists.naturalSort","category":"./lib/lists.nix","name":"naturalSort","fn_type":null,"description":["Sort list using \"Natural sorting\".\nNumeric portions of strings are sorted in numeric order."],"example":"\nnaturalSort [\"disk11\" \"disk8\" \"disk100\" \"disk9\"]\n=> [\"disk8\" \"disk9\" \"disk11\" \"disk100\"]\nnaturalSort [\"10.46.133.149\" \"10.5.16.62\" \"10.54.16.25\"]\n=> [\"10.5.16.62\" \"10.46.133.149\" \"10.54.16.25\"]\nnaturalSort [\"v0.2\" \"v0.15\" \"v0.0.9\"]\n=> [ \"v0.0.9\" \"v0.2\" \"v0.15\" ]\n"},{"id":"lib.lists.take","category":"./lib/lists.nix","name":"take","fn_type":"take :: int -> [a] -> [a]","description":["Return the first (at most) N elements of a list."],"example":"\ntake 2 [ \"a\" \"b\" \"c\" \"d\" ]\n=> [ \"a\" \"b\" ]\ntake 2 [ ]\n=> [ ]\n"},{"id":"lib.lists.drop","category":"./lib/lists.nix","name":"drop","fn_type":"drop :: int -> [a] -> [a]","description":["Remove the first (at most) N elements of a list."],"example":"\ndrop 2 [ \"a\" \"b\" \"c\" \"d\" ]\n=> [ \"c\" \"d\" ]\ndrop 2 [ ]\n=> [ ]\n"},{"id":"lib.lists.sublist","category":"./lib/lists.nix","name":"sublist","fn_type":"sublist :: int -> int -> [a] -> [a]","description":["Return a list consisting of at most `count` elements of `list`,\nstarting at index `start`."],"example":"\nsublist 1 3 [ \"a\" \"b\" \"c\" \"d\" \"e\" ]\n=> [ \"b\" \"c\" \"d\" ]\nsublist 1 3 [ ]\n=> [ ]\n"},{"id":"lib.lists.last","category":"./lib/lists.nix","name":"last","fn_type":"last :: [a] -> a","description":["Return the last element of a list.","This function throws an error if the list is empty."],"example":"\nlast [ 1 2 3 ]\n=> 3\n"},{"id":"lib.lists.init","category":"./lib/lists.nix","name":"init","fn_type":"init :: [a] -> [a]","description":["Return all elements but the last.","This function throws an error if the list is empty."],"example":"\ninit [ 1 2 3 ]\n=> [ 1 2 ]\n"},{"id":"lib.lists.crossLists","category":"./lib/lists.nix","name":"crossLists","fn_type":null,"description":["Return the image of the cross product of some lists by a function."],"example":"\ncrossLists (x:y: \"${toString x}${toString y}\") [[1 2] [3 4]]\n=> [ \"13\" \"14\" \"23\" \"24\" ]\n"},{"id":"lib.lists.unique","category":"./lib/lists.nix","name":"unique","fn_type":"unique :: [a] -> [a]","description":["Remove duplicate elements from the list. O(n^2) complexity."],"example":"\nunique [ 3 2 3 4 ]\n=> [ 3 2 4 ]\n"},{"id":"lib.lists.intersectLists","category":"./lib/lists.nix","name":"intersectLists","fn_type":null,"description":["Intersects list 'e' and another list. O(nm) complexity."],"example":"\nintersectLists [ 1 2 3 ] [ 6 3 2 ]\n=> [ 3 2 ]\n"},{"id":"lib.lists.subtractLists","category":"./lib/lists.nix","name":"subtractLists","fn_type":null,"description":["Subtracts list 'e' from another list. O(nm) complexity."],"example":"\nsubtractLists [ 3 2 ] [ 1 2 3 4 5 3 ]\n=> [ 1 4 5 ]\n"},{"id":"lib.lists.mutuallyExclusive","category":"./lib/lists.nix","name":"mutuallyExclusive","fn_type":null,"description":["Test if two lists have no common element.\nIt should be slightly more efficient than (intersectLists a b == [])"],"example":null},{"id":"lib.licenses.abstyles","category":"./lib/licenses.nix","name":"abstyles","fn_type":null,"description":["License identifiers from spdx.org where possible.\n* If you cannot find your license here, then look for a similar license or\n* add it to this list. The URL mentioned above is a good source for inspiration."],"example":null},{"id":"lib.kernel.whenHelpers","category":"./lib/kernel.nix","name":"whenHelpers","fn_type":null,"description":["Common patterns/legacy used in common-config/hardened/config.nix"],"example":null},{"id":"lib.generators.mkValueStringDefault","category":"./lib/generators.nix","name":"mkValueStringDefault","fn_type":null,"description":["Convert a value to a sensible default string representation.\n* The builtin `toString` function has some strange defaults,\n* suitable for bash scripts but not much else."],"example":null},{"id":"lib.generators.mkKeyValueDefault","category":"./lib/generators.nix","name":"mkKeyValueDefault","fn_type":null,"description":["Generate a line of key k and value v, separated by\n* character sep. If sep appears in k, it is escaped.\n* Helper for synaxes with different separators.\n*\n* mkValueString specifies how values should be formatted.\n*\n* mkKeyValueDefault {} \":\" \"f:oo\" \"bar\"\n* > \"f\\:oo:bar\""],"example":null},{"id":"lib.generators.toKeyValue","category":"./lib/generators.nix","name":"toKeyValue","fn_type":null,"description":["Generate a key-value-style config file from an attrset.\n*\n* mkKeyValue is the same as in toINI."],"example":null},{"id":"lib.generators.toINI","category":"./lib/generators.nix","name":"toINI","fn_type":null,"description":["Generate an INI-style config file from an\n* attrset of sections to an attrset of key-value pairs.\n*\n* generators.toINI {} {\n* foo = { hi = \"${pkgs.hello}\"; ciao = \"bar\"; };\n* baz = { \"also, integers\" = 42; };\n* }\n*\n*> [baz]\n*> also, integers=42\n*>\n*> [foo]\n*> ciao=bar\n*> hi=/nix/store/y93qql1p5ggfnaqjjqhxcw0vqw95rlz0-hello-2.10\n*\n* The mk* configuration attributes can generically change\n* the way sections and key-value strings are generated.\n*\n* For more examples see the test cases in ./tests/misc.nix."],"example":null},{"id":"lib.generators.toINIWithGlobalSection","category":"./lib/generators.nix","name":"toINIWithGlobalSection","fn_type":null,"description":["Generate an INI-style config file from an attrset\n* specifying the global section (no header), and an\n* attrset of sections to an attrset of key-value pairs.\n*\n* generators.toINIWithGlobalSection {} {\n* globalSection = {\n* someGlobalKey = \"hi\";\n* };\n* sections = {\n* foo = { hi = \"${pkgs.hello}\"; ciao = \"bar\"; };\n* baz = { \"also, integers\" = 42; };\n* }\n*\n*> someGlobalKey=hi\n*>\n*> [baz]\n*> also, integers=42\n*>\n*> [foo]\n*> ciao=bar\n*> hi=/nix/store/y93qql1p5ggfnaqjjqhxcw0vqw95rlz0-hello-2.10\n*\n* The mk* configuration attributes can generically change\n* the way sections and key-value strings are generated.\n*\n* For more examples see the test cases in ./tests/misc.nix.\n*\n* If you don’t need a global section, you can also use\n* `generators.toINI` directly, which only takes\n* the part in `sections`."],"example":null},{"id":"lib.generators.toGitINI","category":"./lib/generators.nix","name":"toGitINI","fn_type":null,"description":["Generate a git-config file from an attrset.\n*\n* It has two major differences from the regular INI format:\n*\n* 1. values are indented with tabs\n* 2. sections can have sub-sections\n*\n* generators.toGitINI {\n* url.\"ssh://git@github.com/\".insteadOf = \"https://github.com\";\n* user.name = \"edolstra\";\n* }\n*\n*> [url \"ssh://git@github.com/\"]\n*> insteadOf = https://github.com/\n*>\n*> [user]\n*> name = edolstra"],"example":null},{"id":"lib.generators.toJSON","category":"./lib/generators.nix","name":"toJSON","fn_type":null,"description":["Generates JSON from an arbitrary (non-function) value.\n* For more information see the documentation of the builtin."],"example":null},{"id":"lib.generators.toYAML","category":"./lib/generators.nix","name":"toYAML","fn_type":null,"description":["YAML has been a strict superset of JSON since 1.2, so we\n* use toJSON. Before it only had a few differences referring\n* to implicit typing rules, so it should work with older\n* parsers as well."],"example":null},{"id":"lib.generators.toPretty","category":"./lib/generators.nix","name":"toPretty","fn_type":null,"description":["Pretty print a value, akin to `builtins.trace`.\n* Should probably be a builtin as well."],"example":null},{"id":"lib.generators.toDhall","category":"./lib/generators.nix","name":"toDhall","fn_type":null,"description":["Translate a simple Nix expression to Dhall notation.\n* Note that integers are translated to Integer and never\n* the Natural type."],"example":null},{"id":"lib.filesystem.haskellPathsInDir","category":"./lib/filesystem.nix","name":"haskellPathsInDir","fn_type":"Path -> Map String Path","description":["A map of all haskell packages defined in the given path,\nidentified by having a cabal file with the same name as the\ndirectory itself."],"example":null},{"id":"lib.filesystem.locateDominatingFile","category":"./lib/filesystem.nix","name":"locateDominatingFile","fn_type":"RegExp -> Path -> Nullable { path : Path; matches : [ MatchResults ]; }","description":["Find the first directory containing a file matching 'pattern'\nupward from a given 'file'.\nReturns 'null' if no directories contain a file matching 'pattern'."],"example":null},{"id":"lib.filesystem.listFilesRecursive","category":"./lib/filesystem.nix","name":"listFilesRecursive","fn_type":"Path -> [ Path ]","description":["Given a directory, return a flattened list of all files within it recursively."],"example":null},{"id":"lib.derivations.lazyDerivation","category":"./lib/derivations.nix","name":"lazyDerivation","fn_type":null,"description":["Restrict a derivation to a predictable set of attribute names, so\nthat the returned attrset is not strict in the actual derivation,\nsaving a lot of computation when the derivation is non-trivial.","This is useful in situations where a derivation might only be used for its\npassthru attributes, improving evaluation performance.","The returned attribute set is lazy in `derivation`. Specifically, this\nmeans that the derivation will not be evaluated in at least the\nsituations below.","For illustration and/or testing, we define derivation such that its\nevaluation is very noticable.","let derivation = throw \"This won't be evaluated.\";","In the following expressions, `derivation` will _not_ be evaluated:","(lazyDerivation { inherit derivation; }).type","attrNames (lazyDerivation { inherit derivation; })","(lazyDerivation { inherit derivation; } // { foo = true; }).foo","(lazyDerivation { inherit derivation; meta.foo = true; }).meta","In these expressions, it `derivation` _will_ be evaluated:","\"${lazyDerivation { inherit derivation }}\"","(lazyDerivation { inherit derivation }).outPath","(lazyDerivation { inherit derivation }).meta","And the following expressions are not valid, because the refer to\nimplementation details and/or attributes that may not be present on\nsome derivations:","(lazyDerivation { inherit derivation }).buildInputs","(lazyDerivation { inherit derivation }).passthru","(lazyDerivation { inherit derivation }).pythonPath"],"example":null},{"id":"lib.deprecated.imap","category":"./lib/deprecated.nix","name":"imap","fn_type":null,"description":["deprecated:","For historical reasons, imap has an index starting at 1.","But for consistency with the rest of the library we want an index\nstarting at zero."],"example":null},{"id":"lib.debug.traceIf","category":"./lib/debug.nix","name":"traceIf","fn_type":"traceIf :: bool -> string -> a -> a","description":["Conditionally trace the supplied message, based on a predicate."],"example":"\ntraceIf true \"hello\" 3\ntrace: hello\n=> 3\n"},{"id":"lib.debug.traceValFn","category":"./lib/debug.nix","name":"traceValFn","fn_type":"traceValFn :: (a -> b) -> a -> a","description":["Trace the supplied value after applying a function to it, and\nreturn the original value."],"example":"\ntraceValFn (v: \"mystring ${v}\") \"foo\"\ntrace: mystring foo\n=> \"foo\"\n"},{"id":"lib.debug.traceVal","category":"./lib/debug.nix","name":"traceVal","fn_type":"traceVal :: a -> a","description":["Trace the supplied value and return it."],"example":"\ntraceVal 42\n# trace: 42\n=> 42\n"},{"id":"lib.debug.traceSeq","category":"./lib/debug.nix","name":"traceSeq","fn_type":"traceSeq :: a -> b -> b","description":["`builtins.trace`, but the value is `builtins.deepSeq`ed first."],"example":"\ntrace { a.b.c = 3; } null\ntrace: { a = ; }\n=> null\ntraceSeq { a.b.c = 3; } null\ntrace: { a = { b = { c = 3; }; }; }\n=> null\n"},{"id":"lib.debug.traceSeqN","category":"./lib/debug.nix","name":"traceSeqN","fn_type":null,"description":["Like `traceSeq`, but only evaluate down to depth n.\nThis is very useful because lots of `traceSeq` usages\nlead to an infinite recursion."],"example":"\ntraceSeqN 2 { a.b.c = 3; } null\ntrace: { a = { b = {…}; }; }\n=> null\n"},{"id":"lib.debug.traceValSeqFn","category":"./lib/debug.nix","name":"traceValSeqFn","fn_type":null,"description":["A combination of `traceVal` and `traceSeq` that applies a\nprovided function to the value to be traced after `deepSeq`ing\nit."],"example":null},{"id":"lib.debug.traceValSeq","category":"./lib/debug.nix","name":"traceValSeq","fn_type":null,"description":["A combination of `traceVal` and `traceSeq`."],"example":null},{"id":"lib.debug.traceValSeqNFn","category":"./lib/debug.nix","name":"traceValSeqNFn","fn_type":null,"description":["A combination of `traceVal` and `traceSeqN` that applies a\nprovided function to the value to be traced."],"example":null},{"id":"lib.debug.traceValSeqN","category":"./lib/debug.nix","name":"traceValSeqN","fn_type":null,"description":["A combination of `traceVal` and `traceSeqN`."],"example":null},{"id":"lib.debug.traceFnSeqN","category":"./lib/debug.nix","name":"traceFnSeqN","fn_type":null,"description":["Trace the input and output of a function `f` named `name`,\nboth down to `depth`.","This is useful for adding around a function call,\nto see the before/after of values as they are transformed."],"example":"\ntraceFnSeqN 2 \"id\" (x: x) { a.b.c = 3; }\ntrace: { fn = \"id\"; from = { a.b = {…}; }; to = { a.b = {…}; }; }\n=> { a.b.c = 3; }\n"},{"id":"lib.debug.runTests","category":"./lib/debug.nix","name":"runTests","fn_type":null,"description":["Evaluate a set of tests. A test is an attribute set `{expr,\nexpected}`, denoting an expression and its expected result. The\nresult is a list of failed tests, each represented as `{name,\nexpected, actual}`, denoting the attribute name of the failing\ntest and its expected and actual results.","Used for regression testing of the functions in lib; see\ntests.nix for an example. Only tests having names starting with\n\"test\" are run.","Add attr { tests = [\"testName\"]; } to run these tests only."],"example":null},{"id":"lib.debug.testAllTrue","category":"./lib/debug.nix","name":"testAllTrue","fn_type":null,"description":["Create a test assuming that list elements are `true`."],"example":"\n{ testX = allTrue [ true ]; }\n"},{"id":"lib.customisation.overrideDerivation","category":"./lib/customisation.nix","name":"overrideDerivation","fn_type":null,"description":["`overrideDerivation drv f' takes a derivation (i.e., the result\nof a call to the builtin function `derivation') and returns a new\nderivation in which the attributes of the original are overridden\naccording to the function `f'. The function `f' is called with\nthe original derivation attributes.","`overrideDerivation' allows certain \"ad-hoc\" customisation\nscenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance,\nif you want to \"patch\" the derivation returned by a package\nfunction in Nixpkgs to build another version than what the\nfunction itself provides, you can do something like this:","mySed = overrideDerivation pkgs.gnused (oldAttrs: {\nname = \"sed-4.2.2-pre\";\nsrc = fetchurl {\nurl = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;\nsha256 = \"11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k\";\n};\npatches = [];\n});","For another application, see build-support/vm, where this\nfunction is used to build arbitrary derivations inside a QEMU\nvirtual machine."],"example":null},{"id":"lib.customisation.makeOverridable","category":"./lib/customisation.nix","name":"makeOverridable","fn_type":null,"description":["`makeOverridable` takes a function from attribute set to attribute set and\ninjects `override` attribute which can be used to override arguments of\nthe function.","nix-repl> x = {a, b}: { result = a + b; }","nix-repl> y = lib.makeOverridable x { a = 1; b = 2; }","nix-repl> y\n{ override = «lambda»; overrideDerivation = «lambda»; result = 3; }","nix-repl> y.override { a = 10; }\n{ override = «lambda»; overrideDerivation = «lambda»; result = 12; }","Please refer to \"Nixpkgs Contributors Guide\" section\n\".overrideDerivation\" to learn about `overrideDerivation` and caveats\nrelated to its use."],"example":null},{"id":"lib.customisation.callPackageWith","category":"./lib/customisation.nix","name":"callPackageWith","fn_type":null,"description":["Call the package function in the file `fn' with the required\narguments automatically. The function is called with the\narguments `args', but any missing arguments are obtained from\n`autoArgs'. This function is intended to be partially\nparameterised, e.g.,","callPackage = callPackageWith pkgs;\npkgs = {\nlibfoo = callPackage ./foo.nix { };\nlibbar = callPackage ./bar.nix { };\n};","If the `libbar' function expects an argument named `libfoo', it is\nautomatically passed as an argument. Overrides or missing\narguments can be supplied in `args', e.g.","libbar = callPackage ./bar.nix {\nlibfoo = null;\nenableX11 = true;\n};"],"example":null},{"id":"lib.customisation.callPackagesWith","category":"./lib/customisation.nix","name":"callPackagesWith","fn_type":null,"description":["Like callPackage, but for a function that returns an attribute\nset of derivations. The override function is added to the\nindividual attributes."],"example":null},{"id":"lib.customisation.extendDerivation","category":"./lib/customisation.nix","name":"extendDerivation","fn_type":null,"description":["Add attributes to each output of a derivation without changing\nthe derivation itself and check a given condition when evaluating."],"example":null},{"id":"lib.customisation.hydraJob","category":"./lib/customisation.nix","name":"hydraJob","fn_type":null,"description":["Strip a derivation of all non-essential attributes, returning\nonly those needed by hydra-eval-jobs. Also strictly evaluate the\nresult to ensure that there are no thunks kept alive to prevent\ngarbage collection."],"example":null},{"id":"lib.customisation.makeScope","category":"./lib/customisation.nix","name":"makeScope","fn_type":null,"description":["Make a set of packages with a common scope. All packages called\nwith the provided `callPackage' will be evaluated with the same\narguments. Any package in the set may depend on any other. The\n`overrideScope'` function allows subsequent modification of the package\nset in a consistent way, i.e. all packages in the set will be\ncalled with the overridden packages. The package sets may be\nhierarchical: the packages in the set are called with the scope\nprovided by `newScope' and the set provides a `newScope' attribute\nwhich can form the parent scope for later package sets."],"example":null},{"id":"lib.customisation.makeScopeWithSplicing","category":"./lib/customisation.nix","name":"makeScopeWithSplicing","fn_type":null,"description":["Like the above, but aims to support cross compilation. It's still ugly, but\nhopefully it helps a little bit."],"example":null},{"id":"lib.cli.toGNUCommandLineShell","category":"./lib/cli.nix","name":"toGNUCommandLineShell","fn_type":null,"description":["Automatically convert an attribute set to command-line options.","This helps protect against malformed command lines and also to reduce\nboilerplate related to command-line construction for simple use cases.","`toGNUCommandLine` returns a list of nix strings.\n`toGNUCommandLineShell` returns an escaped shell string."],"example":"\ncli.toGNUCommandLine {} {\ndata = builtins.toJSON { id = 0; };\nX = \"PUT\";\nretry = 3;\nretry-delay = null;\nurl = [ \"https://example.com/foo\" \"https://example.com/bar\" ];\nsilent = false;\nverbose = true;\n}\n=> [\n\"-X\" \"PUT\"\n\"--data\" \"{\\\"id\\\":0}\"\n\"--retry\" \"3\"\n\"--url\" \"https://example.com/foo\"\n\"--url\" \"https://example.com/bar\"\n\"--verbose\"\n]\n\ncli.toGNUCommandLineShell {} {\ndata = builtins.toJSON { id = 0; };\nX = \"PUT\";\nretry = 3;\nretry-delay = null;\nurl = [ \"https://example.com/foo\" \"https://example.com/bar\" ];\nsilent = false;\nverbose = true;\n}\n=> \"'-X' 'PUT' '--data' '{\\\"id\\\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'\";\n"},{"id":"lib.attrsets.attrByPath","category":"./lib/attrsets.nix","name":"attrByPath","fn_type":"attrByPath :: [String] -> b -> AttrSet -> c","description":["Return an attribute from nested attribute sets."],"example":"\nx = { a = { b = 3; }; }\n# [\"a\" \"b\"] is equivalent to x.a.b\n# 6 is a default value to return if the path does not exist in attrset\nattrByPath [\"a\" \"b\"] 6 x\n=> 3\nattrByPath [\"z\" \"z\"] 6 x\n=> 6\n"},{"id":"lib.attrsets.hasAttrByPath","category":"./lib/attrsets.nix","name":"hasAttrByPath","fn_type":"hasAttrByPath :: [String] -> AttrSet -> Bool","description":["Return if an attribute from nested attribute set exists."],"example":"\nx = { a = { b = 3; }; }\nhasAttrByPath [\"a\" \"b\"] x\n=> true\nhasAttrByPath [\"z\" \"z\"] x\n=> false\n"},{"id":"lib.attrsets.setAttrByPath","category":"./lib/attrsets.nix","name":"setAttrByPath","fn_type":"setAttrByPath :: [String] -> a -> AttrSet","description":["Return nested attribute set in which an attribute is set."],"example":"\nsetAttrByPath [\"a\" \"b\"] 3\n=> { a = { b = 3; }; }\n"},{"id":"lib.attrsets.getAttrFromPath","category":"./lib/attrsets.nix","name":"getAttrFromPath","fn_type":"getAttrFromPath :: [string] -> AttrSet -> a","description":["Like `attrByPath' without a default value. If it doesn't find the\npath it will throw."],"example":"\nx = { a = { b = 3; }; }\ngetAttrFromPath [\"a\" \"b\"] x\n=> 3\ngetAttrFromPath [\"z\" \"z\"] x\n=> error: cannot find attribute `z.z'\n"},{"id":"lib.attrsets.concatMapAttrs","category":"./lib/attrsets.nix","name":"concatMapAttrs","fn_type":"concatMapAttrs ::(String -> a -> AttrSet)-> AttrSet-> AttrSet","description":["Map each attribute in the given set and merge them into a new attribute set."],"example":"\nconcatMapAttrs\n(name: value: {\n${name} = value;\n${name + value} = value;\n})\n{ x = \"a\"; y = \"b\"; }\n=> { x = \"a\"; xa = \"a\"; y = \"b\"; yb = \"b\"; }\n"},{"id":"lib.attrsets.updateManyAttrsByPath","category":"./lib/attrsets.nix","name":"updateManyAttrsByPath","fn_type":"updateManyAttrsByPath :: [{ path :: [string], update :: (a -> b) }] -> a -> b","description":["Update or set specific paths of an attribute set.","Takes a list of updates to apply and an attribute set to apply them to,\nand returns the attribute set with the updates applied. Updates are\nrepresented as { path = ...; update = ...; } values, where `path` is a\nlist of strings representing the attribute path that should be updated,\nand `update` is a function that takes the old value at that attribute path\nas an argument and returns the new\nvalue it should be.","Properties:\n- Updates to deeper attribute paths are applied before updates to more\nshallow attribute paths\n- Multiple updates to the same attribute path are applied in the order\nthey appear in the update list\n- If any but the last `path` element leads into a value that is not an\nattribute set, an error is thrown\n- If there is an update for an attribute path that doesn't exist,\naccessing the argument in the update function causes an error, but\nintermediate attribute sets are implicitly created as needed"],"example":"\nupdateManyAttrsByPath [\n{\npath = [ \"a\" \"b\" ];\nupdate = old: { d = old.c; };\n}\n{\npath = [ \"a\" \"b\" \"c\" ];\nupdate = old: old + 1;\n}\n{\npath = [ \"x\" \"y\" ];\nupdate = old: \"xy\";\n}\n] { a.b.c = 0; }\n=> { a = { b = { d = 1; }; }; x = { y = \"xy\"; }; }\n"},{"id":"lib.attrsets.attrVals","category":"./lib/attrsets.nix","name":"attrVals","fn_type":"attrVals :: [string] -> AttrSet -> [AttrSet]","description":["Return the specified attributes from a set."],"example":"\nattrVals [\"a\" \"b\" \"c\"] as\n=> [as.a as.b as.c]\n"},{"id":"lib.attrsets.attrValues","category":"./lib/attrsets.nix","name":"attrValues","fn_type":"attrValues :: AttrsSet -> [a]","description":["Return the values of all attributes in the given set, sorted by\nattribute name."],"example":"\nattrValues {c = 3; a = 1; b = 2;}\n=> [1 2 3]\n"},{"id":"lib.attrsets.getAttrs","category":"./lib/attrsets.nix","name":"getAttrs","fn_type":"getAttrs :: [a] -> AttrSet -> AttrSet","description":["Given a set of attribute names, return the set of the corresponding\nattributes from the given set."],"example":"\ngetAttrs [ \"a\" \"b\" ] { a = 1; b = 2; c = 3; }\n=> { a = 1; b = 2; }\n"},{"id":"lib.attrsets.catAttrs","category":"./lib/attrsets.nix","name":"catAttrs","fn_type":"catAttrs :: string -> [AttrSet] -> [a]","description":["Collect each attribute named `attr' from a list of attribute\nsets. Sets that don't contain the named attribute are ignored."],"example":"\ncatAttrs \"a\" [{a = 1;} {b = 0;} {a = 2;}]\n=> [1 2]\n"},{"id":"lib.attrsets.filterAttrs","category":"./lib/attrsets.nix","name":"filterAttrs","fn_type":"filterAttrs :: (a -> b -> bool) -> AttrSet -> AttrSet","description":["Filter an attribute set by removing all attributes for which the\ngiven predicate return false."],"example":"\nfilterAttrs (n: v: n == \"foo\") { foo = 1; bar = 2; }\n=> { foo = 1; }\n"},{"id":"lib.attrsets.filterAttrsRecursive","category":"./lib/attrsets.nix","name":"filterAttrsRecursive","fn_type":"filterAttrsRecursive :: (a -> b -> bool) -> AttrSet -> AttrSet","description":["Filter an attribute set recursively by removing all attributes for\nwhich the given predicate return false."],"example":"\nfilterAttrsRecursive (n: v: v != null) { foo = { bar = null; }; }\n=> { foo = {}; }\n"},{"id":"lib.attrsets.foldAttrs","category":"./lib/attrsets.nix","name":"foldAttrs","fn_type":"foldAttrs :: (a -> b -> [c]) -> [a] -> [AttrSet] -> AttrSet","description":["Apply fold functions to values grouped by key."],"example":"\nfoldAttrs (item: acc: [item] ++ acc) [] [{ a = 2; } { a = 3; }]\n=> { a = [ 2 3 ]; }\n"},{"id":"lib.attrsets.collect","category":"./lib/attrsets.nix","name":"collect","fn_type":"collect ::(AttrSet -> Bool) -> AttrSet -> [x]","description":["Recursively collect sets that verify a given predicate named `pred'\nfrom the set `attrs'. The recursion is stopped when the predicate is\nverified."],"example":"\ncollect isList { a = { b = [\"b\"]; }; c = [1]; }\n=> [[\"b\"] [1]]\n\ncollect (x: x ? outPath)\n{ a = { outPath = \"a/\"; }; b = { outPath = \"b/\"; }; }\n=> [{ outPath = \"a/\"; } { outPath = \"b/\"; }]\n"},{"id":"lib.attrsets.cartesianProductOfSets","category":"./lib/attrsets.nix","name":"cartesianProductOfSets","fn_type":"cartesianProductOfSets :: AttrSet -> AttrsSet -> [AttrSet]","description":["Return the cartesian product of attribute set value combinations."],"example":"\ncartesianProductOfSets { a = [ 1 2 ]; b = [ 10 20 ]; }\n=> [\n{ a = 1; b = 10; }\n{ a = 1; b = 20; }\n{ a = 2; b = 10; }\n{ a = 2; b = 20; }\n]\n"},{"id":"lib.attrsets.nameValuePair","category":"./lib/attrsets.nix","name":"nameValuePair","fn_type":"nameValuePair :: string -> a -> { name :: string, value :: a }","description":["Utility function that creates a {name, value} pair as expected by\nbuiltins.listToAttrs."],"example":"\nnameValuePair \"some\" 6\n=> { name = \"some\"; value = 6; }\n"},{"id":"lib.attrsets.mapAttrs","category":"./lib/attrsets.nix","name":"mapAttrs","fn_type":"mapAttrs :: (name :: string -> value :: any -> any ) -> AttrSet -> AttrSet","description":["Apply a function to each element in an attribute set. The\nfunction takes two arguments --- the attribute name and its value\n--- and returns the new value for the attribute. The result is a\nnew attribute set."],"example":"\nmapAttrs (name: value: name + \"-\" + value)\n{ x = \"foo\"; y = \"bar\"; }\n=> { x = \"x-foo\"; y = \"y-bar\"; }\n"},{"id":"lib.attrsets.mapAttrs'","category":"./lib/attrsets.nix","name":"mapAttrs'","fn_type":"mapAttrs' :: (name :: string -> value :: any -> nameValuePair ) -> AttrSet -> AttrSet","description":["Like `mapAttrs', but allows the name of each attribute to be\nchanged in addition to the value. The applied function should\nreturn both the new name and value as a `nameValuePair'."],"example":"\nmapAttrs' (name: value: nameValuePair (\"foo_\" + name) (\"bar-\" + value))\n{ x = \"a\"; y = \"b\"; }\n=> { foo_x = \"bar-a\"; foo_y = \"bar-b\"; }\n"},{"id":"lib.attrsets.mapAttrsToList","category":"./lib/attrsets.nix","name":"mapAttrsToList","fn_type":"mapAttrsToList ::(String -> a -> b) -> AttrSet -> [b]","description":["Call a function for each attribute in the given set and return\nthe result in a list."],"example":"\nmapAttrsToList (name: value: name + value)\n{ x = \"a\"; y = \"b\"; }\n=> [ \"xa\" \"yb\" ]\n"},{"id":"lib.attrsets.mapAttrsRecursive","category":"./lib/attrsets.nix","name":"mapAttrsRecursive","fn_type":"mapAttrsRecursive ::([String] -> a -> b) -> AttrSet -> AttrSet","description":["Like `mapAttrs', except that it recursively applies itself to\nattribute sets. Also, the first argument of the argument\nfunction is a *list* of the names of the containing attributes."],"example":"\nmapAttrsRecursive (path: value: concatStringsSep \"-\" (path ++ [value]))\n{ n = { a = \"A\"; m = { b = \"B\"; c = \"C\"; }; }; d = \"D\"; }\n=> { n = { a = \"n-a-A\"; m = { b = \"n-m-b-B\"; c = \"n-m-c-C\"; }; }; d = \"d-D\"; }\n"},{"id":"lib.attrsets.mapAttrsRecursiveCond","category":"./lib/attrsets.nix","name":"mapAttrsRecursiveCond","fn_type":"mapAttrsRecursiveCond ::(AttrSet -> Bool) -> ([String] -> a -> b) -> AttrSet -> AttrSet","description":["Like `mapAttrsRecursive', but it takes an additional predicate\nfunction that tells it whether to recurse into an attribute\nset. If it returns false, `mapAttrsRecursiveCond' does not\nrecurse, but does apply the map function. If it returns true, it\ndoes recurse, and does not apply the map function."],"example":"\n# To prevent recursing into derivations (which are attribute\n# sets with the attribute \"type\" equal to \"derivation\"):\nmapAttrsRecursiveCond\n(as: !(as ? \"type\" && as.type == \"derivation\"))\n(x: ... do something ...)\nattrs\n"},{"id":"lib.attrsets.genAttrs","category":"./lib/attrsets.nix","name":"genAttrs","fn_type":"genAttrs :: [names :: string] -> (a -> b) -> AttrSet","description":["Generate an attribute set by mapping a function over a list of\nattribute names."],"example":"\ngenAttrs [ \"foo\" \"bar\" ] (name: \"x_\" + name)\n=> { foo = \"x_foo\"; bar = \"x_bar\"; }\n"},{"id":"lib.attrsets.isDerivation","category":"./lib/attrsets.nix","name":"isDerivation","fn_type":"isDerivation :: a -> bool","description":["Check whether the argument is a derivation. Any set with\n{ type = \"derivation\"; } counts as a derivation."],"example":"\nnixpkgs = import {}\nisDerivation nixpkgs.ruby\n=> true\nisDerivation \"foobar\"\n=> false\n"},{"id":"lib.attrsets.toDerivation","category":"./lib/attrsets.nix","name":"toDerivation","fn_type":"toDerivation :: string -> AttrSet","description":["Converts a store path to a fake derivation."],"example":null},{"id":"lib.attrsets.optionalAttrs","category":"./lib/attrsets.nix","name":"optionalAttrs","fn_type":"optionalAttrs :: bool -> AttrSet -> AttrSet","description":["If `cond' is true, return the attribute set `as',\notherwise an empty attribute set."],"example":"\noptionalAttrs (true) { my = \"set\"; }\n=> { my = \"set\"; }\noptionalAttrs (false) { my = \"set\"; }\n=> { }\n"},{"id":"lib.attrsets.zipAttrsWithNames","category":"./lib/attrsets.nix","name":"zipAttrsWithNames","fn_type":"zipAttrsWithNames :: [a] -> (name :: string -> values :: [b] -> c) -> [AttrSet] -> AttrSet","description":["Merge sets of attributes and use the function f to merge attributes\nvalues."],"example":"\nzipAttrsWithNames [\"a\"] (name: vs: vs) [{a = \"x\";} {a = \"y\"; b = \"z\";}]\n=> { a = [\"x\" \"y\"]; }\n"},{"id":"lib.attrsets.zipAttrsWith","category":"./lib/attrsets.nix","name":"zipAttrsWith","fn_type":"zipAttrsWith :: (name :: string -> values :: [a] -> b) -> [AttrSet] -> AttrSet","description":["Implementation note: Common names appear multiple times in the list of\nnames, hopefully this does not affect the system because the maximal\nlaziness avoid computing twice the same expression and listToAttrs does\nnot care about duplicated attribute names."],"example":"\nzipAttrsWith (name: values: values) [{a = \"x\";} {a = \"y\"; b = \"z\";}]\n=> { a = [\"x\" \"y\"]; b = [\"z\"] }\n"},{"id":"lib.attrsets.zipAttrs","category":"./lib/attrsets.nix","name":"zipAttrs","fn_type":"zipAttrs :: [AttrSet] -> AttrSet","description":["Like `zipAttrsWith' with `(name: values: values)' as the function."],"example":"\nzipAttrs [{a = \"x\";} {a = \"y\"; b = \"z\";}]\n=> { a = [\"x\" \"y\"]; b = [\"z\"] }\n"},{"id":"lib.attrsets.recursiveUpdateUntil","category":"./lib/attrsets.nix","name":"recursiveUpdateUntil","fn_type":"recursiveUpdateUntil :: (path :: [string] -> lhs :: any -> rhs :: any -> bool) -> AttrSet -> AttrSet -> [AttrSet]","description":["Does the same as the update operator '//' except that attributes are\nmerged until the given predicate is verified. The predicate should\naccept 3 arguments which are the path to reach the attribute, a part of\nthe first attribute set and a part of the second attribute set. When\nthe predicate is verified, the value of the first attribute set is\nreplaced by the value of the second attribute set."],"example":"\nrecursiveUpdateUntil (path: l: r: path == [\"foo\"]) {\n# first attribute set\nfoo.bar = 1;\nfoo.baz = 2;\nbar = 3;\n} {\n#second attribute set\nfoo.bar = 1;\nfoo.quz = 2;\nbaz = 4;\n}\n\nreturns: {\nfoo.bar = 1; # 'foo.*' from the second set\nfoo.quz = 2; #\nbar = 3; # 'bar' from the first set\nbaz = 4; # 'baz' from the second set\n}\n"},{"id":"lib.attrsets.recursiveUpdate","category":"./lib/attrsets.nix","name":"recursiveUpdate","fn_type":"recursiveUpdate :: AttrSet -> AttrSet -> Attrset","description":["A recursive variant of the update operator ‘//’. The recursion\nstops when one of the attribute values is not an attribute set,\nin which case the right hand side value takes precedence over the\nleft hand side value."],"example":"\nrecursiveUpdate {\nboot.loader.grub.enable = true;\nboot.loader.grub.device = \"/dev/hda\";\n} {\nboot.loader.grub.device = \"\";\n}\n\nreturns: {\nboot.loader.grub.enable = true;\nboot.loader.grub.device = \"\";\n}\n"},{"id":"lib.attrsets.matchAttrs","category":"./lib/attrsets.nix","name":"matchAttrs","fn_type":"matchAttrs :: AttrSet -> AttrSet -> bool","description":["Returns true if the pattern is contained in the set. False otherwise."],"example":"\nmatchAttrs { cpu = {}; } { cpu = { bits = 64; }; }\n=> true\n"},{"id":"lib.attrsets.overrideExisting","category":"./lib/attrsets.nix","name":"overrideExisting","fn_type":"overrideExisting :: AttrSet -> AttrSet -> AttrSet","description":["Override only the attributes that are already present in the old set\nuseful for deep-overriding."],"example":"\noverrideExisting {} { a = 1; }\n=> {}\noverrideExisting { b = 2; } { a = 1; }\n=> { b = 2; }\noverrideExisting { a = 3; b = 2; } { a = 1; }\n=> { a = 1; b = 2; }\n"},{"id":"lib.attrsets.showAttrPath","category":"./lib/attrsets.nix","name":"showAttrPath","fn_type":"showAttrPath :: [string] -> string","description":["Turns a list of strings into a human-readable description of those\nstrings represented as an attribute path. The result of this function is\nnot intended to be machine-readable."],"example":"\nshowAttrPath [ \"foo\" \"10\" \"bar\" ]\n=> \"foo.\\\"10\\\".bar\"\nshowAttrPath []\n=> \"\"\n"},{"id":"lib.attrsets.getOutput","category":"./lib/attrsets.nix","name":"getOutput","fn_type":"getOutput :: string -> AttrSet -> string","description":["Get a package output.\nIf no output is found, fallback to `.out` and then to the default."],"example":"\ngetOutput \"dev\" pkgs.openssl\n=> \"/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev\"\n"},{"id":"lib.attrsets.chooseDevOutputs","category":"./lib/attrsets.nix","name":"chooseDevOutputs","fn_type":"chooseDevOutputs :: [AttrSet] -> [string]","description":["Pick the outputs of packages to place in buildInputs"],"example":null},{"id":"lib.attrsets.recurseIntoAttrs","category":"./lib/attrsets.nix","name":"recurseIntoAttrs","fn_type":"recurseIntoAttrs :: AttrSet -> AttrSet","description":["Make various Nix tools consider the contents of the resulting\nattribute set when looking for what to build, find, etc.","This function only affects a single attribute set; it does not\napply itself recursively for nested attribute sets."],"example":null},{"id":"lib.attrsets.dontRecurseIntoAttrs","category":"./lib/attrsets.nix","name":"dontRecurseIntoAttrs","fn_type":"dontRecurseIntoAttrs :: AttrSet -> AttrSet","description":["Undo the effect of recurseIntoAttrs."],"example":null},{"id":"lib.attrsets.unionOfDisjoint","category":"./lib/attrsets.nix","name":"unionOfDisjoint","fn_type":"unionOfDisjoint :: AttrSet -> AttrSet -> AttrSet","description":["`unionOfDisjoint x y` is equal to `x // y // z` where the\nattrnames in `z` are the intersection of the attrnames in `x` and\n`y`, and all values `assert` with an error message. This\noperator is commutative, unlike (//)."],"example":null},{"id":"lib.attrsets.zipWithNames","category":"./lib/attrsets.nix","name":"zipWithNames","fn_type":"zipWithNames :: [a] -> (name :: string -> values :: [b] -> c) -> [AttrSet] -> AttrSet","description":["deprecated use zipAttrsWithNames instead"],"example":null},{"id":"lib.attrsets.zip","category":"./lib/attrsets.nix","name":"zip","fn_type":"zip :: (name :: string -> values :: [a] -> b) -> [AttrSet] -> AttrSet","description":["deprecated use zipAttrsWith instead"],"example":null},{"id":"lib.asserts.assertMsg","category":"./lib/asserts.nix","name":"assertMsg","fn_type":"assertMsg :: Bool -> String -> Bool","description":["Throw if pred is false, else return pred.\nIntended to be used to augment asserts with helpful error messages."],"example":"\nassertMsg false \"nope\"\nstderr> error: nope\n\nassert assertMsg (\"foo\" == \"bar\") \"foo is not bar, silly\"; \"\"\nstderr> error: foo is not bar, silly\n\n"},{"id":"lib.asserts.assertOneOf","category":"./lib/asserts.nix","name":"assertOneOf","fn_type":"assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool","description":["Specialized `assertMsg` for checking if val is one of the elements\nof a list. Useful for checking enums."],"example":"\nlet sslLibrary = \"libressl\";\nin assertOneOf \"sslLibrary\" sslLibrary [ \"openssl\" \"bearssl\" ]\nstderr> error: sslLibrary must be one of [\nstderr> \"openssl\"\nstderr> \"bearssl\"\nstderr> ], but is: \"libressl\"\n\n"}]
\ No newline at end of file
diff --git a/models/data/trivial-builders.json b/models/data/trivial-builders.json
deleted file mode 100644
index 81e1550..0000000
--- a/models/data/trivial-builders.json
+++ /dev/null
@@ -1,238 +0,0 @@
-[
- {
- "id": "trivial-builders.runCommand",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "runCommand",
- "fn_type": null,
- "description": [
- "Run the shell command `buildCommand' to produce a store path named\n`name'. The attributes in `env' are added to the environment\nprior to running the command. By default `runCommand` runs in a\nstdenv with no compiler environment. `runCommandCC` uses the default\nstdenv, `pkgs.stdenv`."
- ],
- "example": "\nrunCommand \"name\" {envVariable = true;} ''echo hello > $out''\nrunCommandCC \"name\" {} ''gcc -o myfile myfile.c; cp myfile $out'';\nThe `*Local` variants force a derivation to be built locally,\nit is not substituted.\nThis is intended for very cheap commands (<1s execution time).\nIt saves on the network roundrip and can speed up a build.\nIt is the same as adding the special fields\n`preferLocalBuild = true;`\n`allowSubstitutes = false;`\nto a derivation’s attributes.\n"
- },
- {
- "id": "trivial-builders.runCommandWith",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "runCommandWith",
- "fn_type": null,
- "description": [
- "Generalized version of the `runCommand`-variants\nwhich does customized behavior via a single\nattribute set passed as the first argument\ninstead of having a lot of variants like\n`runCommand*`. Additionally it allows changing\nthe used `stdenv` freely and has a more explicit\napproach to changing the arguments passed to\n`stdenv.mkDerivation`."
- ],
- "example": null
- },
- {
- "id": "trivial-builders.writeTextFile",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeTextFile",
- "fn_type": null,
- "description": [
- "Writes a text file to the nix store.\nThe contents of text is added to the file in the store."
- ],
- "example": "\n# Writes my-file to /nix/store/\nwriteTextFile {\nname = \"my-file\";\ntext = ''\nContents of File\n'';\n}\nSee also the `writeText` helper function below.\n# Writes executable my-file to /nix/store//bin/my-file\nwriteTextFile {\nname = \"my-file\";\ntext = ''\nContents of File\n'';\nexecutable = true;\ndestination = \"/bin/my-file\";\n}\n"
- },
- {
- "id": "trivial-builders.writeText",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeText",
- "fn_type": null,
- "description": [
- "Writes a text file to nix store with no optional parameters available."
- ],
- "example": "\n# Writes contents of file to /nix/store/\nwriteText \"my-file\"\n''\nContents of File\n'';\n"
- },
- {
- "id": "trivial-builders.writeTextDir",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeTextDir",
- "fn_type": null,
- "description": [
- "Writes a text file to nix store in a specific directory with no\noptional parameters available."
- ],
- "example": "\n# Writes contents of file to /nix/store//share/my-file\nwriteTextDir \"share/my-file\"\n''\nContents of File\n'';\n"
- },
- {
- "id": "trivial-builders.writeScript",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeScript",
- "fn_type": null,
- "description": [
- "Writes a text file to /nix/store/ and marks the file as\nexecutable.",
- "If passed as a build input, will be used as a setup hook. This makes setup\nhooks more efficient to create: you don't need a derivation that copies\nthem to $out/nix-support/setup-hook, instead you can use the file as is."
- ],
- "example": "\n# Writes my-file to /nix/store/ and makes executable\nwriteScript \"my-file\"\n''\nContents of File\n'';\n"
- },
- {
- "id": "trivial-builders.writeScriptBin",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeScriptBin",
- "fn_type": null,
- "description": [
- "Writes a text file to /nix/store//bin/ and\nmarks the file as executable."
- ],
- "example": "\n# Writes my-file to /nix/store//bin/my-file and makes executable.\nwriteScriptBin \"my-file\"\n''\nContents of File\n'';\n"
- },
- {
- "id": "trivial-builders.writeShellScript",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeShellScript",
- "fn_type": null,
- "description": [
- "Similar to writeScript. Writes a Shell script and checks its syntax.\nAutomatically includes interpreter above the contents passed."
- ],
- "example": "\n# Writes my-file to /nix/store/ and makes executable.\nwriteShellScript \"my-file\"\n''\nContents of File\n'';\n"
- },
- {
- "id": "trivial-builders.writeShellScriptBin",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeShellScriptBin",
- "fn_type": null,
- "description": [
- "Similar to writeShellScript and writeScriptBin.\nWrites an executable Shell script to /nix/store//bin/ and checks its syntax.\nAutomatically includes interpreter above the contents passed."
- ],
- "example": "\n# Writes my-file to /nix/store//bin/my-file and makes executable.\nwriteShellScriptBin \"my-file\"\n''\nContents of File\n'';\n"
- },
- {
- "id": "trivial-builders.writeShellApplication",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeShellApplication",
- "fn_type": null,
- "description": [
- "Similar to writeShellScriptBin and writeScriptBin.\nWrites an executable Shell script to /nix/store//bin/ and\nchecks its syntax with shellcheck and the shell's -n option.\nAutomatically includes sane set of shellopts (errexit, nounset, pipefail)\nand handles creation of PATH based on runtimeInputs",
- "Note that the checkPhase uses stdenv.shell for the test run of the script,\nwhile the generated shebang uses runtimeShell. If, for whatever reason,\nthose were to mismatch you might lose fidelity in the default checks."
- ],
- "example": "\nWrites my-file to /nix/store//bin/my-file and makes executable.\nwriteShellApplication {\nname = \"my-file\";\nruntimeInputs = [ curl w3m ];\ntext = ''\ncurl -s 'https://nixos.org' | w3m -dump -T text/html\n'';\n}\n"
- },
- {
- "id": "trivial-builders.concatTextFile",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "concatTextFile",
- "fn_type": null,
- "description": [
- "concat a list of files to the nix store.\nThe contents of files are added to the file in the store."
- ],
- "example": "\n# Writes my-file to /nix/store/\nconcatTextFile {\n name = \"my-file\";\nfiles = [ drv1 \"${drv2}/path/to/file\" ];\n}\nSee also the `concatText` helper function below.\n# Writes executable my-file to /nix/store//bin/my-file\nconcatTextFile {\nname = \"my-file\";\nfiles = [ drv1 \"${drv2}/path/to/file\" ];\nexecutable = true;\ndestination = \"/bin/my-file\";\n}\n"
- },
- {
- "id": "trivial-builders.concatText",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "concatText",
- "fn_type": null,
- "description": [
- "Writes a text file to nix store with no optional parameters available."
- ],
- "example": "\n# Writes contents of files to /nix/store/\nconcatText \"my-file\" [ file1 file2 ]\n"
- },
- {
- "id": "trivial-builders.concatScript",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "concatScript",
- "fn_type": null,
- "description": [
- "Writes a text file to nix store with and mark it as executable."
- ],
- "example": "\n# Writes contents of files to /nix/store/\nconcatScript \"my-file\" [ file1 file2 ]\n"
- },
- {
- "id": "trivial-builders.symlinkJoin",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "symlinkJoin",
- "fn_type": null,
- "description": [
- "Create a forest of symlinks to the files in `paths'.",
- "This creates a single derivation that replicates the directory structure\nof all the input paths.",
- "BEWARE: it may not \"work right\" when the passed paths contain symlinks to directories."
- ],
- "example": "\n# adds symlinks of hello to current build.\nsymlinkJoin { name = \"myhello\"; paths = [ pkgs.hello ]; }\n# adds symlinks of hello and stack to current build and prints \"links added\"\nsymlinkJoin { name = \"myexample\"; paths = [ pkgs.hello pkgs.stack ]; postBuild = \"echo links added\"; }\nThis creates a derivation with a directory structure like the following:\n/nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample\n|-- bin\n| |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello\n| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack\n`-- share\n|-- bash-completion\n| `-- completions\n| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack\n|-- fish\n| `-- vendor_completions.d\n| `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish\n...\nsymlinkJoin and linkFarm are similar functions, but they output\nderivations with different structure.\nsymlinkJoin is used to create a derivation with a familiar directory\nstructure (top-level bin/, share/, etc), but with all actual files being symlinks to\nthe files in the input derivations.\nsymlinkJoin is used many places in nixpkgs to create a single derivation\nthat appears to contain binaries, libraries, documentation, etc from\nmultiple input derivations.\nlinkFarm is instead used to create a simple derivation with symlinks to\nother derivations. A derivation created with linkFarm is often used in CI\nas a easy way to build multiple derivations at once.\n"
- },
- {
- "id": "trivial-builders.linkFarm",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "linkFarm",
- "fn_type": null,
- "description": [
- "Quickly create a set of symlinks to derivations.",
- "This creates a simple derivation with symlinks to all inputs.",
- "entries can be a list of attribute sets like",
- "\n[ { name = \"name\" ; path = \"/nix/store/...\"; } ]",
- "\nor an attribute set name -> path like",
- "\n{ name = \"/nix/store/...\"; other = \"/nix/store/...\"; }"
- ],
- "example": "\n# Symlinks hello and stack paths in store to current $out/hello-test and\n# $out/foobar.\nlinkFarm \"myexample\" [ { name = \"hello-test\"; path = pkgs.hello; } { name = \"foobar\"; path = pkgs.stack; } ]\nThis creates a derivation with a directory structure like the following:\n/nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample\n|-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1\n`-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10\nSee the note on symlinkJoin for the difference between linkFarm and symlinkJoin.\n"
- },
- {
- "id": "trivial-builders.linkFarmFromDrvs",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "linkFarmFromDrvs",
- "fn_type": null,
- "description": [
- "Easily create a linkFarm from a set of derivations.",
- "This calls linkFarm with a list of entries created from the list of input\nderivations. It turns each input derivation into an attribute set\nlike { name = drv.name ; path = drv }, and passes this to linkFarm."
- ],
- "example": "\n# Symlinks the hello, gcc, and ghc derivations in $out\nlinkFarmFromDrvs \"myexample\" [ pkgs.hello pkgs.gcc pkgs.ghc ]\nThis creates a derivation with a directory structure like the following:\n/nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample\n|-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0\n|-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5\n`-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10\n"
- },
- {
- "id": "trivial-builders.makeSetupHook",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "makeSetupHook",
- "fn_type": null,
- "description": [
- "Make a package that just contains a setup hook with the given contents.\nThis setup hook will be invoked by any package that includes this package\nas a buildInput. Optionally takes a list of substitutions that should be\napplied to the resulting script."
- ],
- "example": "\n# setup hook that depends on the hello package and runs ./myscript.sh\nmyhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh;\n# writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the\n# bash interpreter.\nmyhellohookSub = makeSetupHook {\ndeps = [ hello ];\nsubstitutions = { bash = \"${pkgs.bash}/bin/bash\"; };\nmeta.platforms = lib.platforms.linux;\n} ./myscript.sh;\n# setup hook with a package test\nmyhellohookTested = makeSetupHook {\ndeps = [ hello ];\nsubstitutions = { bash = \"${pkgs.bash}/bin/bash\"; };\nmeta.platforms = lib.platforms.linux;\npassthru.tests.greeting = callPackage ./test { };\n} ./myscript.sh;\n"
- },
- {
- "id": "trivial-builders.writeDirectReferencesToFile",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeDirectReferencesToFile",
- "fn_type": null,
- "description": [
- "Write the set of references to a file, that is, their immediate dependencies.",
- "This produces the equivalent of `nix-store -q --references`."
- ],
- "example": null
- },
- {
- "id": "trivial-builders.writeStringReferencesToFile",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "writeStringReferencesToFile",
- "fn_type": null,
- "description": [
- "Extract a string's references to derivations and paths (its\ncontext) and write them to a text file, removing the input string\nitself from the dependency graph. This is useful when you want to\nmake a derivation depend on the string's references, but not its\ncontents (to avoid unnecessary rebuilds, for example).",
- "Note that this only works as intended on Nix >= 2.3."
- ],
- "example": null
- },
- {
- "id": "trivial-builders.requireFile",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "requireFile",
- "fn_type": null,
- "description": [
- "Print an error message if the file with the specified name and\nhash doesn't exist in the Nix store. This function should only\nbe used by non-redistributable software with an unfree license\nthat we need to require the user to download manually. It produces\npackages that cannot be built automatically."
- ],
- "example": "\nrequireFile {\nname = \"my-file\";\nurl = \"http://example.com/download/\";\nsha256 = \"ffffffffffffffffffffffffffffffffffffffffffffffffffff\";\n}\n"
- },
- {
- "id": "trivial-builders.applyPatches",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "applyPatches",
- "fn_type": null,
- "description": ["Applies a list of patches to a source directory."],
- "example": "\nPatching nixpkgs\napplyPatches {\n\tsrc = pkgs.path;\n\tpatches = [\n\t(pkgs.fetchpatch {\n\turl = \"https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch\";\n\tsha256 = \"1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr\";\n\t})\n\t];\n}\n"
- },
- {
- "id": "trivial-builders.emptyFile",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "emptyFile",
- "fn_type": null,
- "description": ["An immutable file in the store with a length of 0 bytes."],
- "example": null
- },
- {
- "id": "trivial-builders.emptyDirectory",
- "category": "./pkgs/build-support/trivial-builders.nix",
- "name": "emptyDirectory",
- "fn_type": null,
- "description": ["An immutable empty directory in the store."],
- "example": null
- }
-]
diff --git a/scripts/prepare.js b/scripts/make-builtins.js
similarity index 83%
rename from scripts/prepare.js
rename to scripts/make-builtins.js
index 0811d0a..76b5520 100644
--- a/scripts/prepare.js
+++ b/scripts/make-builtins.js
@@ -15,9 +15,8 @@ const info = Object.entries(builtins).map(([name, meta]) => {
],
};
});
-fs.writeFile("./models/builtins.json", JSON.stringify(info), (err) => {
+fs.writeFile("./models/data/builtins.json", JSON.stringify(info), (err) => {
if (err) {
console.error(err);
}
- // file written successfully
});
diff --git a/styles/theme/lightThemeOptions.ts b/styles/theme/lightThemeOptions.ts
index 302a87b..cb4b85c 100644
--- a/styles/theme/lightThemeOptions.ts
+++ b/styles/theme/lightThemeOptions.ts
@@ -9,6 +9,9 @@ const lightThemeOptions: ThemeOptions = {
},
secondary: {
main: "#6ad541"
+ },
+ background: {
+ default: "#fafaff"
}
},
};