I screwed my NixOS and deleted user-environment :(

I did nix store delete /nix/store/...-user-environment/ (shame on me but I thought this would fix another weird problem).

Now I get this error:

$ sudo nixos-rebuild switch --show-trace
error:
       … while realising the context of a path

       at «string»:1:6:

            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |      ^

       error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «string»:1:13:

            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |             ^
building Nix...
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
error: file 'nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
/tmp/nixos-rebuild.Elytb3/nix
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
building the system configuration...
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

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

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.38, NixOS, 23.05 (Stoat), 23.05.1998.f64b9738da8`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `"nixos-23.05, nixos-unstable"`
 - channels(jakob): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Any ideas how to get it running again? Please!

1 Like

Oh wait! Looks like just a new terminal window did the trick.

BTW, the original problem mentioned above was this: python-2.7 is marked as insecure, refusing to evaluate after upgrading to NixOS 23.05.

1 Like

The wonders of rubber duck debugging :duck: :smile:

2 Likes