I have a thing I have been wondering about for a bit now, and so far I couldn’t find anything about it online. Whenever I use any of nix run, nix shell or nix profile install, oftentimes it will download all the package definitions from the nixpkgs repo, which sometimes takes a bit to finish. Now when not updating my flake/flake.lock I don’t think this should be necessary.
So is there maybe a way to cache the downloaded data for subsequent use of these commands? When just wanting to quickly try out a package or use it without installation, this should speed up downloading/starting.
This only happens if you use an unpinned nixpkgs input from the flake registry. By default NixOS changes this to your system nixpkgs, if you’re on another distro you may have to set that manually.
(and my nixpkgs input is the unstable branch)
because I thought that should synchronize the nixpkgs used in the CLI with the flake.lock in my configuration. But it looks like that made it actually not be pinned anymore?
When having this option set, in the output of nix registry list, nixpkgs points to a store path ending with a ?lastModified=...<some more parameters>. When removing the option, it just points to a nix store path without any parameters.
Would the latter mean that it is pinned then? And would it mean it is still on the same revision as the nixpkgs used in my flake?
has the same effect. However, like with the regular nixpkgs, this makes nixpkgs-unfree point to a store path with parameters at the end when looking at the registry. Whenever I have used this to run/test/build packages using the nix command, it also often redownloaded the package definitions. So this means it also is not pinned to the flake.lock in my config?
I forget the details of exactly how registry config works (very much a set-it-and-forget-it… and detsys are correct that the registry probably shouldn’t exist in the first place).
I think I have figured out the options to set in order to achieve what I have been asking. As mentioned by @TLATER I have set:
nixpkgs.flake.setFlakeRegistry = true;
which makes the nixpkgs flake in the registry be pinned.
Then I also looked at the of this option and set this in order to pin my extra nixpkgs-unfree:
nix.registry.nixpkgs-unfree.to = {
type = "path";
path = inputs.nixpkgs-unfree;
};
(of course nixpkgs-unfree is added as an input in my flake.nix)
This is a different setup now compared to the result of my old question, so I will update that accordingly.