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 search path entry does not exist #28

Open
KaiserKarel opened this issue Apr 11, 2021 · 6 comments
Open

Nix search path entry does not exist #28

KaiserKarel opened this issue Apr 11, 2021 · 6 comments

Comments

@KaiserKarel
Copy link

I'm getting the following error:

warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignorg
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I), at /home/karel3

Any advice on how to use nix build inside the vm?

@Mic92
Copy link
Owner

Mic92 commented Apr 11, 2021

It looks like you do not have a valid NIX_PATH set and/or or nix-channels is not set up in the VM.

If you don't to set up one each time you can use one of the following methods:

$ export NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz
$ nix-build

or

$ nix-build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz

There is probably also a way on how to do this declarative in the NixOS configuration of the VM.
I think our installation tests in nixpkgs had some examples.

@KaiserKarel
Copy link
Author

KaiserKarel commented Apr 11, 2021

I'm thinking this might also be due to my permsissions? When I create a different user in the vm.nix file, in the wheel group, and try to use sudo, I get the following error:

sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy"
sudo: /nix/store/b0f7wna41zs504lqy1ir7s1fknr893ll-sudo-1.9.6p1/libexec/sudo/sudoers.so must be owned by uid 0
sudo: fatal error, unable to load plugins

My NIX_PATH does is valid for the user karel, but not root:

warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring # does not exist
`/nix/var/nix/profiles/per-user/karel/channels'  # does exist

For context, here is the configuration file:

 { lib, pkgs, ... }: {
  boot.kernelPackages = pkgs.linuxPackages_latest;
  services.openssh.enable = true;

  virtualisation = {
    cores = 6;
    memorySize = "16G";
    docker.enable = true;
    graphics = false;
  };



  users.users = let
    user = builtins.getEnv "USER";
    keys = map (key: "${builtins.getEnv "HOME"}/.ssh/${key}") ["id_rsa.pub" "id_ecdsa.pub" "id_ed25519.pu>
    home = builtins.getEnv "HOME";
  in {
   ${user} = {
    isNormalUser = true;
    extraGroups = ["wheel" "networkmanager" "docker"];
    openssh.authorizedKeys.keyFiles = lib.filter builtins.pathExists keys;
    home = home;
    initialHashedPassword = "";
   };
  };

@KaiserKarel
Copy link
Author

Or am I not supposed to use users different from root with nixos-shell?

@Mic92
Copy link
Owner

Mic92 commented Apr 12, 2021

I have not tested this with different users but when I log into the vm and run as root

$ sudo nix-channel --add https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz nixos
$ ls -la /nix/var/nix/profiles/per-user/root/
lrwxrwxrwx 15 root 12 Apr 11:56  channels -> channels-1-link
lrwxrwxrwx 60 root 12 Apr 11:56  channels-1-link -> /nix/store/67f8bhzzq3jbahrmsq77i7g2fdyj1dbm-user-environment

I see a channel being created.

@KaiserKarel
Copy link
Author

Hmmm, I'll have a look at this more this weekend. We were hoping to use nixos-shell as dev environments, with services running etc; so running everything as root should work, although our security guy was not too happy ;)

@Mic92
Copy link
Owner

Mic92 commented Apr 19, 2021

It should also work without root. I just have not tried it. You need to create a different channel anyway afterwards. Instead of channels you can also set NIX_PATH globally in the vm using this nixos configuration.

{ pkgs, ... }: {
      nix.nixPath = [
        "nixpkgs=${pkgs.path}"
      ];
}

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

No branches or pull requests

2 participants