Open Tungsten842 opened 1 year ago
Currently we're checking if NIX_PATH contains nixpkgs(users usually remove it if using flakes) and determining if we should use flakes or channels
what is the output of echo $NIX_PATH
Currently we're checking if NIX_PATH contains nixpkgs(users usually remove it if using flakes) and determining if we should use flakes or channels
what is the output of
echo $NIX_PATH
❯ echo $NIX_PATH
/home/quantmint/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
Isn't there a better way to find out if a user is using flakes? I use flakes, but NIX_PATH is set by default. Also, is it possible to use a different flake for comma (instead of nixpkgs)? https://github.com/nix-community/comma/blob/c83ff3839983b3cb8deb407ff618ca12179de588/src/main.rs#L50
I ran into this same issue. I use flakes, and my NIX_PATH
is
/Users/fmoda3/.nix-defexpr/channels:darwin-config=/Users/fmoda3/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels
which happens to contain "nixpkgs" in one of the entries, making comma think I am using channels.
To fix it, i had to add nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
to my flake, to force a nixpkgs
entry that points to my flake.
After this addition, NIX_PATH
becomes
/Users/fmoda3/.nix-defexpr/channels:darwin-config=/Users/fmoda3/.nixpkgs/darwin-configuration.nix:nixpkgs=/nix/store/v0vq1p4c17x97w2py57xanh4nlh4v4cn-source:/nix/var/nix/profiles/per-user/root/channels
I wonder if the .contains("nixpkgs")
should be .contains("nixpkgs=")
in order to differentiate when nixpkgs is explicitly specified, or just happens to be in the path of a different entry?
I wonder if the
.contains("nixpkgs")
should be.contains("nixpkgs=")
in order to differentiate when nixpkgs is explicitly specified, or just happens to be in the path of a different entry?
fixed https://github.com/nix-community/comma/commit/e27a6369909e324ef845c4ece512c2e2e09c2a68 thanks for the report
is it possible to use a different flake for comma (instead of nixpkgs)?
implemented in https://github.com/nix-community/comma/commit/17a4f3384954a43cec0f91361f153cda908fe3d3
My current NIX_PATH
is nixpkgs=flake:nixpkgs
as set by the nixpkgs.flake.setNixPath
option, but this causes comma to error on usage with error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
. Is there something I need to do on my end to fix this?
To hopefully save others finding this issue through the error mentioned above some time: if you have nix.channel.enable = false
in your NixOS configuration, NixOS puts nix-path =
(empty path) in /etc/nix/nix.conf
, which overrides NIX_PATH
. So if you then leave nixpkgs.flake.setNixPath
enabled (the new default in 24.05), that sets a NIX_PATH
in the environment that Nix doesn't actually use, which trips up comma (it assumes that if there's a nixpkgs=
in NIX_PATH
it can and should use that).
Until this is fixed in Nix and/or NixOS, you may have to mess with settings a bit to get nix-path
in the configuration file and NIX_PATH
in the environment back in sync (personally I just disabled nixpkgs.flake.setNixPath
, but enabling nix.channel.enable
or fiddling with nix.settings.nix-path
so that it matches NIX_PATH
or at least has nixpkgs=flake:nixpkgs
probably also works).
(I think comma could check for nixpkgs in nix-path
in nix show-config
/ nix config show
to work around this, but that seems like a hassle to deal with a setup that doesn't really make sense...)
I installed comma with:
$ nix profile install github:nix-community/comma
When running:, cbonsai
I get: