NixOS 放置配置文件的方式是什么/etc
?
例如我想放弃/etc/nanorc
。我发现一些论坛条目讨论将其编程为/etc/nixos/configuration.nix
,但找不到任何相关文档......
答案1
/etc
要在 NixOS 上创建文件,请使用environment.etc
in configuration.nix
。这是一个例子:
environment.etc = {
# Creates /etc/nanorc
nanorc = {
text = ''
whatever you want to put in the file goes here.
'';
# The UNIX file mode bits
mode = "0440";
};
};
答案2
此外,您还可以通过以下方式从路径添加文件:
environment.etc = {
somerc.source = /etc/somerc;
};
或者一个目录:
environment.etc = {
aDir.source = ./aDir;
};
或者包路径:
environment.etc = {
"X11/xorg.conf.d/90-super.conf".source = "${pkgs.displayfix}/share/displayfix/data/90-super.conf";
};