Commit 9246d8f7 authored by jopejoe1's avatar jopejoe1
Browse files

nixos/shairport-sync: add freeform config

parent f9f59197
Loading
Loading
Loading
Loading
+38 −3
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@ with lib;
let

  cfg = config.services.shairport-sync;

  configFormat = pkgs.formats.libconfig {};
  configFile = configFormat.generate "shairport-sync.conf" cfg.settings;
in

{
@@ -29,6 +30,38 @@ in

      package = lib.options.mkPackageOption pkgs "shairport-sync" { };

      settings =  mkOption {
        type = configFormat.type;
        default = {};
        example = {
          general = {
            name = "NixOS Shairport";
            output_backend = "pw";
          };
          metadata = {
            enabled = "yes";
            include_cover_art = "yes";
            cover_art_cache_directory = "/tmp/shairport-sync/.cache/coverart";
            pipe_name = "/tmp/shairport-sync-metadata";
            pipe_timeout = 5000;
          };
          mqtt = {
            enabled = "yes";
            hostname = "mqtt.server.domain.example";
            port = 1883;
            publish_parsed = "yes";
            publish_cover = "yes";
          };
        };
        description = ''
          Configuration options for Shairport-Sync.

          See the example [shairport-sync.conf][example-file] for possible options.

          [example-file]: https://github.com/mikebrady/shairport-sync/blob/master/scripts/shairport-sync.conf
        '';
      };

      arguments = mkOption {
        type = types.str;
        default = "-v -o pa";
@@ -108,8 +141,10 @@ in
        };
      };

    environment.systemPackages = [ cfg.package ];

    environment =  {
      systemPackages = [ cfg.package ];
      etc."shairport-sync.conf".source = configFile;
    };
  };

}