Error: Not an absolute path default-1-link

I have difficulty in installing package as normal user. It says “not an absolute path”. I have yet understand about profile and how it relates to channel, therefor do not know where to look for neither what to modify.

 myuser@machine  ~ 
$ nix-env -i hello                                                                                                                                                                                                                                                            ~
installing 'hello-2.10'
error: not an absolute path: 'default-1-link'

The operation works normally once I use sudo.

Here another nixy details.

 myuser@machine  ~ 
$ nix-channel --list                                                                                                                                                                                                                                                          ~
nixos https://nixos.org/channels/nixos-19.09

 myuser@machine  ~ 
$ echo $NIX_PATH                                                                                                                                                                                                                                                              ~
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

 myuser@machine  ~ 
$ ls -lih ~/ | grep nix                                                                                                                                                                                                                                                        ~
-rw-r--r--  myuser mygroup   45 .nix-channels
drwxr-xr-x  myuser mygroup 4.0K .nix-defexpr
lrwxrwxrwx  myuser mygroup   29 .nix-profile -> /nix/var/nix/profiles/default

 myuser@machine  ~ 
$ ls -lah /nix/var/nix/profiles/default                                                                                                                                                                                                                                       ~
lrwxrwxrwx root root /nix/var/nix/profiles/default -> default-59-link

I’ve never encountered the error: not an absolute path: 'default-1-link' issue.

However, taking a step back, generally what you want when using nix-env to install is nix-env -iA nixpkgs.hello. This will also speed up evaluation time considerably.

Taking another step back, I almost never use nix-env because it falls into the “I did some manual setup to get this machine to this point”. I would highly recommend using system.packages in your configuration.nix, or using home.packages in home-manager. These expressions can be easily version controlled and gets a machine to a consistent state very fast.

Thank you for the points, definitely will considering those :smiley:

However, taking a step back, generally what you want when using nix-env to install is nix-env -iA nixpkgs.hello . This will also speed up evaluation time considerably.

Oh by the way, have you heard some program that do the caching for this? That nix-env sometime repeatedly make us wait for the same operation. If that not exist, I’m planning on creating a simple one, just for query (the package name) and translate (the packagename-version into some.attribute).

If i remember correctly, the long wait for nix-env -i, is just specific to that program since it has to consider every channel that you have, and tries to do some fuzzy logic to look up related results. With the -A options, you’re essentially saying, “please only evaluate this one attribute, and don’t search everywhere”.