How to add a file to /etc in NixOS

nixos

What is the NixOS-way to put a configuration file in /etc?

E.g. I want to drop /etc/nanorc. I found some forum entries talking about programming it into /etc/nixos/configuration.nix, but could not find any documentation about that…

Best Answer

To create a file in /etc on NixOS, use environment.etc in configuration.nix. Here's an example:

environment.etc = {
  # Creates /etc/nanorc
  nanorc = {
    text = ''
      whatever you want to put in the file goes here.
    '';

    # The UNIX file mode bits
    mode = "0440";
  };
};
Related Question