Commit 84220a70 authored by Vincent Haupert's avatar Vincent Haupert Committed by pennae
Browse files

nixos/envoy: add `package` option

parent 3c3da876
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ let
  conf = format.generate "envoy.json" cfg.settings;
  validateConfig = file:
    pkgs.runCommand "validate-envoy-conf" { } ''
      ${pkgs.envoy}/bin/envoy --log-level error --mode validate -c "${file}"
      ${cfg.package}/bin/envoy --log-level error --mode validate -c "${file}"
      cp "${file}" "$out"
    '';

@@ -18,6 +18,8 @@ in
  options.services.envoy = {
    enable = mkEnableOption (lib.mdDoc "Envoy reverse proxy");

    package = mkPackageOptionMD pkgs "envoy" { };

    settings = mkOption {
      type = format.type;
      default = { };
@@ -46,14 +48,14 @@ in
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ pkgs.envoy ];
    environment.systemPackages = [ cfg.package ];
    systemd.services.envoy = {
      description = "Envoy reverse proxy";
      after = [ "network-online.target" ];
      requires = [ "network-online.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = "${pkgs.envoy}/bin/envoy -c ${validateConfig conf}";
        ExecStart = "${cfg.package}/bin/envoy -c ${validateConfig conf}";
        CacheDirectory = [ "envoy" ];
        LogsDirectory = [ "envoy" ];
        Restart = "no";