Local flake-based `nix search`, `nix run` and `nix shell`

I found a way to set the registry in my flake.nix:

{
  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  outputs = { self, nixpkgs, ... }@inputs: {
    nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
      modules = [
        ({ pkgs, ... }: {
          nix.registry.sys = {
            from = { type = "indirect"; id = "sys"; };
            flake = nixpkgs;
          };
        })
        # ...
      ];
    };
  };
}

Now I can nix search sys foo :slight_smile:

7 Likes