I’ve got rid of all nix channels and just use flakes for everything. However, command-not-found
now complains it can not find programs.sqlite
because that file is expected in default root channel. How do I specify that that for command-not-found
? (preferrably from home-manager option programs.command-not-found.dbPath
)
I’m not aware of a way to pull that database in with flakes.
I therefore still maintain an irregularly updated nixos
channel for the root
user.
You can either replace the current command-not-found module with the one provided by nix-index (it provides both a module for nixos and home manager, thanks K900).
The second approach I can imagine is to manually download the database from https://channels.nixos.org (code not tested)
{ pgks, ... }:
let
# To find the channel url I went in:
# https://channels.nixos.org/ > nixos-22.05 > nixexprs.tar.gz
# All the available channels you can browse https://releases.nixos.org
nixos_tarball = pkgs.fetchzip {
url = "https://releases.nixos.org/nixos/22.05/nixos-22.05.3737.3933d8bb912/nixexprs.tar.xz";
sha256 = "sha256-+xhJb0vxEAnF3hJ6BZ1cbndYKZwlqYJR/PWeJ3aVU8k=";}
;
# extract only the sqlite file
programs-sqlite = pkgs.runCommand "program.sqlite" {} ''
cp ${nixos_tarball}/programs.sqlite $out
'';
in
{
programs.command-not-found.dbPath = programs-sqlite;
}
Thank you all, especially @tobiasBora for spending the time to write the code, really appreciated.
Can you elaborate on the nix-index? I’ve seen the nix-index
option in home manager, but when I enable it I face the same complaints (missing programs.sqlite
), and I’m not sure how the first approach would work.
No problems. The readme provides a code snippet to use in your configuration.nix
here GitHub - bennofs/nix-index: Quickly locate nix packages with specific files
programs.command-not-found.enable = false;
programs.bash.interactiveShellInit = ''
source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh
'';
It also links to the home manager module here Appendix A. Configuration Options I don’t have a computer to test but I guess you want to have
programs.nix-index.enable = true;
programs.nix-index.enableBashIntegration = true;
(If you use zsh/fish adapt this code of course)
Also make sure to disable the command-not-found
option to avoid conflicts as they are vifferent implementations of the same functionality(it is disabled by default but you may have enabled it). If it fails maybe try to disable system-wide to see if it helps. If you are still out of luck please post your config
that was what I had in my home-manager
configuration as well. However, nix-index
doesn’t know where the nixpkgs
is either.
I ended up writing a custom script to call it with the right nixpkgs path:
(pkgs.writeScriptBin "nix-index-update-db" "nix-index -f ${pkgs.path}")
and run the script when I update my flake nixpkgs input.
Thank you very much for the pointer.
Oh I thought that nix-index would just pick the latest stuff from Hydra irrespective of the current channel. Good to know then!
@NobbZ @myguidingstar @tobiasBora
I spent a bit of spare time on GitHub - wamserma/flake-programs-sqlite - maybe you could have a look and test-drive it.
Seems to be a nice idea and thank you for the effort, though:
$ nixos-rebuild build --flake .#mimas
building the system configuration...
warning: Git tree '/home/nmelzer/Projects/nixos-config' is dirty
error: attribute '757b82211463dd5ba1475b6851d3731dfe14d377' missing
And that commit is from 2022-12-16T14:28:48Z (unstable)
If the system can’t sustain even that pace for updates, I wont be able to do any test-drive for you, sorry.
I just realized that you simply might miss the old commit because your started scraping at some later moment in time.
Therefore I updated my local clone to be the same as on GitHub
That lockfiles commit actually got recognized by your system and now I am building my system to start testing your flake under real life conditions.
I already found some issue with your README and hope to be able to do a PR later today.
Yes, I only kept some older revisions for testing, but proper scraping started less than 24 hours ago.
I have made my first tries and some testing and draw a first conclusion:
- Works well so far, but setup steps are currently lacking documentation (will try to PR today)
- There should be a module that handles the setup and also goes through a redirection (I hope to be able to do a PR before christmas)
- I do not really like how overriding the input is part of the contract (I have an idea, but that has to be postponed for now, I don’t have the time nor energy to even verbalise my thoughts before christmas)
I need to change something it seems, as I have posted this in the wrong thread initially and simply reposting seems to be denied by the spam filter or something…
No need to hurry, most like I won’t be available to review the module before next year.