Blocky on NixOS cannot write logs to certain directory #1638
-
Hello I am trying to use Blocky with NixOS, and I specified a path on where the logs get written, but I keep getting an error saying This is the part of my config I have that tells where to write the logs:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, yes the root filesystem is read-only so you can't just create a directory there. Putting stuff at the root is anyways not a good practice, the filesytem layout actually follows something called the Filesystem Hierarchy Standard (FHS). It's common to put things at the root for containers, but that's generally an ugly hack if you ask me. In the NixOS community you might see people mention the FHS because NixOS doesn't strictly follow it since it puts most things in the Nix store and then symlinks only some of them at the more standard path. This breaks a lot of programs, for instance running all prebuilt dynamically linked binaries since those binaries hardcode a path to the dynamic linker like Anyways here, you should point blocky to something in a directory it has write access to. Systemd can create a directory for you, see LogsDirectory (untested): # This modifies the blocky systemd unit (it will be merged with what's defined in the NixOS module)
# It needs to go at the root of the config, basically at the same level as where you wrote services.blocky
systemd.services.blocky.serviceConfig.LogsDirectory = "blocky";
# Configure the query log to be under the LogsDirectory
# I wrote the full path to the config value but this would work just as well copied into your snippet
services.blocky.config.queryLog.target = "/var/log/blocky/queries"; It's possible to avoid needing to knowing the log dir value in advance, doing something like this (untested). In this case it's not too useful, but shows off # Think of `BindPaths` like a container volume mount, the bound path is only visible to the unit
# The idea here is we use %L which Systemd expands to the `LogsDirectory`, and make it accessible at a known path
# See man systemd.unit for %L and others
systemd.services.blocky.serviceConfig.BindPaths = [ "%L/blocky/queries:/run/blocky-query-logs" ];
# Then we can hard code that known path in the blocky config
services.blocky.config.queryLog.target = "/run/blocky-query-logs"; P.S. I happen to use NixOS so can reply, but this kind of question would better be posted on the NixOS community forum. |
Beta Was this translation helpful? Give feedback.
Hey, yes the root filesystem is read-only so you can't just create a directory there.
Putting stuff at the root is anyways not a good practice, the filesytem layout actually follows something called the Filesystem Hierarchy Standard (FHS). It's common to put things at the root for containers, but that's generally an ugly hack if you ask me.
In the NixOS community you might see people mention the FHS because NixOS doesn't strictly follow it since it puts most things in the Nix store and then symlinks only some of them at the more standard path. This breaks a lot of programs, for instance running all prebuilt dynamically linked binaries since those binaries hardcode a path to the dynamic li…