2021-12-09 08:22:59 -05:00
|
|
|
# Frequently Asked Questions
|
|
|
|
|
|
|
|
## Nix
|
|
|
|
|
|
|
|
### How do I add a new binary cache?
|
|
|
|
|
2023-01-18 06:15:33 -05:00
|
|
|
Using NixOS (≥ 22.05):
|
2021-12-09 08:22:59 -05:00
|
|
|
|
|
|
|
```nix
|
2022-02-07 10:43:35 -05:00
|
|
|
nix.settings = {
|
2023-02-20 03:40:55 -05:00
|
|
|
trusted-substituters = [ "https://cache.nixos.org" ];
|
|
|
|
substituters = [ "https://cache.nixos.org" ];
|
2022-02-07 10:43:35 -05:00
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
Using NixOS (≤ 21.11):
|
|
|
|
|
|
|
|
```nix
|
|
|
|
nix = {
|
2023-02-20 03:40:55 -05:00
|
|
|
trustedBinaryCaches = [ "https://cache.nixos.org" ];
|
|
|
|
binaryCaches = [ "https://cache.nixos.org" ];
|
2022-02-07 10:43:35 -05:00
|
|
|
};
|
2021-12-09 08:22:59 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Using `Nix`:
|
|
|
|
|
2022-11-08 11:37:41 -05:00
|
|
|
```shell-session
|
2023-02-20 03:40:55 -05:00
|
|
|
$ echo "trusted-binary-caches = https://cache.nixos.org" >> /etc/nix/nix.conf
|
|
|
|
$ nix-build helpers/bench.nix --option extra-binary-caches https://cache.nixos.org
|
2021-12-09 08:22:59 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
### How do I force nix to re-check whether something exists at a binary cache?
|
|
|
|
|
|
|
|
Nix caches the contents of binary caches so that it doesn't have to query them
|
|
|
|
on every command. This includes negative answers (cache doesn't have something).
|
|
|
|
The default timeout for that is 1 hour as of writing.
|
|
|
|
|
|
|
|
To wipe all cache-lookup-caches:
|
|
|
|
|
2022-11-08 11:37:41 -05:00
|
|
|
```shell-session
|
2021-12-09 08:22:59 -05:00
|
|
|
$ rm $HOME/.cache/nix/binary-cache-v*.sqlite*
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternatively, use the `narinfo-cache-negative-ttl` option to reduce the
|
|
|
|
cache timeout.
|
|
|
|
|
|
|
|
### How to operate between Nix paths and strings?
|
|
|
|
|
2023-09-04 14:21:24 -04:00
|
|
|
See <http://stackoverflow.com/a/43850372>
|
2021-12-09 08:22:59 -05:00
|
|
|
|
|
|
|
### How to build reverse dependencies of a package?
|
|
|
|
|
2022-11-08 11:37:41 -05:00
|
|
|
```shell-session
|
|
|
|
$ nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
|
|
|
|
```
|
2021-12-09 08:22:59 -05:00
|
|
|
|
|
|
|
### How can I manage dotfiles in \$HOME with Nix?
|
|
|
|
|
2023-09-04 14:21:24 -04:00
|
|
|
See <https://github.com/nix-community/home-manager>
|
2021-12-09 08:22:59 -05:00
|
|
|
|
|
|
|
### What's the recommended process for building custom packages?
|
|
|
|
|
2023-09-04 14:21:24 -04:00
|
|
|
> E.g. if I git clone nixpkgs how do I use the cloned repo to define new / updated packages?
|
2021-12-09 08:22:59 -05:00
|
|
|
|
|
|
|
## NixOS
|
|
|
|
|
|
|
|
### How to build my own ISO?
|
|
|
|
|
2023-09-04 14:21:24 -04:00
|
|
|
See <http://nixos.org/nixos/manual/index.html#sec-building-image>
|
2021-12-09 08:22:59 -05:00
|
|
|
|
|
|
|
### How do I connect to any of the machines in NixOS tests?
|
|
|
|
|
|
|
|
Apply following patch:
|
|
|
|
|
2022-11-08 11:37:41 -05:00
|
|
|
```diff
|
2021-12-09 08:22:59 -05:00
|
|
|
diff --git a/nixos/lib/test-driver/test-driver.pl b/nixos/lib/test-driver/test-driver.pl
|
|
|
|
index 8ad0d67..838fbdd 100644
|
|
|
|
--- a/nixos/lib/test-driver/test-driver.pl
|
|
|
|
+++ b/nixos/lib/test-driver/test-driver.pl
|
|
|
|
@@ -34,7 +34,7 @@ foreach my $vlan (split / /, $ENV{VLANS} || "") {
|
|
|
|
if ($pid == 0) {
|
|
|
|
dup2(fileno($pty->slave), 0);
|
|
|
|
dup2(fileno($stdoutW), 1);
|
|
|
|
- exec "vde_switch -s $socket" or _exit(1);
|
|
|
|
+ exec "vde_switch -tap tap0 -s $socket" or _exit(1);
|
|
|
|
}
|
|
|
|
close $stdoutW;
|
|
|
|
print $pty "version\n";
|
|
|
|
```
|
|
|
|
|
|
|
|
And then the vde_switch network should be accessible locally.
|
|
|
|
|
|
|
|
### How to bootstrap NixOS inside an existing Linux installation?
|
|
|
|
|
|
|
|
There are a couple of tools:
|
|
|
|
|
2023-10-02 02:55:31 -04:00
|
|
|
- <https://github.com/nix-community/nixos-anywhere>
|
2021-12-09 08:22:59 -05:00
|
|
|
- <https://github.com/jeaye/nixos-in-place>
|
|
|
|
- <https://github.com/elitak/nixos-infect>
|
|
|
|
- <https://github.com/cleverca22/nix-tests/tree/master/kexec>
|