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

nixos-option no longer works after collect garbage #138

Closed
liaowang11 opened this issue Feb 25, 2021 · 5 comments
Closed

nixos-option no longer works after collect garbage #138

liaowang11 opened this issue Feb 25, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@liaowang11
Copy link

Your issue may already be reported!
Please search on the issue tracker before creating one.

Expected Behavior

nixos-option from profile/core/default.nix should still works after nix-collect-garbage -d
profile/core/default.nix includes an alias to fix nixos-option:

nixos-option = "nixos-option -I nixpkgs=${toString ../../compat}";

Current Behavior

nixos-option :

terminate called after throwing an instance of 'nix::EvalError'
  what():  cannot import '/nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source/flake.nix', since path
 '/nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source' is not valid, at /nix/store/2mpgi4bvn8py4liv9
w3mjxd2c5r7bvv8-source/default.nix:131:19
fish: Job 1, “command nixos-option -I nixpkgs…” terminated by signal SIGABRT (Abort)

Possible Solution

The nixpkgs used by flake-compat in compat/default.nix has no referrers, which is why it’s got garbage collect.
I don’t know enough of Nix to add some kind of references to the nixpkgs source to fix this.

Steps to Reproduce

  1. nixos-rebuild switch
  2. nix-collect-garbage -d
  3. nixos-option errors

Context

nixos-option use /nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source/
which is included in gc print-dead.

> nixos-option services.earlyoom                                   
unpacking 'https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz'...
terminate called after throwing an instance of 'nix::EvalError'
  what():  cannot import '/nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source/flake.nix', since path
 '/nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source' is not valid, at /nix/store/2mpgi4bvn8py4liv9
w3mjxd2c5r7bvv8-source/default.nix:131:19
fish: Job 1, “command nixos-option -I nixpkgs…” terminated by signal SIGABRT (Abort)

> nix-store -q --references /nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source

> nix-store --gc --print-dead | rg /nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/xmssbbj2d1pfm51cqci88ggxnmi3j9dj' to '/tmp/nixos-rebuild.CRuJ2V/result'
determining live/dead paths...
/nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source

Your Environment

@liaowang11 liaowang11 added the bug Something isn't working label Feb 25, 2021
@nrdxp
Copy link
Collaborator

nrdxp commented Feb 25, 2021

I can't reproduce this. IIRC, I found this issue myself, and I believe the toString fixed it. Here's what happens on my machine:
asciicast

@liaowang11
Copy link
Author

@nrdxp So what is currently referring that nixpkgs which nixos-option is using?
On my two machines, all no referrers(the store path may varies).
❯ nix-store -q --referrers /nix/store/slf28rxb23rmx2qgid4bwfifwbkyb5ji-dxl4kb7jclicnk2mignizz53bk8wl9z4-source

@nrdxp
Copy link
Collaborator

nrdxp commented Feb 26, 2021

alias nixos-option
nixos-option='nixos-option -I nixpkgs=/nix/store/1ivyv4zwqzqjpqz5qb0yp9xbax331m6l-source/compat'

@liaowang11
Copy link
Author

Ok, i will dive into this further, close for now.

@nrdxp
Copy link
Collaborator

nrdxp commented Feb 26, 2021

I will also take a closer look later as well by clearing all non declarative gcroots and see if maybe the issue will arise then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants