You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/building.md
+47-3Lines changed: 47 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,7 @@
2
2
3
3
This requires access to a system that already has Nix installed. Please refer to the [Nix installation guide](https://nixos.org/guides/install-nix.html) if that\'s not the case.
4
4
5
-
If you have a flakes-enabled Nix, you can use the following command to
6
-
build your own tarball instead of relying on a prebuilt one:
5
+
If you have a flakes-enabled Nix, you can use the following command to build your own tarball instead of relying on a prebuilt one:
7
6
8
7
```sh
9
8
sudo nix run github:nix-community/NixOS-WSL#nixosConfigurations.default.config.system.build.tarballBuilder
@@ -19,7 +18,52 @@ Without a flakes-enabled Nix, you can build a tarball using:
19
18
20
19
```sh
21
20
nix-build -A nixosConfigurations.default.config.system.build.tarballBuilder && sudo ./result/bin/nixos-wsl-tarball-builder
22
-
23
21
```
24
22
25
23
The resulting tarball can then be found under `nixos.wsl`.
24
+
25
+
## Copying files to the new installation
26
+
27
+
The tarball builder supports copying in extra files and fixing up ownership before the tarball is packed.
28
+
29
+
### `--extra-files <path>`
30
+
31
+
The `--extra-files <path>` option allows copying files into the target root after installation.
32
+
33
+
The contents of `<path>` are recursively copied and overwrite the target\'s root (`/`). The structure and permissions of `<path>` should already match how you want them on the target.
34
+
35
+
For example, if you want to copy your SSH host key, you can prepare a directory structure like this:
sudo nix run github:nix-community/NixOS-WSL#nixosConfigurations.default.config.system.build.tarballBuilder -- --extra-files $root
47
+
```
48
+
49
+
By default, everything ends up owned by root.
50
+
51
+
### `--chown <path> <uid:gid>`
52
+
53
+
The `--chown` option allows adjusting ownership of directories or files inside the tarball after they\'re copied.
54
+
55
+
For example:
56
+
57
+
```sh
58
+
sudo nix run github:nix-community/NixOS-WSL#nixosConfigurations.default.config.system.build.tarballBuilder -- \
59
+
--extra-files ./extra \
60
+
--chown /home/myuser 1000:100
61
+
```
62
+
63
+
This is equivalent to running inside the tarball root:
64
+
65
+
```sh
66
+
chown -R 1000:100 /home/myuser
67
+
```
68
+
69
+
The `--chown` option can be used multiple times to set ownership for different paths. Only use this when you can guarantee what the UID/GID will be on the target system.
0 commit comments