about summary refs log tree commit diff
path: root/nixos/doc/manual
diff options
context:
space:
mode:
authorJade Lovelace <software@lfcode.ca>2024-01-03 17:41:57 +0100
committerJade Lovelace <software@lfcode.ca>2024-02-03 20:44:38 -0800
commite456032addae76701eb17e6c03fc515fd78ad74f (patch)
tree42bb5f4f2303202044989af20266b8905ef6caf7 /nixos/doc/manual
parenta9da154ccb5c561141cd8c04c8305c00a1676ede (diff)
downloadnixlib-e456032addae76701eb17e6c03fc515fd78ad74f.tar
nixlib-e456032addae76701eb17e6c03fc515fd78ad74f.tar.gz
nixlib-e456032addae76701eb17e6c03fc515fd78ad74f.tar.bz2
nixlib-e456032addae76701eb17e6c03fc515fd78ad74f.tar.lz
nixlib-e456032addae76701eb17e6c03fc515fd78ad74f.tar.xz
nixlib-e456032addae76701eb17e6c03fc515fd78ad74f.tar.zst
nixlib-e456032addae76701eb17e6c03fc515fd78ad74f.zip
nixos/flake: put nixpkgs in NIX_PATH and system registry for flake configs
Currently there are a bunch of really wacky hacks required to get nixpkgs
path correctly set up under flake configs such that `nix run
nixpkgs#hello` and `nix run -f '<nixpkgs>' hello` hit the nixpkgs that
the system was built with. In particular you have to use specialArgs or
an anonymous module, and everyone has to include this hack in their
own configs.

We can do this for users automatically.

I have tested these manually with a basic config; I don't know if it is
even possible to write a nixos test for it since you can't really get a
string-with-context to yourself unless you are in a flake context.
Diffstat (limited to 'nixos/doc/manual')
-rw-r--r--nixos/doc/manual/release-notes/rl-2405.section.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md
index f423311620d9..6a6903f5ce9a 100644
--- a/nixos/doc/manual/release-notes/rl-2405.section.md
+++ b/nixos/doc/manual/release-notes/rl-2405.section.md
@@ -14,6 +14,14 @@ In addition to numerous new and upgraded packages, this release has the followin
    - This can be disabled through the `environment.stub-ld.enable` option.
    - If you use `programs.nix-ld.enable`, no changes are needed. The stub will be disabled automatically.
 
+- On flake-based NixOS configurations using `nixpkgs.lib.nixosSystem`, NixOS will automatically set `NIX_PATH` and the system-wide flake registry (`/etc/nix/registry.json`) to point `<nixpkgs>` and the unqualified flake path `nixpkgs` to the version of nixpkgs used to build the system.
+
+  This makes `nix run nixpkgs#hello` and `nix-build '<nixpkgs>' -A hello` work out of the box with no added configuration, reusing dependencies already on the system.
+
+  This may be undesirable if nix commands are not going to be run on the built system since it adds nixpkgs to the system closure. For such closure-size-constrained non-interactive systems, this setting should be disabled.
+
+  To disable this, set [nixpkgs.flake.setNixPath](#opt-nixpkgs.flake.setNixPath) and [nixpkgs.flake.setFlakeRegistry](#opt-nixpkgs.flake.setFlakeRegistry) to false.
+
 - Julia environments can now be built with arbitrary packages from the ecosystem using the `.withPackages` function. For example: `julia.withPackages ["Plots"]`.
 
 ## New Services {#sec-release-24.05-new-services}