Open lucianthorr opened 5 months ago
Yeah I also have this issue, I found this when I was trying to update the nix version.
My nix doctor output:
[FAIL] Multiple versions of nix found in PATH:
/nix/store/4xwvps7bnachw9686ac22jhczn04i44b-nix-2.20.5/bin
/nix/store/8wj64myqgglm4pi59qs1w18ky9qqii6f-nix-2.18.2/bin
error: not an absolute path: '~/Library'
Is this expected of nix-darwin?
What probably happened is that you installed Nix itself, and then nix-darwin installed its own version of Nix. You can list your imperatively installed packages with nix-env --query
and nix profile list
. For packages that show up in nix-env --query
, you can uninstall them with nix-env --uninstall <pkg>
; for packages that show up in nix profile list
, you can uninstall them with nix profile uninstall <pkg>
What probably happened is that you installed Nix itself, and then nix-darwin installed its own version of Nix.
@Samasaur1 But According to the instructions we can use the nix-installer from the determinate systems to install nix before installing nix-darwin right? Then how come this behavior of two nix installations is expected.
We can't technically install nix-darwin without having nix so what would be a proper method of installation for flake nix-darwin
I think this is just a situation where there's no better way to do it
@Samasaur1 forgive me if I'm dumb but does this mean every single nix-darwin installation have such a problem of two nix installations?
@thuvasooriya You'll have two Nix installations at some point. As far as I can tell, the best thing to do is
I kind of hate this, but I don't see a better way to do it. You need Nix to install nix-darwin, and nix-darwin should manage the systemwide version of Nix. And it just seems like a really bad idea to have the nix-darwin installer try to uninstall standalone Nix unprompted
What kind of management does the nix-darwin do to the systemwide nix? Is there a way the darwin features could be inside the systemwide nix rather than wrapping it?
@Samasaur1 How do you do step 3 - Uninstall standalone Nix.
Also how do you upgrade nix (nix upgrade-nix does not work)
@lucianthorr When I say nix-darwin "manages" the systemwide Nix, I mean that the Nix first on your PATH should come from nix-darwin. This means it's declaratively configured, pinned to a reproducible version, and all the other benefits that you get from installing software with nix-darwin over imperatively installing software. This is all-around a good thing, it just so happens that you need Nix to install nix-darwin in the first place.
@bestlem see below
What probably happened is that you installed Nix itself, and then nix-darwin installed its own version of Nix. You can list your imperatively installed packages with
nix-env --query
andnix profile list
. For packages that show up innix-env --query
, you can uninstall them withnix-env --uninstall <pkg>
; for packages that show up innix profile list
, you can uninstall them withnix profile uninstall <pkg>
I don't have anything installed imperatively anymore, but if you post the output of both nix-env --query
and nix profile list
on your system, I can help you figure out exactly how to uninstall the second version of Nix
@bestlem oh also I forgot to answer your other question. Nix-Darwin defaults to the latest stable Nix, and you probably don't want to override this to a newer version. If you do, though, there's the nix.package
option
@Samasaur1 Thanks for the reply. I kind of get the chicken and the egg problem here but I guess the nix-installer from the declarative systems is made in such a way to not allow nix uninstallation without removing nix-darwin first which would break a hell lot of stuff afaik. Check this out
And I'm not sure how to safely uninstall that nix and figure out which one is from nix-darwin and which one is the one I installed. update: I just checked the above comments but maybe there is something wrong with my nix installation but I didn't have any output for nix-env --query
and nix profile list
I think the readme file should be updated with regards to these issues and possible headaches associated with it. I would be willing to make a pull request with updated instructions because afaik uninstalling nix-darwin installed via flakes also require different commands from the ones that've been mentioned in the readme file.
I guess an optional safe script to install nix and install nix-darwin and then uninstall the imperatively installed nix is a good choice to have since I haven't seem much devs playing with two nix versions at the same system. I'm just a beginner getting started with nix and I might be wrong. Please correct me.
@bestlem see below
What probably happened is that you installed Nix itself, and then nix-darwin installed its own version of Nix. You can list your imperatively installed packages with
nix-env --query
andnix profile list
. For packages that show up innix-env --query
, you can uninstall them withnix-env --uninstall <pkg>
; for packages that show up innix profile list
, you can uninstall them withnix profile uninstall <pkg>
I don't have anything installed imperatively anymore, but if you post the output of both
nix-env --query
andnix profile list
on your system, I can help you figure out exactly how to uninstall the second version of Nix
I am using flakes only. Sometimes doing a darwin-rebuild others just home-manager - from the same flake. If done using darwin-rebuild both those commands give no result, if via home-manager (nix build build .#"homeConfigurations.{user}@{machine}.activationPackage) they show home-manager-path
The two nixes are one from Nix-Darwin and the other from the installer (in my case determinate systems) Originally they were version 2.18.x and 2.20.x but somehow my Nix-Darwin version is now 2.21.2 and so I don't need the installer version.
I have this same issue, but for some reason the default profile is taking precedence over the systemwide Nix package in my path - so I always end up only referencing the Determinate Systems-installed Nix version, which is older than I want to run :/
@remi-gelinas Which shell are you using? and what is your $PATH
How do you do step 3 - Uninstall standalone Nix.
sudo -i nix-env --uninstall nix
worked for me.
You can't uninstall the Determine Systems-installed Nix while using nix-darwin. However, it doesn't really cause issues (the nix-darwin nix is used instead), so I'd just leave it as is
I don't know if this is related -> but I'm seeing the same stuff.
Once I install Darwin I can no longer run nix-shell -p xxxx
(I assume this is because its a flake install maybe)
I don't mind having two installations of nix when using nix-darwin, if both versions are somewhat recent. On my system nix-darwin uses 2.18.1
, yet the latest version available as of this writing is 2.21.0.
What does it take to update the nix that nix-darwin uses? What are reasons that nix-darwin should stay on older releases?
I'm curious and would appreciated if someone more knowledgable could provide some context on this.
@afh Upgrade (and downgrade) can be done in your config files by setting option
nix.package = pkgs.nixVersions.latest
or any of the nixVersions you can find in searching nixpkgs
There are some regressions added by later version of nix so if your system is working then I would leave it. I upgraded as later nix do have a debugger rather than just --show-trace and no doubt other improvements.
Thank you @bestlem, that's very helpful to know. I hear you lound and clear on leaving it, and I'll probably regret my decision to change the installed nix version, when things break, yet I'm keen on exploring the details of nix and nix-darwin more (including newer language features) and think there is benefit for me.
You should almost definitely stay on Nix 2.18. Later versions are kind of just bug-filled messes, and so nixpkgs is staying on Nix 2.18 for a reason.
I don't know if this is related -> but I'm seeing the same stuff.
Once I install Darwin I can no longer run
nix-shell -p xxxx
(I assume this is because its a flake install maybe)
@jeeftor what do you see when you try that?
Thank you for chiming in, @Samasaur1. I was under the impression that the older nix was more a nix-darwin thing rather than nixpkgs. Thanks for clearing that up.
From your experience what makes later versions of Nix kind of a bug filled mess?
From your experience what makes later versions of Nix kind of a bug filled mess?
@afh I actually haven't used Nix > 2.18.x for specifically this reason. That said, I've seen lots of reports of Nix bugs in the Matrix rooms/other places, and they're fairly frequently caused by regressions. You can also look at the issues on NixOS/nix, some of which are labeled with "regression"
@Samasaur1 on first glance 31 open regressions doesn't look to bad to me, but again I've only scratched Nix's surface, if even, so happy to trust the judgement of folks that are more involved.
Out of curiosity: do you think an update of Nix in nixpkgs and nix-darwin will come with the next release, this year or even further out in the future?
I don't know if this is related -> but I'm seeing the same stuff. Once I install Darwin I can no longer run
nix-shell -p xxxx
(I assume this is because its a flake install maybe)@jeeftor what do you see when you try that?
My issue was related to using determinate and not copying all the paths over... but previously only nix shell nixpkgs#xxx
would work - after the fix that and nix-shell -p
both work
I don't know if this is related -> but I'm seeing the same stuff. Once I install Darwin I can no longer run
nix-shell -p xxxx
(I assume this is because its a flake install maybe)@jeeftor what do you see when you try that?
My issue was related to using determinate and not copying all the paths over... but previously only
nix shell nixpkgs#xxx
would work - after the fix that andnix-shell -p
both work
Glad you figured it out!
@afh I don't really keep up with development of Nix the language, so I'm not sure. I do know that there are some alternative implementations that specifically target stability (Lix comes to mind), so you could use those if you wanted.
I'm not sure if this is related, but I have the following configuration:
~/.config/nix/nix.conf
:
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://cache.nixos.org/ https://devenv.cachix.org https://fossar.cachix.org https://shopware.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= fossar.cachix.org-1:Zv6FuqIboeHPWQS7ysLCJ7UT7xExb4OE8c4LyGb5AsE= shopware.cachix.org-1:IDifwLVQaaDU2qhlPkJsWJp/Pq0PfzHPIB90hBOhL3k=
.config/nix/flake.nix
{
description = "Example Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nixpkgs, nix-darwin, home-manager }:
let
configuration = { pkgs, ... }: {
environment.systemPackages = with pkgs; [
devenv
If I execute darwin-rebuild switch --refresh --flake ~/.config/nix
it says it has updated everything, even if I manually run nix-channel --update
upfront.
But devenv version
still gives me 1.0.7
.
nix-shell -p devenv
devenv version
Gives me 1.0.8
.
My $PATH
is /opt/homebrew/bin:/opt/homebrew/sbin:/Users/htuscher/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
I have no idea figuring out why darwin-rebuild
is not installing a new version. But seeing this thread it seems related. Can somebody please tell me if that's the case and how I could figure out what's the issue?
@htuscher I think this is a bug on devenv side.
If you enter devenv shell and then run devenv version
you are running a different executable of devenv than the global one. This executable looks into https://github.com/cachix/devenv/blob/main/src/modules/latest-version
file and on their v1.0.8 release this file stated 1.0.7 version.
If you try to run a global (outside of devenv shell) devenv version
executable you will get v1.0.8 because it looks into a different file https://github.com/cachix/devenv/blob/main/devenv/Cargo.toml
@nickkadutskyi Thanks for your response. As there has been a new release 1.1.0
both https://github.com/cachix/devenv/blob/main/src/modules/latest-version
and https://github.com/cachix/devenv/blob/main/devenv/Cargo.toml
show 1.1
. But even if I do nix-channel --update
or darwin-rebuild switch --refresh --flake ~/.config/nix
I'm still getting devenv 1.0.7 (aarch64-darwin)
.
My local nix-store doesn't have devenv 1.1 installed at all:
ls -lah /nix/store/*-devenv-1*
-r--r--r-- 1 root nixbld 4,3K 1 Jan 1970 /nix/store/9xpjsg1v0jmdfczvhazx6zxdzbszklyd-devenv-1.0.7-vendor.tar.gz.drv
-r--r--r-- 1 root nixbld 4,3K 1 Jan 1970 /nix/store/xhs8kqc0rpmr4zfjd0w93ndvsgmldag7-devenv-1.0.7.drv
I have no idea why this package is not updating.
@htuscher From what I see they still have different versions for v1.1
tag. latest-version says v1.08
and Cargo.toml says 1.1.0
.
Since you are using nix-darwin with flake you need to update flake inputs to get the latest version of everything. Try to run nix flake update
and then darwin-rebuild switch
@nickkadutskyi Thanks a lot, didn't know that the flake.lock could lock versions of packages.
I'm revisiting this issue after a while. As per if it ain't broke leave it strategy i left the determinate systems installer installed nix as it is and used the nix installed by nix-darwin. Now that i'm cleaning up some stuff and willing to spend some time, I want to know what is the proper way to install nix-darwin without having to install two versions of nix.
I think I have to
Grateful for any comments or advice. Thanks in advance.
@thuvasooriya I recently reinstalled nix. I installed nix via determinate installer and then in my nix-darwin setup I had nix.package = pkgs.nixVersions.nix_2_24;
which provides the same version as determinate installer. I still have two nix installations in my store:
❯ nix config check
[FAIL] Multiple versions of nix found in PATH:
/nix/store/d88r5b1qv1fvz2j9qndz8sr31mqgz45x-nix-2.24.6/bin
/nix/store/lavm0gpm9h0xl3a1fwcwxm7ahf47sq95-nix-2.24.6/bin
But they are of the same version. So far can't see any issues.
@nickkadutskyi thanks for the comment, yeah and I haven't faced any dire issues with two different nix versions in my store either. It's just something not expected of a nix environment afaik and it annoys me so much sometimes. sorry for the trouble. i just wanted to know if there is a way to just have nix-darwin and the one nix version it maintains
@thuvasooriya I recently reinstalled nix. I installed nix via determinate installer and then in my nix-darwin setup I had
nix.package = pkgs.nixVersions.nix_2_24;
which provides the same version as determinate installer. I still have two nix installations in my store:❯ nix config check [FAIL] Multiple versions of nix found in PATH: /nix/store/d88r5b1qv1fvz2j9qndz8sr31mqgz45x-nix-2.24.6/bin /nix/store/lavm0gpm9h0xl3a1fwcwxm7ahf47sq95-nix-2.24.6/bin
But they are of the same version. So far can't see any issues.
apologies for off-topic - but how did you enable the nix config
command? When I try to run this, it says that config
is not a recognized command.
@gshpychka nix config is a new command not in nix 2.18 (or lix) - for that version use nix doctor
I would also look at which -a nix
to see the PATH used to find nix.
I think the one from the installer /nix/var/nix/profiles/default/bin/nix probably does not matter if you have set a nix version elsewhere - and (at least on macOS) that one is difficult to upgrade.
I'm following the instructions here and it seems like I now have two versions of Nix installed. Determinate Systems currently installed 2.20.5 Then after running
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
, mynix --version
is 2.18.2.nix-doctor
also states that I have two conflicting nixes.Is that to be expected?
It's confusing (as a total newbie) also because I'm not sure what my PATH should be set to in .zshenv
export PATH="/nix/var/nix/profiles/default/bin:$PATH"
<-- Determinateexport PATH="/run/current-system/sw/bin:$PATH"
<--nix-darwin