File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -20,5 +20,6 @@ Refer to the following documentation for more information.
20
20
- [ Secrets and full disk encryption] ( ./howtos/secrets.md )
21
21
- [ Use without flakes] ( ./howtos/use-without-flakes.md )
22
22
- [ Terraform] ( ./howtos/terraform.md )
23
+ - [ Nix-channels / ` NIX_PATH ` ] ( ./howtos/nix-path.md )
23
24
24
25
[ Reference] ( ./reference.md ) : Reference Guide
Original file line number Diff line number Diff line change 17
17
[ Use without flakes] ( ./use-without-flakes.md )
18
18
19
19
[ Terraform] ( ./terraform.md )
20
+
21
+ [ Nix-channels / ` NIX_PATH ` ] ( ./nix-path.md )
Original file line number Diff line number Diff line change
1
+ # Nix-channels / ` NIX_PATH `
2
+
3
+ nixos-anywhere does not install channels onto the new system by default to save
4
+ time and disk space. This for example results in errors like:
5
+
6
+ ```
7
+ (stack trace truncated; use '--show-trace' to show the full trace)
8
+
9
+ error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
10
+
11
+ at «none»:0: (source not available)
12
+ ```
13
+
14
+ when using tools like nix-shell/nix-env that rely on ` NIX_PATH ` beeing set.
15
+
16
+ # Solution 1: Set the ` NIX_PATH ` via nixos configuration (recommended)
17
+
18
+ Instead of stateful channels, one can also populate the ` NIX_PATH ` using nixos
19
+ configuration instead:
20
+
21
+ ``` nix
22
+ {
23
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
24
+ # ... other inputs
25
+
26
+ outputs = { nixpkgs, ... }:
27
+ {
28
+ nixosConfigurations.yoursystem = nixpkgs.lib.nixosSystem {
29
+ system = "x86_64-linux"; # adapt to your actual system
30
+ modules = [
31
+ # This line will populate NIX_PATH
32
+ { nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; }
33
+ # ... other modules and your configuration.nix
34
+ ];
35
+ };
36
+ };
37
+ }
38
+ ```
39
+
40
+ Advantage: This solution will be automatically kept up-to-date everytime the
41
+ flake is updated.
42
+
43
+ In your shell you will see something in your ` $NIX_PATH ` :
44
+
45
+ ``` shellSession
46
+ $ echo $NIX_PATH
47
+ /root/.nix-defexpr/channels:nixpkgs=/nix/store/8b61j28rpy11dg8hanbs2x710d8w3v0d-source
48
+ ```
49
+
50
+ # Solution 2: Manually add the channel
51
+
52
+ On the installed machine, run:
53
+
54
+ ``` shellSession
55
+ $ nix-channel --add https://nixos.org/channels/nixos-unstable nixos
56
+ $ nix-channel --update
57
+ ```
You can’t perform that action at this time.
0 commit comments