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...
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...
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";
};
};
Additionally, you can also add a file from a path with:
environment.etc = {
somerc.source = /etc/somerc;
};
Or a directory:
environment.etc = {
aDir.source = ./aDir;
};
Or a package path:
environment.etc = {
"X11/xorg.conf.d/90-super.conf".source = "${pkgs.displayfix}/share/displayfix/data/90-super.conf";
};
/etc/somerc
point to itself? – Mateen Ulhaq Oct 24 '21 at 13:14/path/to/file
instead? – Steve Chavez Oct 24 '21 at 22:31