Repository navigation
command-not-found: disable by default, simplify, document - #416425
Conversation
There was a problem hiding this comment.
13 year old code that doesn't do anything - today we install and run the command immediately if NIX_AUTO_RUN is set.
This tool is broken for users that use flakes and not nix-channels, and fails silently so few would be aware.
71b6c37 to
a2d5ceb
Compare
We must check for the database every time we use the script so lets add it to the script itself.
- Now we check for database existence in the script. - Nix ensures the script exists. - The 126 error code check and retry is leftover from an old version.
Fish completely separate of nixos will look for command-not-found provided by nixos, this was surprising so lets make it explicit.
a2d5ceb to
0309303
Compare
| enable = lib.mkOption { | ||
| type = lib.types.bool; | ||
| default = true; | ||
| default = false; |
There was a problem hiding this comment.
Alternatives to disabling for all cases:
- Detect use of flakes and disable if flakes are used.
- Only disable by default for
systemState >= 25.11.
There was a problem hiding this comment.
There is config.nixpkgs.source != null which could be used as a default.
Though, there is no guarantee that this will catch all systems using a flake. nixpkgs.flake.source is only set by default if nixpkgs.lib.nixosSystem is used to construct the nixosConfiguration. But this should be the case for most flakes users.
Still worthwhile considering I guess.
There was a problem hiding this comment.
Only disable by default for systemState >= 25.11
I think this is not needed. It is not breaking anything super important.
There was a problem hiding this comment.
Though, there is no guarantee that this will catch all systems using a flake.
IMO the consistency of just disabling is better, otherwise there is a more complicated bug for those flake systems where this falls through.
| enable = lib.mkOption { | ||
| type = lib.types.bool; | ||
| default = true; | ||
| default = false; |
There was a problem hiding this comment.
There is config.nixpkgs.source != null which could be used as a default.
Though, there is no guarantee that this will catch all systems using a flake. nixpkgs.flake.source is only set by default if nixpkgs.lib.nixosSystem is used to construct the nixosConfiguration. But this should be the case for most flakes users.
Still worthwhile considering I guess.
| if (! -e $dbPath) { | ||
| print STDERR "$program: command not found\n"; | ||
| print STDERR "\n"; | ||
| print STDERR "command-not-found: Missing package database\n"; |
There was a problem hiding this comment.
For a user that doesn't know about the package-not-found mechanism, this error lacks context.
| print STDERR "command-not-found: Missing package database\n"; | |
| print STDERR "command-not-found: A package providing $program can possibly be installed, but a package database is missing to tell for sure.\n"; |
... or the like would probably be more clear
There was a problem hiding this comment.
Good point, I've added more context in.
|
I rebuilt my system with this change and verified that it behaves as expected with all 3 shells. |
| - `base16-builder` node package has been removed due to lack of upstream maintenance. | ||
| - `gentium` package now provides `Gentium-*.ttf` files, and not `GentiumPlus-*.ttf` files like before. The font identifiers `Gentium Plus*` are available in the `gentium-plus` package, and if you want to use the more recently updated package `gentium` [by sil](https://software.sil.org/gentium/), you should update your configuration files to use the `Gentium` font identifier. | ||
| - `space-orbit` package has been removed due to lack of upstream maintenance. Debian upstream stopped tracking it in 2011. | ||
| - `command-not-found` package is now disabled by default; it works only for nix-channels based systems, and requires setup for it to work. |
There was a problem hiding this comment.
This should have go into the NixOS release notes nixos/doc/manual/release-notes, not the nixpkgs ones. Can you make a follow up change?
There was a problem hiding this comment.
Ah thanks for letting me know, I've moved it to the correct place in #432023
Given that we include programs.sqlite by default we may as well revert this [upstream change][]. Users can still disable it if they want to. [upstream change]: NixOS/nixpkgs#416425
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
(From my comment here.)
Hi all, I'm new to nix, this is my first PR, please let me know if it is too controversial a change, or if I'm missing anything.
This PR simplifies command-not-found, adds documentation and disables it by default as it is currently failing silently and depends on nix-channels that won't be in use for many users, and requires undocumented management and initialisation for other users.
Context:
command-not-foundis most important for new users (so they can find packages,) but for new users (using a flakes setup) it will be enabled and broken, at best failing silently and they won't know about its existence, at worst creating annoying and confusing error messages.There are some rewrites and alternate approaches, the most recommended one is
programs.nix-indexwhich provides its own command-not-found (but is slow to generate the index, and requires running a command to explicitly generate that index.)This is a 5-10 year old issue, is broken for new users using flakes, users using custom setups, and is broken for users using nix-channels without having run
sudo nix-channels --update. It will also produce very old results for users that have switched to a flakes-based system, and will suddenly break for other users who have changed their channels.The ultimate issue is command-not-found does not provide or manage its package database.
Problems:
nixos, won't check other channels.See:
Changes:
programs.command-not-foundby default. There are a number of other alternatives includingnix-index, for auto-run you can usecomma.Related PRs:
Attempts to fix for Fish shells by adding a wrapper for fish, this PR supercedes that one by removing the need for the wrapper.
Manual testing
Missing database
With database
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.