Skip to content

Commit c229332

Browse files
Merge staging-next into staging
2 parents d8e0934 + 0f79519 commit c229332

158 files changed

Lines changed: 3869 additions & 1805 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/build-helpers/dev-shell-tools.chapter.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Converts Nix values to strings in the way the [`derivation` built-in function](h
2020

2121
```nix
2222
devShellTools.valueToString (builtins.toFile "foo" "bar")
23-
=> "/nix/store/...-foo"
23+
# => "/nix/store/...-foo"
2424
```
2525

2626
```nix
2727
devShellTools.valueToString false
28-
=> ""
28+
# => ""
2929
```
3030

3131
:::
@@ -42,16 +42,22 @@ This function does not support `__structuredAttrs`, but does support `passAsFile
4242
devShellTools.unstructuredDerivationInputEnv {
4343
drvAttrs = {
4444
name = "foo";
45-
buildInputs = [ hello figlet ];
45+
buildInputs = [
46+
hello
47+
figlet
48+
];
4649
builder = bash;
47-
args = [ "-c" "${./builder.sh}" ];
50+
args = [
51+
"-c"
52+
"${./builder.sh}"
53+
];
4854
};
4955
}
50-
=> {
51-
name = "foo";
52-
buildInputs = "/nix/store/...-hello /nix/store/...-figlet";
53-
builder = "/nix/store/...-bash";
54-
}
56+
# => {
57+
# name = "foo";
58+
# buildInputs = "/nix/store/...-hello /nix/store/...-figlet";
59+
# builder = "/nix/store/...-bash";
60+
#}
5561
```
5662

5763
Note that `args` is not included, because Nix does not added it to the builder process environment.
@@ -69,7 +75,10 @@ Takes the relevant parts of a derivation and returns a set of environment variab
6975
let
7076
pkg = hello;
7177
in
72-
devShellTools.derivationOutputEnv { outputList = pkg.outputs; outputMap = pkg; }
78+
devShellTools.derivationOutputEnv {
79+
outputList = pkg.outputs;
80+
outputMap = pkg;
81+
}
7382
```
7483

7584
:::

doc/build-helpers/fetchers.chapter.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,11 @@ It might be useful to manipulate the content downloaded by `fetchurl` directly i
491491
In this example, we'll adapt [](#ex-fetchers-fetchurl-nixpkgs-version) to append the result of running the `hello` package to the contents we download, purely to illustrate how to manipulate the content.
492492

493493
```nix
494-
{ fetchurl, hello, lib }:
494+
{
495+
fetchurl,
496+
hello,
497+
lib,
498+
}:
495499
fetchurl {
496500
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version";
497501
@@ -714,9 +718,10 @@ A wrapper around `fetchpatch`, which takes:
714718
Here is an example of `fetchDebianPatch` in action:
715719

716720
```nix
717-
{ lib
718-
, fetchDebianPatch
719-
, buildPythonPackage
721+
{
722+
lib,
723+
fetchDebianPatch,
724+
buildPythonPackage,
720725
}:
721726
722727
buildPythonPackage rec {
@@ -914,7 +919,9 @@ It produces packages that cannot be built automatically.
914919
{ fetchtorrent }:
915920
916921
fetchtorrent {
917-
config = { peer-limit-global = 100; };
922+
config = {
923+
peer-limit-global = 100;
924+
};
918925
url = "magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c";
919926
hash = "";
920927
}

doc/build-helpers/images/appimagetools.section.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ let
6666
url = "https://github.com/irccloud/irccloud-desktop/releases/download/v${version}/IRCCloud-${version}-linux-x86_64.AppImage";
6767
hash = "sha256-/hMPvYdnVB1XjKgU2v47HnVvW4+uC3rhRjbucqin4iI=";
6868
};
69-
in appimageTools.wrapType2 {
69+
in
70+
appimageTools.wrapType2 {
7071
inherit pname version src;
7172
extraPkgs = pkgs: [ pkgs.at-spi2-core ];
7273
}
@@ -106,7 +107,8 @@ let
106107
appimageContents = appimageTools.extract {
107108
inherit pname version src;
108109
};
109-
in appimageTools.wrapType2 {
110+
in
111+
appimageTools.wrapType2 {
110112
inherit pname version src;
111113
112114
extraPkgs = pkgs: [ pkgs.at-spi2-core ];
@@ -150,7 +152,8 @@ let
150152
substituteInPlace $out/irccloud.desktop --replace-fail 'Exec=AppRun' 'Exec=${pname}'
151153
'';
152154
};
153-
in appimageTools.wrapType2 {
155+
in
156+
appimageTools.wrapType2 {
154157
inherit pname version src;
155158
156159
extraPkgs = pkgs: [ pkgs.at-spi2-core ];

doc/build-helpers/images/binarycache.section.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The following derivation will construct a flat-file binary cache containing the
3535
```nix
3636
{ mkBinaryCache, hello }:
3737
mkBinaryCache {
38-
rootPaths = [hello];
38+
rootPaths = [ hello ];
3939
}
4040
```
4141

doc/build-helpers/images/dockertools.section.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ The following package builds a Docker image that runs the `redis-server` executa
235235
The Docker image will have name `redis` and tag `latest`.
236236

237237
```nix
238-
{ dockerTools, buildEnv, redis }:
238+
{
239+
dockerTools,
240+
buildEnv,
241+
redis,
242+
}:
239243
dockerTools.buildImage {
240244
name = "redis";
241245
tag = "latest";
@@ -253,7 +257,9 @@ dockerTools.buildImage {
253257
config = {
254258
Cmd = [ "/bin/redis-server" ];
255259
WorkingDir = "/data";
256-
Volumes = { "/data" = { }; };
260+
Volumes = {
261+
"/data" = { };
262+
};
257263
};
258264
}
259265
```
@@ -286,7 +292,11 @@ It uses `runAsRoot` to create a directory and a file inside the image.
286292
This works the same as [](#ex-dockerTools-buildImage-extraCommands), but uses `runAsRoot` instead of `extraCommands`.
287293
288294
```nix
289-
{ dockerTools, buildEnv, hello }:
295+
{
296+
dockerTools,
297+
buildEnv,
298+
hello,
299+
}:
290300
dockerTools.buildImage {
291301
name = "hello";
292302
tag = "latest";
@@ -320,7 +330,11 @@ This works the same as [](#ex-dockerTools-buildImage-runAsRoot), but uses `extra
320330
Note that with `extraCommands`, we can't directly reference `/` and must create files and directories as if we were already on `/`.
321331
322332
```nix
323-
{ dockerTools, buildEnv, hello }:
333+
{
334+
dockerTools,
335+
buildEnv,
336+
hello,
337+
}:
324338
dockerTools.buildImage {
325339
name = "hello";
326340
tag = "latest";
@@ -350,7 +364,11 @@ dockerTools.buildImage {
350364
Note that using a value of `"now"` in the `created` attribute will break reproducibility.
351365
352366
```nix
353-
{ dockerTools, buildEnv, hello }:
367+
{
368+
dockerTools,
369+
buildEnv,
370+
hello,
371+
}:
354372
dockerTools.buildImage {
355373
name = "hello";
356374
tag = "latest";
@@ -766,7 +784,11 @@ The closure of `config` is automatically included in the generated image.
766784
The following package shows a more compact way to create the same output generated in [](#ex-dockerTools-streamLayeredImage-hello).
767785
768786
```nix
769-
{ dockerTools, hello, lib }:
787+
{
788+
dockerTools,
789+
hello,
790+
lib,
791+
}:
770792
dockerTools.streamLayeredImage {
771793
name = "hello";
772794
tag = "latest";
@@ -1547,11 +1569,15 @@ The Docker image generated will have a name like `hello-<version>-env` and tag `
15471569
This example uses [](#ex-dockerTools-streamNixShellImage-hello) as a starting point.
15481570
15491571
```nix
1550-
{ dockerTools, cowsay, hello }:
1572+
{
1573+
dockerTools,
1574+
cowsay,
1575+
hello,
1576+
}:
15511577
dockerTools.streamNixShellImage {
15521578
tag = "latest";
15531579
drv = hello.overrideAttrs (old: {
1554-
nativeBuildInputs = old.nativeBuildInputs or [] ++ [
1580+
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
15551581
cowsay
15561582
];
15571583
});

doc/build-helpers/images/makediskimage.section.md

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ A `deterministic` flag is available for best efforts determinism.
5252
To produce a Nix-store only image:
5353
```nix
5454
let
55-
pkgs = import <nixpkgs> {};
55+
pkgs = import <nixpkgs> { };
5656
lib = pkgs.lib;
5757
make-disk-image = import <nixpkgs/nixos/lib/make-disk-image.nix>;
5858
in
59-
make-disk-image {
60-
inherit pkgs lib;
61-
config = {};
62-
additionalPaths = [ ];
63-
format = "qcow2";
64-
onlyNixStore = true;
65-
partitionTableType = "none";
66-
installBootLoader = false;
67-
touchEFIVars = false;
68-
diskSize = "auto";
69-
additionalSpace = "0M"; # Defaults to 512M.
70-
copyChannel = false;
71-
}
59+
make-disk-image {
60+
inherit pkgs lib;
61+
config = { };
62+
additionalPaths = [ ];
63+
format = "qcow2";
64+
onlyNixStore = true;
65+
partitionTableType = "none";
66+
installBootLoader = false;
67+
touchEFIVars = false;
68+
diskSize = "auto";
69+
additionalSpace = "0M"; # Defaults to 512M.
70+
copyChannel = false;
71+
}
7272
```
7373

7474
Some arguments can be left out, they are shown explicitly for the sake of the example.
@@ -78,29 +78,36 @@ Building this derivation will provide a QCOW2 disk image containing only the Nix
7878
To produce a NixOS installation image disk with UEFI and bootloader installed:
7979
```nix
8080
let
81-
pkgs = import <nixpkgs> {};
81+
pkgs = import <nixpkgs> { };
8282
lib = pkgs.lib;
8383
make-disk-image = import <nixpkgs/nixos/lib/make-disk-image.nix>;
8484
evalConfig = import <nixpkgs/nixos/lib/eval-config.nix>;
8585
in
86-
make-disk-image {
87-
inherit pkgs lib;
88-
inherit (evalConfig {
86+
make-disk-image {
87+
inherit pkgs lib;
88+
inherit
89+
(evalConfig {
8990
modules = [
9091
{
91-
fileSystems."/" = { device = "/dev/vda"; fsType = "ext4"; autoFormat = true; };
92+
fileSystems."/" = {
93+
device = "/dev/vda";
94+
fsType = "ext4";
95+
autoFormat = true;
96+
};
9297
boot.grub.device = "/dev/vda";
9398
}
9499
];
95-
}) config;
96-
format = "qcow2";
97-
onlyNixStore = false;
98-
partitionTableType = "legacy+gpt";
99-
installBootLoader = true;
100-
touchEFIVars = true;
101-
diskSize = "auto";
102-
additionalSpace = "0M"; # Defaults to 512M.
103-
copyChannel = false;
104-
memSize = 2048; # Qemu VM memory size in megabytes. Defaults to 1024M.
105-
}
100+
})
101+
config
102+
;
103+
format = "qcow2";
104+
onlyNixStore = false;
105+
partitionTableType = "legacy+gpt";
106+
installBootLoader = true;
107+
touchEFIVars = true;
108+
diskSize = "auto";
109+
additionalSpace = "0M"; # Defaults to 512M.
110+
copyChannel = false;
111+
memSize = 2048; # Qemu VM memory size in megabytes. Defaults to 1024M.
112+
}
106113
```

doc/build-helpers/images/ocitools.section.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ Note that no user namespace is created, which means that you won't be able to ru
7676
This example uses `ociTools.buildContainer` to create a simple container that runs `bash`.
7777

7878
```nix
79-
{ ociTools, lib, bash }:
79+
{
80+
ociTools,
81+
lib,
82+
bash,
83+
}:
8084
ociTools.buildContainer {
8185
args = [
8286
(lib.getExe bash)

doc/build-helpers/images/portableservice.section.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ See [](#ex-portableService-hello) to understand how to use the output of `portab
9191
The following example builds a Portable Service image with the `hello` package, along with a service unit that runs it.
9292

9393
```nix
94-
{ lib, writeText, portableService, hello }:
94+
{
95+
lib,
96+
writeText,
97+
portableService,
98+
hello,
99+
}:
95100
let
96101
hello-service = writeText "hello.service" ''
97102
[Unit]
@@ -151,7 +156,13 @@ To make things available globally, you must specify the `symlinks` attribute whe
151156
The following package builds on the package from [](#ex-portableService-hello) to make `/etc/ssl` available globally (this is only for illustrative purposes, because `hello` doesn't use `/etc/ssl`).
152157

153158
```nix
154-
{ lib, writeText, portableService, hello, cacert }:
159+
{
160+
lib,
161+
writeText,
162+
portableService,
163+
hello,
164+
cacert,
165+
}:
155166
let
156167
hello-service = writeText "hello.service" ''
157168
[Unit]
@@ -167,7 +178,10 @@ portableService {
167178
inherit (hello) version;
168179
units = [ hello-service ];
169180
symlinks = [
170-
{ object = "${cacert}/etc/ssl"; symlink = "/etc/ssl"; }
181+
{
182+
object = "${cacert}/etc/ssl";
183+
symlink = "/etc/ssl";
184+
}
171185
];
172186
}
173187
```

doc/build-helpers/special/checkpoint-build.section.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ To change a normal derivation to a checkpoint based build, these steps must be t
2626

2727
## Example {#sec-checkpoint-build-example}
2828
```nix
29-
{ pkgs ? import <nixpkgs> {} }:
29+
{
30+
pkgs ? import <nixpkgs> { },
31+
}:
3032
let
3133
inherit (pkgs.checkpointBuildTools)
3234
prepareCheckpointBuild
@@ -39,5 +41,6 @@ let
3941
sed -i 's/Hello, world!/Hello, Nix!/g' src/hello.c
4042
'';
4143
});
42-
in mkCheckpointBuild changedHello helloCheckpoint
44+
in
45+
mkCheckpointBuild changedHello helloCheckpoint
4346
```

0 commit comments

Comments
 (0)