Unverified Commit a10e1717 authored by Bruno BELANYI's avatar Bruno BELANYI Committed by GitHub
Browse files

nixos/autobrr: use systemd credentials (#381759)

parents a143b7cc ce9137b3
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ let
  cfg = config.services.autobrr;
  configFormat = pkgs.formats.toml { };
  configTemplate = configFormat.generate "autobrr.toml" cfg.settings;
  templaterCmd = "${lib.getExe pkgs.dasel} put -f '${configTemplate}' -v $(cat ${cfg.secretFile}) -o %S/autobrr/config.toml 'sessionSecret'";
  templaterCmd = ''${lib.getExe pkgs.dasel} put -f '${configTemplate}' -v "$(${config.systemd.package}/bin/systemd-creds cat sessionSecret)" -o %S/autobrr/config.toml "sessionSecret"'';
in
{
  options = {
@@ -73,9 +73,10 @@ in
      serviceConfig = {
        Type = "simple";
        DynamicUser = true;
        LoadCredential = "sessionSecret:${cfg.secretFile}";
        StateDirectory = "autobrr";
        ExecStartPre = "${lib.getExe pkgs.bash} -c '${templaterCmd}'";
        ExecStart = "${lib.getExe pkgs.autobrr} --config %S/autobrr";
        ExecStart = "${lib.getExe cfg.package} --config %S/autobrr";
        Restart = "on-failure";
      };
    };