Starting Postgrest with SystemD

I am trying to write a systemd service for postgrest like this = {
    postgrest = {
      enable = true;
      description = "Start postgrest";
      after = [ "container@testproddb.service" ];

      serviceConfig = {
        User = "postgrest";
        Restart = "always";
        ExecStart = "${let unstable = import <nixos-unstable> {}; in with pkgs; unstable.haskellPackages.postgrest}/bin/postgrest /etc/nixos/config/postgrest.conf";

I have to run unstable for that package because its broken in 23.11.

When i look at the output .service file it points to a .postgrest directory in the store but not the .postgrest-bin directory.

Am i doing something dumb? :slight_smile:

You can probably just use the lib.getBin function on that package. Interpolating a package into a string will use its out output by default, not its bin output.

I think what ElvishJerricco said would work.

In addition, I think where you imported the unstable channel you forgot to include system variable, so that may also be some of what is causing an issue for you? Although you are using the < > syntax which would mean thats an actual channel not a flake import so I suppose that is probably fine?