Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of Nix flake registry instead of channel #167

Open
ambroisie opened this issue Jun 4, 2021 · 11 comments
Open

Make use of Nix flake registry instead of channel #167

ambroisie opened this issue Jun 4, 2021 · 11 comments

Comments

@ambroisie
Copy link
Contributor

I would like nix-index to make use of a pinned version of nixpkgs that I set in the Nix registry, instead of Nix channels which I do not use and do not update.

@malob
Copy link

malob commented Nov 13, 2021

In case it's helpful to you or others, my current workaround is to set nixpkgs on my NIX_PATH to point to a nixpkgs.nix file included in my Nix configs flake.

@LunNova
Copy link

LunNova commented Dec 9, 2021

On nixos it seems to be as easy as setting it to the flake input, no need to construct the URL yourself from the flake.lock or have a local path.

nix.nixPath = [ "nixpkgs=${nixpkgs}" ];

LunNova/nixos-configs@0258db8

Not sure if this works on darwin although I don't know why it wouldn't.

@malob
Copy link

malob commented Dec 14, 2021

@LunNova, great point! I had forgotten that I was doing things the way I was so that the nixpkgs in NIX_PATH would support workflows that don't support flakes.

@srid
Copy link

srid commented Apr 16, 2022

If flakes is enabled, it automatically should use nix profile install instead of nix-env -iA. And nix run nixpkgs#<pkg> ... instead of nix-shell ---run.

@dfrankland
Copy link

I can confirm that using nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; works on darwin

@anajuliabit
Copy link

anajuliabit commented Jun 15, 2023

@srid @dfrankland I have flakes enabled and set nix.nixPath = [ "nixpkgs=${nixpkgs}" ], but it is still using the channel. Any suggestions for what I could do? :)

The program 'tldr' is currently not installed. It is provided by
several packages. You can install it by typing one of the following:
  nix-env -iA nixpkgs.tldr-hs.out
  nix-env -iA nixpkgs.tldr.out
  nix-env -iA nixpkgs.tealdeer.out

Or run it once with:
  nix-shell -p tldr-hs.out --run ...
  nix-shell -p tldr.out --run ...
  nix-shell -p tealdeer.out --run ...

@figsoda
Copy link
Member

figsoda commented Jun 15, 2023

@anajuliabit I think you are experiencing #210, currently nix-index's command-not-found only suggests the flake commands if your user profile is with flakes, which I think only happens if you've run one of the nix profile commands once

@anajuliabit
Copy link

anajuliabit commented Jun 17, 2023

@figsoda, you are correct
actually, I hid the comment because I reached the same conclusion after writing it. But I will keep it visible for anyone who may find it useful. Thank you!

@hpfr
Copy link

hpfr commented Jan 14, 2024

I recently stopped using home-manager and nix-index broke. I’m also using flakes and setting NIX_PATH accordingly. I tried installing something (nix-index, in fact) with nix profile, but still get this error:

0 2024-01-14 12:05:05 $ nix-index
+ querying available packages
error: querying available packages failed
caused by: nix-env failed with error: nix-env failed with exit status: 1:
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

2 2024-01-14 12:05:12 $ printenv NIX_PATH
nixpkgs=/etc/nix/inputs/nixpkgs
0 2024-01-14 12:05:17 $ ls /etc/nix/inputs/nixpkgs/
doc  maintainers  pkgs             COPYING      flake.nix
lib  nixos        CONTRIBUTING.md  default.nix  README.md
0 2024-01-14 12:05:23 $ nix profile list
Index:              0
Flake attribute:    legacyPackages.x86_64-linux.nix-index
Original flake URL: flake:nixpkgs
Locked flake URL:   path:/nix/store/7ix7lj4h8q5jl740bkwvpi611safrq0v-source?lastModified=1702645756&narHash=sha256-qKI6OR3TYJYQB3Q8mAZ%2BDG4o/BR9ptcv9UnRV2hzljc%3D&rev=40c3c94c241286dd2243ea34d3aef8a488f9e4d0
Store paths:        /nix/store/3mashfgk5g2xnsqyl4ljwm44n768dcx7-nix-index-0.1.7

Index:              1
Flake attribute:    legacyPackages.x86_64-linux.nix-index
Original flake URL: flake:nixpkgs
Locked flake URL:   path:/nix/store/7ix7lj4h8q5jl740bkwvpi611safrq0v-source?lastModified=1702645756&narHash=sha256-qKI6OR3TYJYQB3Q8mAZ%2BDG4o/BR9ptcv9UnRV2hzljc%3D&rev=40c3c94c241286dd2243ea34d3aef8a488f9e4d0
Store paths:        /nix/store/3mashfgk5g2xnsqyl4ljwm44n768dcx7-nix-index-0.1.7

What am I missing here?

@srid
Copy link

srid commented Jan 19, 2024

@srid @dfrankland I have flakes enabled and set nix.nixPath = [ "nixpkgs=${nixpkgs}" ], but it is still using the channel.

@anajuliabit You can try the workaround mentioned in the Zulip thread linked in #191 (comment)

@boomshroom
Copy link

While nix-index detects the use of flakes if ~/.nix-profile/manifest.nix exists, it fails if nix is set with use-xdg-base-directories = true, which doesn't use ~/.nix-profile, but instead uses $XDG_STATE_HOME/nix/profile (or ~/.local/state/nix/profile if $XDG_STATE_HOME isn't set).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants