Put nixpkgs in NIX_PATH and system registry for flake configs #1067
+107
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of NixOS/nixpkgs@e456032, which ensures that
NIX_PATH
includesnixpkgs=flake:nixpkgs
when the system was built from a flake.Here is the rationale for having
NIX_PATH
correctly set in a flake context, especially since Nix 2.24: NixOS/nixpkgs#273170 (comment)💻 Demonstration from a REPL session, using my own system flake importing this branch
Before
switch
, despite havingextra-nix-path = nixpkgs=flake:nixpkgs
innix.conf
:Open the REPL and load the flake's output to execute
nix-darwin.lib.darwinSystem
:> darwinCfg = (builtins.getFlake (builtins.toString ./.)).darwinConfigurations.myhost
Verify that
nix.registry
was populated:With
nix.registry.nixpkgs
equal to nix-darwin'snixpkgs.source
(default)With
nix.registry.nixpkgs
overriden by the userVerify that
nix.nixPath
was populated:With
nix.channel.enable = true
(default)With
nix.channel.enable = false
After a
switch
, the system can perform<nixpkgs>
lookups successfully: