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

This commit is contained in:
yaya
2026-04-20 05:18:43 +00:00
committed by GitHub
2 changed files with 35 additions and 25 deletions
+2
View File
@@ -109,6 +109,8 @@
- `nodePackages.browserify` has been removed, as it was unmaintained within nixpkgs.
- `command-not-found` package will be enabled by default if the source of nixpkgs contains the file `programs.sqlite`. This is the case if a nixpkgs tarball from https://channels.nixos.org is used. This usage will also make the database of `command-no-found` stateless.
- `nodePackages.sass` has been removed, as it was unmaintained within nixpkgs.
- All `@tailwindcss` packages in the `nodePackages` set have been removed, as they are libraries that should instead be locked by JS projects that utilize them.
@@ -38,8 +38,6 @@ in
Whether interactive shells should show which Nix package (if
any) provides a missing command.
Requires nix-channels to be set and downloaded (sudo nix-channel --update.)
See also nix-index and nix-index-database as an alternative for flakes-based systems.
Additionally, having the env var NIX_AUTO_RUN set will automatically run the matching package, and with NIX_AUTO_RUN_INTERACTIVE it will confirm the package before running.
@@ -47,38 +45,48 @@ in
};
dbPath = lib.mkOption {
default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite";
description = ''
Absolute path to programs.sqlite.
Absolute path to `programs.sqlite`, which contains mappings from binary names to package names.
By default this file will be provided by your channel
(nixexprs.tar.xz).
If a nixpkgs tarball from https://channels.nixos.org is used as the source of nixpkgs, this file will be provided and this option be set by default.
To use the stateful `programs.sqlite` database, set this option to
`/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite`.
If you do so, you can update it with `sudo nix-channels --update`.
'';
type = lib.types.path;
};
};
config = lib.mkIf cfg.enable {
programs.bash.interactiveShellInit = ''
command_not_found_handle() {
'${commandNotFound}/bin/command-not-found' "$@"
}
'';
config = lib.mkMerge [
{
programs.command-not-found = {
enable = lib.mkOptionDefault (builtins.pathExists cfg.dbPath);
dbPath = pkgs.path + "/programs.sqlite";
};
}
programs.zsh.interactiveShellInit = ''
command_not_found_handler() {
'${commandNotFound}/bin/command-not-found' "$@"
}
'';
(lib.mkIf cfg.enable {
programs.bash.interactiveShellInit = ''
command_not_found_handle() {
'${commandNotFound}/bin/command-not-found' "$@"
}
'';
# NOTE: Fish by itself checks for nixos command-not-found, let's instead makes it explicit.
programs.fish.interactiveShellInit = ''
function fish_command_not_found
"${commandNotFound}/bin/command-not-found" $argv
end
'';
programs.zsh.interactiveShellInit = ''
command_not_found_handler() {
'${commandNotFound}/bin/command-not-found' "$@"
}
'';
environment.systemPackages = [ commandNotFound ];
};
# NOTE: Fish by itself checks for nixos command-not-found, let's instead makes it explicit.
programs.fish.interactiveShellInit = ''
function fish_command_not_found
"${commandNotFound}/bin/command-not-found" $argv
end
'';
environment.systemPackages = [ commandNotFound ];
})
];
}