treewide: Fix all Nix ASTs in all markdown files
This allows for correct highlighting and maybe future automatic formatting. The AST was verified to work with nixfmt only.
This commit is contained in:
committed by
Valentin Gagarin
parent
bc77c7a973
commit
fcc95ff817
@@ -176,7 +176,7 @@ You can define a function called `packageOverrides` in your local `~/.config/nix
|
||||
```nix
|
||||
{
|
||||
packageOverrides = pkgs: rec {
|
||||
foo = pkgs.foo.override { ... };
|
||||
foo = pkgs.foo.override { /* ... */ };
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -141,7 +141,7 @@ For BLAS/LAPACK switching to work correctly, all packages must depend on `blas`
|
||||
assert (!blas.isILP64) && (!lapack.isILP64);
|
||||
|
||||
stdenv.mkDerivation {
|
||||
...
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ It is used to override the arguments passed to a function.
|
||||
Example usages:
|
||||
|
||||
```nix
|
||||
pkgs.foo.override { arg1 = val1; arg2 = val2; ... }
|
||||
pkgs.foo.override { arg1 = val1; arg2 = val2; /* ... */ }
|
||||
```
|
||||
|
||||
It's also possible to access the previous arguments.
|
||||
|
||||
```nix
|
||||
pkgs.foo.override (previous: { arg1 = previous.arg1; ... })
|
||||
pkgs.foo.override (previous: { arg1 = previous.arg1; /* ... */ })
|
||||
```
|
||||
|
||||
<!-- TODO: move below programlisting to a new section about extending and overlays and reference it -->
|
||||
@@ -27,13 +27,15 @@ pkgs.foo.override (previous: { arg1 = previous.arg1; ... })
|
||||
```nix
|
||||
import pkgs.path { overlays = [ (self: super: {
|
||||
foo = super.foo.override { barSupport = true ; };
|
||||
})]};
|
||||
})];}
|
||||
```
|
||||
|
||||
```nix
|
||||
mypkg = pkgs.callPackage ./mypkg.nix {
|
||||
mydep = pkgs.mydep.override { ... };
|
||||
}
|
||||
{
|
||||
mypkg = pkgs.callPackage ./mypkg.nix {
|
||||
mydep = pkgs.mydep.override { /* ... */ };
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
In the first example, `pkgs.foo` is the result of a function call with some default arguments, usually a derivation. Using `pkgs.foo.override` will call the same function with the given new arguments.
|
||||
@@ -45,9 +47,11 @@ The function `overrideAttrs` allows overriding the attribute set passed to a `st
|
||||
Example usages:
|
||||
|
||||
```nix
|
||||
helloBar = pkgs.hello.overrideAttrs (finalAttrs: previousAttrs: {
|
||||
pname = previousAttrs.pname + "-bar";
|
||||
});
|
||||
{
|
||||
helloBar = pkgs.hello.overrideAttrs (finalAttrs: previousAttrs: {
|
||||
pname = previousAttrs.pname + "-bar";
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
In the above example, "-bar" is appended to the pname attribute, while all other attributes will be retained from the original `hello` package.
|
||||
@@ -61,9 +65,11 @@ If only a one-argument function is written, the argument has the meaning of `pre
|
||||
Function arguments can be omitted entirely if there is no need to access `previousAttrs` or `finalAttrs`.
|
||||
|
||||
```nix
|
||||
helloWithDebug = pkgs.hello.overrideAttrs {
|
||||
separateDebugInfo = true;
|
||||
};
|
||||
{
|
||||
helloWithDebug = pkgs.hello.overrideAttrs {
|
||||
separateDebugInfo = true;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
In the above example, the `separateDebugInfo` attribute is overridden to be true, thus building debug info for `helloWithDebug`.
|
||||
@@ -87,14 +93,16 @@ The function `overrideDerivation` creates a new derivation based on an existing
|
||||
Example usage:
|
||||
|
||||
```nix
|
||||
mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
|
||||
name = "sed-4.2.2-pre";
|
||||
src = fetchurl {
|
||||
url = "ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2";
|
||||
hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY=";
|
||||
};
|
||||
patches = [];
|
||||
});
|
||||
{
|
||||
mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
|
||||
name = "sed-4.2.2-pre";
|
||||
src = fetchurl {
|
||||
url = "ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2";
|
||||
hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY=";
|
||||
};
|
||||
patches = [];
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
In the above example, the `name`, `src`, and `patches` of the derivation will be overridden, while all other attributes will be retained from the original derivation.
|
||||
@@ -112,8 +120,10 @@ The function `lib.makeOverridable` is used to make the result of a function easi
|
||||
Example usage:
|
||||
|
||||
```nix
|
||||
f = { a, b }: { result = a+b; };
|
||||
c = lib.makeOverridable f { a = 1; b = 2; };
|
||||
{
|
||||
f = { a, b }: { result = a+b; };
|
||||
c = lib.makeOverridable f { a = 1; b = 2; };
|
||||
}
|
||||
```
|
||||
|
||||
The variable `c` is the value of the `f` function applied with some default arguments. Hence the value of `c.result` is `3`, in this example.
|
||||
|
||||
Reference in New Issue
Block a user