大量背景信息,TLDR 位于底部
我正在使用 NixOS,为了使我的系统具有声明性,我链接到了~/.config/monitors.xml
我保存在配置中的文件,如下所示:
systemd.tmpfiles.rules = [ "L /home/thomas/.config/monitors.xml - - - - ${pkgs.writeText "thomas_monitors.xml" "${builtins.readFile ./monitors.xml}"}" ];
此属性添加了一条tmpfiles.d
规则,用于链接/home/thomas/.config/monitors.xml
到存储在 Nix 存储区中包含内容的文件<my nixos configuration directory>/monitors.xml
。
然而,在查看我的.config
目录时,我注意到那monitors.xml
是一个普通文件,而不是一个链接。
systemd-tmpfiles-setup.service
和服务systemd-tmpfiles-clean.service
在每次启动时都会根据运行systemctl status
,所以我知道它必须尝试建立符号链接,即使它没有被建立。
当我在我的配置中进行差异比较时~/.config/monitors.xml
,monitors.xml
没有任何区别,所以我最好的猜测是 Gnome 以某种方式注意到了链接的建立并将其替换为它所链接到的文件?
或者,也许systemd-tmpfiles
没有建立链接,并且monitors.xml
当前存在的链接是由 Gnome 生成的,恰好与我在配置中定义的链接相同?如果是这种情况,我有什么方法可以强制systemd-tmpfiles
建立链接吗?
我还有另外两条tmpfiles.d
规则monitors.xml
,一条是将其链接到/run/gdm/.config/monitors.xml
,另一条是将其链接到/root/.config/monitors.xml
,这两条规则都正确链接了文件。唯一不起作用的是~/.config
。
另外,/home/thomas
是我的主目录,也是/home/thomas/.config
。~/.config
我知道这不是问题。
总结:
为什么~/.config/monitors.xml
没有符号链接到我想要的文件?Gnome 会删除链接吗?或者,如果systemd-tmpfiles
出于某种原因没有建立链接,我该如何强制它建立链接?