Skip to content

check isFlake in nixpkgsFlakeRef#15175

Merged
edolstra merged 1 commit intoNixOS:masterfrom
KiaraGrouwstra:flake-ref-nixpkgs
Feb 10, 2026
Merged

check isFlake in nixpkgsFlakeRef#15175
edolstra merged 1 commit intoNixOS:masterfrom
KiaraGrouwstra:flake-ref-nixpkgs

Conversation

@KiaraGrouwstra
Copy link
Contributor

@KiaraGrouwstra KiaraGrouwstra commented Feb 8, 2026

Add a check for isFlake in nixpkgsFlakeRef.

Motivation

To get bashInteractive, nix develop currently gets a flake reference to nixpkgs, either from inputs.nixpkgs or flake registry entry nixpkgs.

Currently, this is done by name for any (locked) reference. For any nixpkgs reference lacking a flake.nix, nix develop thus errors:

error (ignored): path '.../flake.nix' does not exist

Now, given a inputs.<name>.flake = false;, we may know in advance that our reference should not be a reference to a flake.

This change incorporates this knowledge, so that given inputs.nixpkgs.flake = false;, nix develop will fall back to flake registry entry nixpkgs to use as its flake for bashInteractive.

While Nixpkgs itself of course does expose a flake, this check is relevant in particular for dummy inputs (e.g. inputs using { url = "file:/dev/null"; flake = false; }), which may be overridden by --override-input or .follows, yet do not expose (flake) code themselves.

Context

  • Note that this change takes at face value the name nixpkgsFlakeReference, which reflects current use of the function, although the fetch-tree experimental feature has broadened the use of what were historically called flake references beyond use to refer to flake-enabled source trees.
  • I made an example for such use of dummy inputs at https://codeberg.org/kiara/poc-override-nix-deps.

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

To get `bashInteractive`, `nix develop` currently
[gets a flake reference to nixpkgs](https://github.com/NixOS/nix/blob/3b473c4be5e6abc58aa43271f35ff127af806c55/src/nix/develop.cc#L650-L658),
either from [`inputs.nixpkgs`](https://github.com/NixOS/nix/blob/3b473c4be5e6abc58aa43271f35ff127af806c55/src/libcmd/installable-flake.cc#L204)
or [`<nixpkgs>`](https://github.com/NixOS/nix/blob/3b473c4be5e6abc58aa43271f35ff127af806c55/src/libcmd/include/nix/cmd/installable-flake.hh#L87).

Currently, this is done by name for any (locked) reference.
For any `nixpkgs` reference lacking a `flake.nix`, `nix develop` thus errors:

```
error (ignored): path '.../flake.nix' does not exist
```

While the registry does not expose info to help check this,
flake inputs expose the `flake` boolean.
This means that given `inputs.<name>.flake = false;`,
we may know in advance that our reference should not be to a flake.

This change incorporates this, so that given `inputs.nixpkgs.flake = false;`,
`nix develop` will fall back `<nixpkgs>` to use its flake for `bashInteractive`.

While Nixpkgs itself of course does expose a flake,
this check is relevant in particular for dummy inputs
(e.g. inputs using `{ url = "file:/dev/null"; flake = false; }`),
which may be overridden by `--override-input` or `.follows`,
yet do not expose (flake) code themselves.

Signed-off-by: cinereal <cinereal@riseup.net>
@KiaraGrouwstra KiaraGrouwstra marked this pull request as ready for review February 8, 2026 13:29
@roberth roberth added new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc labels Feb 9, 2026
@roberth
Copy link
Member

roberth commented Feb 9, 2026

Getting bashInteractive seems a bit useless since

Furthermore none of this will be necessary when we implement

That said, since we don't have that yet, I would suggest to go ahead with this change, which is good.

@edolstra edolstra added this pull request to the merge queue Feb 10, 2026
Merged via the queue into NixOS:master with commit b06d0f7 Feb 10, 2026
23 checks passed
@KiaraGrouwstra KiaraGrouwstra deleted the flake-ref-nixpkgs branch February 10, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants