4

Seems my hosts file (/etc/hosts) points to /nix/store/gds7bha3bx0a22pnzw93pgf0666anpyr-etc-hosts and is read only.

How am I meant to modify this file?

6

Modify the nixos config with:

networking.extraHosts =
  ''
    127.0.0.2 other-localhost
    10.0.0.1 server
  '';
  • It sounds like it could be an answer; perhaps Chris could use some extra words to explain what this is and why it works? – Jeff Schaller Dec 17 '18 at 16:22
  • Perhaps a reference could be github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/… – Jeff Schaller Dec 17 '18 at 16:36
  • When I reviewing, I thought that it looked like a fairly random piece of data. It is clear that is has something to do with the code at the GitHub link that Jeff posted in an earlier comment, but it looks malformed (or I just don't understand the the syntax, which appears different from the GitHub code). If this is a proper answer, please add information about where and how and why this code snipped would be used. Until then, I will still consider this to be a non-answer. If it's a clarification to the question, then please update the question with this info and describe how it's relevant. – Kusalananda Dec 17 '18 at 18:14
  • 1
    Well, yes, networking.extraHosts from the configuration.nix file will get into the /etc/hosts on the resulting NixOS system. – Vladimír Čunát Dec 17 '18 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.