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

nix-tree no longer works by default, does not contain a 'flake.nix', searching up #106

Closed
sg-qwt opened this issue Dec 8, 2024 · 10 comments · Fixed by #109
Closed

nix-tree no longer works by default, does not contain a 'flake.nix', searching up #106

sg-qwt opened this issue Dec 8, 2024 · 10 comments · Fixed by #109

Comments

@sg-qwt
Copy link

sg-qwt commented Dec 8, 2024

x nix run 'nixpkgs#nix-tree' -- --version
nix-tree 0.5.0
x nix run 'nixpkgs#nix-tree'
path '/home/me/.local/state/nix/profile' does not contain a 'flake.nix', searching up
error: could not find a flake.nix file
nix-tree: Received ExitFailure 1 when running
Raw command: nix path-info --json --extra-experimental-features "nix-command flakes" /home/me/.local/state/nix/profile /var/run/current-system
> nix --version
nix (Nix) 2.24.10

I guess this is caused by the newer nix version?

nix-tree /var/run/current-system still works
So I have to use nix run 'nixpkgs#nix-tree' -- /var/run/current-system instead now.
Somewhere between the version, the default behavior changed so now I have to pass in current-system explicitly nowadays?

@utdemir
Copy link
Owner

utdemir commented Dec 10, 2024

Oh - I had no idea, thanks for reporting! Yeah, likely the behavior of Nix has changed at some point - as I don't think there was a change on nix-tree side. I'll have a look.

@utdemir
Copy link
Owner

utdemir commented Jan 8, 2025

Looked at this a bit - but I can't reproduce it on my system as I don't have a .local/state/nix/profile so nix-tree just skips it. I think this happens when you don't have a flake enabled profile, am I right?

For reference, here's the part where nix-tree finds your system and user profiles:

home <- getHomeDirectory
nixXdgDirectory <- getXdgDirectory XdgState "nix/profile"
roots <-
filterM
doesDirectoryExist
[ home </> ".nix-profile",
nixXdgDirectory,
"/var/run/current-system"
]

So - could you tell me what does your /home/me/.local/state/nix/profile look like? In other words, which path should nix-tree pass to nix path-info command to get information about your user profile?

@utdemir
Copy link
Owner

utdemir commented Jan 8, 2025

(I also asked this to NixOS Matrix channel as likely I only have today to work on it)

@sg-qwt
Copy link
Author

sg-qwt commented Jan 8, 2025

Looked at this a bit - but I can't reproduce it on my system as I don't have a .local/state/nix/profile so nix-tree just skips it. I think this happens when you don't have a flake enabled profile, am I right?

For reference, here's the part where nix-tree finds your system and user profiles:

home <- getHomeDirectory
nixXdgDirectory <- getXdgDirectory XdgState "nix/profile"
roots <-
filterM
doesDirectoryExist
[ home </> ".nix-profile",
nixXdgDirectory,
"/var/run/current-system"
]

So - could you tell me what does your /home/me/.local/state/nix/profile look like? In other words, which path should nix-tree pass to nix path-info command to get information about your user profile?

My /home/me/.local/state/nix/profile is a directory.

/home/me/.local/state/nix/profile/
└── share
    └── emacs
        └── native-lisp
            └── 30.0.92-7824dc9f
                └── site-start-6962a3f8-8f4312e0.eln

I'm using flake based NixOS, but I never used profile.
nix profile list returns empty.

@utdemir
Copy link
Owner

utdemir commented Jan 8, 2025

@sg-qwt Thanks! So I was wrong with my flake hypothesis then.

When you say it's a directory, is it a plain directory, or a symlink to something under /nix/store? If it's a symlink, what happens when you run nix path-info --json PATH both against the directory itself ( /home/me/.local/state/nix/profile), and also the path it points to?

@sg-qwt
Copy link
Author

sg-qwt commented Jan 8, 2025

@sg-qwt Thanks! So I was wrong with my flake hypothesis then.

When you say it's a directory, is it a plain directory, or a symlink to something under /nix/store? If it's a symlink, what happens when you run nix path-info --json PATH both against the directory itself ( /home/me/.local/state/nix/profile), and also the path it points to?

plain directory

@utdemir
Copy link
Owner

utdemir commented Jan 9, 2025

Ok - so the assumption on #71 was broken then. I'll continue from there.

@GrigorenkoPV
Copy link
Contributor

I'm using flake based NixOS, but I never used profile.

I am curious how ~/.local/state/nix/profile/ got created then.

By the way, do you have anything else under ~/.local/state/nix/?

Does ~/.local/state/nix/profiles/profile exist?

Is ~/.local/state/nix a symlink?

@sg-qwt
Copy link
Author

sg-qwt commented Jan 10, 2025

I'm using flake based NixOS, but I never used profile.

I am curious how ~/.local/state/nix/profile/ got created then.

By the way, do you have anything else under ~/.local/state/nix/?

Does ~/.local/state/nix/profiles/profile exist?

Is ~/.local/state/nix a symlink?

~/.local/state/nix is plain directory

> l ~/.local/state/nix
total 0
drwxr-xr-x 4 me users 0 Nov 27 03:17 .
drwxr-xr-x 5 me users 0 Dec 15 02:36 ..
drwxr-xr-x 3 me users 0 Nov 27 03:17 profile
drwxr-xr-x 2 me users 0 Dec 25 16:05 profiles

~/.local/state/nix/profiles/profile does NOT exist
all hm links under profiles directory

> l ~/.local/state/nix/profiles
total 23K
drwxr-xr-x 2 me users  0 Dec 25 16:05 .
drwxr-xr-x 4 me users  0 Nov 27 03:17 ..
lrwxrwxrwx 1 me users 20 Dec 25 15:56 home-manager -> home-manager-45-link
lrwxrwxrwx 1 me users 67 Nov  4 22:51 home-manager-10-link -> /nix/store/4ya9j1l0pva2l1ijbkvbkr9y02qdknqm-home-manager-generation
lrwxrwxrwx 1 me users 67 Nov  5 19:01 home-manager-11-link -> /nix/store/nm0ljf376ywr21b1598ci9gs16844g1p-home-manager-generation
lrwxrwxrwx 1 me users 67 Nov  5 19:08 home-manager-12-link -> /nix/store/8yrsysmfr96xwjsx2hf831jrijmw0gif-home-manager-generation
lrwxrwxrwx 1 me users 67 Nov  5 19:09 home-manager-13-link -> /nix/store/z9fdfc2mal1hqnls4ydwqv2glxfiys2f-home-manager-generation
lrwxrwxrwx 1 me users 67 Nov  5 19:31 home-manager-14-link -> /nix/store/py8z5vpkdrcy98qhpwyx2m6nb90d7iva-home-manager-generation
lrwxrwxrwx 1 me users 67 Nov  8 17:31 home-manager-15-link -> /nix/store/85hxj6lq89fxm5d82j0d3iicr8c1yn3x-home-manager-generation
lrwxrwxrwx 1 me users 67 Nov  8 17:37 home-manager-16-link -> /nix/store/vrqqxsn6jfqhf1z24js6hqq7128k8gi1-home-manager-generation

@GrigorenkoPV
Copy link
Contributor

Ah, home manager is doing weird things. Okay.

Well, I guess checking that a path is a symlink (as I've suggested in #71 (comment)) should help. Maybe we should even add $XDG_STATE_HOME/nix/profiles/home-manager to the list.

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

Successfully merging a pull request may close this issue.

3 participants