nix-community / nix-direnv

A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
MIT License
1.59k stars 98 forks source link

Installing packages raises an "unknown setting 'upgrade-nix-store-path-url'" warning #466

Closed zimeg closed 5 months ago

zimeg commented 5 months ago

Hello! I've been diving into Nix recently and am wonderfully impressed with this package! Super excited to be using it 😄

When installing new packages from a flake the following warning appears and I'm unsure if this is caused by my Nix or home manager setup or the flake itself:

warning: unknown setting 'upgrade-nix-store-path-url'

This happens the first time I allow direnv in a directory and might happen multiple times after adding new packages.

Here's an example `flake.nix` that's causing this ```nix { description = "A basic flake with a shell"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { devShells.default = pkgs.mkShell { packages = [ pkgs.bashInteractive pkgs.hello ]; }; }); } ```

This same warning isn't shown when using nix-shell -p hello and I'm not sure if this is due to my nix-direnv setup. Any pointers would be appreciated!

zimeg commented 5 months ago

I've poked around the repo a bit looking for hints and these lines seem most interesting for this: https://github.com/nix-community/nix-direnv/blob/e9076faefc13f95b2f621c48d726dd1b68cfe562/direnvrc#L311-L319

Finding the flake_input_path from my project directory outputs a few different paths, but I don't know if these are related to the unknown store path at all:

$ nix --extra-experimental-features "nix-command flakes" flake archive --json --no-write-lock-file .
{
  "inputs": {
    "flake-utils": {
      "inputs": {
        "systems": {
          "inputs": {},
          "path": "/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source"
        }
      },
      "path": "/nix/store/qkig73szmrhgp0qhncxy5vb36lw2g3jj-source"
    },
    "nixpkgs": {
      "inputs": {},
      "path": "/nix/store/abh0p0f6fcqilmp3v24gfj00lp38wn6l-source"
    }
  },
  "path": "/nix/store/17lmjgndk0n510ld6xv4jq72y20r72bn-source"
}
zimeg commented 5 months ago

There's a related option for the nix upgrade-nix command too, but not sure if I can set this somewhere myself: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-upgrade-nix#opt-nix-store-paths-url

bbenne10 commented 5 months ago

I'm not saying nix-direnv doesn't exacerbate these problems, but I don't think we cause them for you. You'll note that we only explicitly include a minimal set of extra features when we invoke the nix binary.

nix-shell is the old style CLI and I have some doubts about whether it tickles these particular points and so your comparisons might be off. You might want to try again with nix shell nixpkgs#hello (note that these two invocations are not exactly the same - the old one is channel based and the new one will resolve the flake, which I believe will get you a newer revision of nixpkgs in the general sense).

What is the content of your various nix.conf files? This page describes where you might find them. I would venture to guess you have upgrade-nix-store-path-url set in one of those and a nix version installed that is too old to understand it, maybe? I don't know when the flag was introduced though so that might be off base (and trying to figure that out is proving difficult). You should know that this is just a warning though so nothing is "wrong" just "almost wrong". Everything should still be working - nix is just telling you it ignored something it didn't understand.

While I'm happy to continue to try and help out here, I really don't believe this to be a nix-direnv issue and so will be closing this. You might be able to find more direct and detailed help at the NixOS discourse. If we determine that we are somehow doing something that exacerbates this, we'll reopen this ticket and address with code changes.

bbenne10 commented 5 months ago

Of course, I hit "Comment" too soon. You may also want to just set -x at the top of your .envrc (before you call use flake) and see what nix invocations are complaining about this. I'm not entirely sure how this would help, but more information is better than less.

zimeg commented 5 months ago

@bbenne10 Really appreciate the response! There's so much helpful info here. I agree this does seem to be caused by something besides nix-direnv so no worries closing the issue. I'll keep exploring and will let you know if nix-direnv does seem to be causing it though.

Using the new CLI didn't seem to raise any warnings on install, which I think is good. It's also good to know about this command and that it installs flakes! There's still a lot for me to learn!

I think you're pointing down the right track with the contents of nix.conf and I'll follow this a bit more:

build-users-group = nixbld
experimental-features = nix-command flakes repl-flake
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
extra-nix-path = nixpkgs=flake:nixpkgs
upgrade-nix-store-path-url = https://install.determinate.systems/nix-upgrade/stable/universal

The version of Nix and the Nix installer I have are:

$ nix --version
nix (Nix) 2.19.2
$ /nix/nix-installer --version
nix-installer 0.16.0

And the versions listed in the upgrade-nix-store-path-url are:

{
  x86_64-linux = "/nix/store/smfmnz0ylx80wkbqbjibj7zcw4q668xp-nix-2.19.2";
  i686-linux = "/nix/store/knp0akbpj2k0rf26fmysmxdysmayihax-nix-2.19.2";
  aarch64-linux = "/nix/store/761hq0abn07nrydrf6mls61bscx2vz2i-nix-2.19.2";
  x86_64-darwin = "/nix/store/zlqvxis1dfcfgmy5fza4hllg6h03vhpb-nix-2.19.2";
  aarch64-darwin = "/nix/store/53r8ay20mygy2sifn7j2p8wjqlx2kxik-nix-2.19.2";
}

You're totally right that this is only a warning and everything does seem to be working fine, I was mostly curious if there was an obvious setting for me to switch. The set -x option is giving me a bit to read through so I'll read through that and explore the discourse some more too. Thank you!