Change:
After installing NixOS then using nixos-enter to chroot into the installation dns does not work. I am trying to clone down a repository but it fails because it cannot resolve Here is a picture of the of some commands run inside the chrooted installation <img width="435" alt="capture" src="https://user-" being run to install and call the chrooted commands. being used a vm using one of the 18.03.. isos (UEFI Mode). this "test" machine (option 4) when prompted (this is setup for hyper-v so you may need to fix the hardware- back to the default one generated). error after installation finishes Please run and paste the results. <img width="276" alt="capture2" src="https://user-"
I'm guessing this is because nixos-enter doesn't create a I think the appropriate solution would be to bind-mount that in from the host system. As a workaround, you should be able to make it work by running .
This leaves me a bit confused. I'm using the nixos-enter after nixos-install has completed. Does not get generated during the build? I noticed that I did not have networkmanager specifically enabled in my configuration. I'll test that and report back.
So specifically enabling networkmanager didn't fix anything. Copying into the chroot didn't fix the issue either. It turns out that nixos-enter regenerates the every time it's called <img width="242" alt="capture3" src="https://user-"<img width="407" alt="capture4" src="https://user-"edit: I retested the commands from the pics above with an external network adapter instead of a natted one. Same result.
And everything works fine outside nixos-enter?
Yep no issues in the regular environment. DNS resolution works fine, as well, once rebooted into the fresh installation. It is just in the nixos-enter environment right after installation, before reboot, that DNS doesn't want to work.
I have a similar problem during install where an overlay does a curl as part of make install - fails because it can't resolve dns (in this case ).
Skipping the install of that overlay and then trying nixos-enter:
Trying the below does work (so clearly something isn't right about the generated ):
Finally, bind mounting the host readonly does allow me to to run nixos-enter: So now nixos-enter fails to generate the (and a working bind mounted one gets used) as it's readonly. Unfortunately the same doesn't seem to be true for nixos-install strangely enough (the overlay still fails to install), not sure why. I could however do: I get some errors from the above but it does install the overlay package. In general there seems to be a dns resolution problem during nixos-install (if dns is required by the build, like doing a curl from the Makefile) and also when doing nixos-enter. In my case I was using the unstable image: .
So my host looks like this: The generated under /mnt/etc (when not bind mounting) looks like this: So it's missing the nameserver(s).
Hmm. As I am a nixos newbie it may just be that I don't fully understand the notion of fixedOutput packages. Looking through the sources for the package manager it seems the build environment will only allow networking when the output is a fixedOutputHash one. However, that does seem like it would mean the package cannot be built everywhere as the binary won't have the same hash...
Ok so I think I get it now. I was installing packages in an impure way I suppose as they were downloading things "behind the scene", sorry I'm a newbie still. So nixos-install is doing what it should do I think. Still, I don't understand why generates an unusable as detailed above and I think that's what this issue really is about.
The issue becomes more severe when you take into account that even if you create a correct it will get replaced every time nixos-enter is called. So if you are using nixos-enter in a script it becomes a blocking issue.
I have the same problem. I'm running a live USB NixOS but I have already installed NixOS on my computer. I'd like to just chroot to my already installed NixOS system and run nixos-install there but it doesn't work because network fails.
After you mount the installation you can just run "nixos-install --no-root-passwd" again. It will pull the configuration from whatever is already installed in the /mnt folder and just update it. The core root of the problem for this ticket/issue is being generated incorrectly. Just waiting for nixos-enter to be fixed in this regard for the ticket to be closed.
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly: for maintainers and people that previously touched the related code and @ mention them in a comment. on the . on the on .
still important to me. I confirm that this is still broken as of 20.03.2102. !
I marked this as stale due to inactivity. &rarr;
Still broken in 20.09
solved it for me. The file did not get replaced when running nixos-enter. Still far from ideal though
I have to be that person ("use the reactions instead of posting you also have this issue"), but this issue is from 2018. Well, I'm having this issue with the GNOME 21.05 ISO.
arch-chroot bind mounts

Discussion:
mount --rbind /dev "$mountPoint/dev" mount --rbind /sys "$mountPoint/sys" <ins> # modified from https://github.com/archlinux/arch-install-scripts/blob/bb04ab435a5a89cd5e5ee821783477bc80db797f/arch-chroot.in#L26-L52 chroot_add_resolv_conf() { local chrootdir=$1 resolv_conf=$1/etc/resolv.conf [[ -e /etc/resolv.conf ]] || return 0 # Handle resolv.conf as a symlink to somewhere else. if [[ -L $chrootdir/etc/resolv.conf ]]; then # readlink(1) should always give us *something* since we know at this point # it's a symlink. For simplicity, ignore the case of nested symlinks. # We also ignore the possibility if `../`s escaping the root. resolv_conf=$(readlink "$chrootdir/etc/resolv.conf") if [[ $resolv_conf = /* ]]; then resolv_conf=$chrootdir$resolv_conf else resolv_conf=$chrootdir/etc/$resolv_conf fi fi # ensure file exists to bind mount over if [[ ! -f $resolv_conf ]]; then install -Dm644 /dev/null "$resolv_conf" || return 1 fi mount --bind /etc/resolv.conf "$resolv_conf" } chroot_add_resolv_conf "$mountPoint" || print "ERROR: failed to set up resolv.conf" </ins> ( # If silent, write both stdout and stderr of activation script to /dev/null # otherwise, write both streams to stderr of this process