Skip to content

command-not-found: enable and default to channel release's dbPath - #489532

Merged
yayayayaka merged 1 commit into
NixOS:masterfrom
leana8959:enable-command-not-found
Apr 20, 2026
Merged

yayayayaka merged 1 commit into
NixOS:masterfrom
leana8959:enable-command-not-found

Conversation

@leana8959

@leana8959 leana8959 commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

NixOS module "command-not-found" was disabled in #416425 because it didn't integrate out-of-the-box with flakes. This PR resolves this issue by pointing dbPath to the programs.sqlite in the nixpkgs sources.

Concretely:

  • If you use flakes/npins/niv with channel releases: command-not-found will now work out of the box.
  • If you use flakes/npins/niv with non channel releases (e.g. github releases): command-not-found will be disabled by default.
  • If you use channels: command-not-found will work as previously, but you need to nixos-rebuild after updating the channel to get the script to point to the new programs.sqlite from the new nixpkgs.

Implementation details

programs.command-not-found.dbPath now points to the database in the nixpkgs source (likely in the store). Only if this database exists, programs.command-not-found.enable will default to true. This also guarantees that the script uses the programs.sqlite database of the very same nixpkgs used to evaluate the system, providing more coherent results out-of-the-box.

I tested this by copying a programs.sqlite to the root of nixpkgs, similar to a release expression. The fish handler for unknown command builds and works correctly.

If this patch is accepted, we would need to revert #438654 which disables command-not-found for a perl-less build.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@leana8959
leana8959 force-pushed the enable-command-not-found branch 2 times, most recently from ec2541b to 203a8fb Compare February 11, 2026 21:00
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: documentation This PR adds or changes documentation labels Feb 11, 2026
@leana8959
leana8959 force-pushed the enable-command-not-found branch 2 times, most recently from f881bb6 to b1e2630 Compare February 11, 2026 21:27
@leana8959
leana8959 marked this pull request as ready for review February 11, 2026 21:37
@nixpkgs-ci nixpkgs-ci Bot added the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Feb 11, 2026
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/use-channels-as-flake-inputs/75261/4

nadevko added a commit to nadevko/dotfiles that referenced this pull request Feb 14, 2026
nadevko added a commit to nadevko/dotfiles that referenced this pull request Feb 14, 2026
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/6436

config = lib.mkMerge [
{
programs.command-not-found = {
enable = lib.mkDefault (builtins.pathExists cfg.dbPath);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that IFD import-from-derivation?

@leana8959 leana8959 Feb 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid yes, I just checked nix's documentation and this fits the description of what IFD is. See the reply below.

I heard that IFD is disabled to make hydra work better. Does that constraint apply to NixOS as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuperSandro2000 Actually, it's not IFD. I was confused about CppNix's documentation about what IFD is.

I asked on nixos discourse here and was told that importing a store path is not the same as importing a derivation (constructed with builtins.derivation), and is not an IFD.

Furthermore, I have tested to evaluate the module change with allow-import-from-derivation set to false. The evaluation proceeded correctly.

$ nix repl -f test.nix --option allow-import-from-derivation false
Lix 2.93.3
Type :? for help.
Loading installable ''...
Added 11 variables.
nix-repl> config.programs.command-not-found
{
  dbPath = /home/leana/wt/NixOS/nixpkgs/enable-command-not-found/programs.sqlite;
  enable = true;
}

nix-repl>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be IFD if nixpkgs was imported via FOD, instead of builtin fetchers. But in that case, already evaluating this module would be IFD, so it doesn't make a difference AFAIU.

@nixpkgs-ci nixpkgs-ci Bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Feb 20, 2026
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/6551

@DavHau DavHau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed the changes, but didn't test it.

config = lib.mkMerge [
{
programs.command-not-found = {
enable = lib.mkDefault (builtins.pathExists cfg.dbPath);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be IFD if nixpkgs was imported via FOD, instead of builtin fetchers. But in that case, already evaluating this module would be IFD, so it doesn't make a difference AFAIU.

Comment thread doc/release-notes/rl-2605.section.md Resolved
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 23, 2026
@leana8959
leana8959 force-pushed the enable-command-not-found branch from c52a716 to 9f8ffcc Compare March 23, 2026 08:23
@leana8959
leana8959 force-pushed the enable-command-not-found branch from 21c44fd to 93e8c9e Compare March 23, 2026 08:30
@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 23, 2026
@leana8959

Copy link
Copy Markdown
Contributor Author

@DavHau I made the requested changes, could this be merged before the upcoming 26.05 release? Thanks :)

@philiptaron

Copy link
Copy Markdown
Contributor

@NixOS/nixos-release-managers I think this would be great to get back into NixOS for 26.05. What do you think?

@yayayayaka

Copy link
Copy Markdown
Member

From a release manager's perspective, there is nothing holding us back from introducing this again for 26.05, as we are not in the feature freeze yet.

@leana8959

Copy link
Copy Markdown
Contributor Author

@yayayayaka sorry for the ping, but it's been a while and the deadline to restrict all breaking changes is near. Are there any plans to merge this?

Thank you!

@yayayayaka yayayayaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff is looking fine by me. I think we can get this in.

@yayayayaka
yayayayaka added this pull request to the merge queue Apr 20, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Apr 20, 2026
Merged via the queue into NixOS:master with commit 83604aa Apr 20, 2026
27 of 29 checks passed
@gravndal

Copy link
Copy Markdown
Contributor

This causes eval failure:

       error: The option `programs.command-not-found.enable' has conflicting definition values:
       - In `/nix/store/bxi67sbs0rkjzzv3xpj3p76iw5nfnl69-source/nixos/modules/programs/command-not-found/command-not-found.nix': false
       - In `/nix/store/bxi67sbs0rkjzzv3xpj3p76iw5nfnl69-source/nixos/modules/programs/command-not-found/command-not-found.nix': true
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

Fix in: #512102

nadevko added a commit to nadevko/dotfiles that referenced this pull request Jun 23, 2026
nadevko added a commit to nadevko/dotfiles that referenced this pull request Jun 23, 2026
nadevko added a commit to nadevko/dotfiles that referenced this pull request Jun 23, 2026
nadevko added a commit to nadevko/dotfiles that referenced this pull request Jun 23, 2026
n0099 added a commit to n0099/nixos that referenced this pull request Sep 17, 2026
…ttps://discourse.nixos.org/t/psa-use-nixos-org-tarballs-for-your-flake-inputs/79950, this also enables `programs.command-not-found`: NixOS/nixpkgs#489532

* rename the GitHub username in flake url `github:vic/*` to `denful`: denful/import-tree#29
@ inputs.nix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants