Howto get a package config path in nix store for systemd service

Hello,

I’m using nix for a while now an getting further down the rabbit hole…

Right now I am writing a config for readeck an wanted to make a systemd-service an -timer for backup. All i need to do is make a simple write command as mentioned in readeck doc ( Backups - Readeck ):

readeck export -config /path/to/config.toml export.zip

which equals to something like this in my .nix-file:

systemd.services.readeck-backup = {
  [...]
  serviceConfig = {
    ExecStart = "${pkgs.readeck}/bin/readeck export -config ??? /data/backup/readeck/readeck-export.zip"
  };
};

Any ideas howto get the /path/to/config.toml in nix store? The config is generated by the rebuild command and not in the same path than ${pkgs.readeck}. It’s just somewhere and i can’t figure out how to get the right variable for that in the systemd.services declaration…

link to the readeck module: And starve him.

It’s impossible to find it, the module author decided to hide it behind a let binding so there is no way to access it from within a NixOS module.

You’ll have to create your own copy from the settings:

{ config, ... }: let
  readeckConfig = (pkgs.formats.toml { }).generate "readeck.toml" config.services.readeck.settings;
in {
  systemd.services.readeck-backup = {
  [...]
    serviceConfig =  {
      ExecStart = "${pkgs.readeck}/bin/readeck export -config ${readeckConfig} /data/backup/readeck/readeck-export.zip"
    };
  };
}

That, or you parse the ExecStart line of the service, but that seems brittle.

I doubt your backup service will work, though, you’re likely going to run into issues since this doesn’t run with the same cgroups and such.