mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 23:23:07 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
113 lines
2.5 KiB
Nix
113 lines
2.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.shairport-sync;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.shairport-sync = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Enable the shairport-sync daemon.
|
|
|
|
Running with a local system-wide or remote pulseaudio server
|
|
is recommended.
|
|
'';
|
|
};
|
|
|
|
arguments = mkOption {
|
|
type = types.str;
|
|
default = "-v -o pa";
|
|
description = lib.mdDoc ''
|
|
Arguments to pass to the daemon. Defaults to a local pulseaudio
|
|
server.
|
|
'';
|
|
};
|
|
|
|
openFirewall = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to automatically open ports in the firewall.
|
|
'';
|
|
};
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "shairport";
|
|
description = lib.mdDoc ''
|
|
User account name under which to run shairport-sync. The account
|
|
will be created.
|
|
'';
|
|
};
|
|
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "shairport";
|
|
description = lib.mdDoc ''
|
|
Group account name under which to run shairport-sync. The account
|
|
will be created.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.shairport-sync.enable {
|
|
|
|
services.avahi.enable = true;
|
|
services.avahi.publish.enable = true;
|
|
services.avahi.publish.userServices = true;
|
|
|
|
users = {
|
|
users.${cfg.user} = {
|
|
description = "Shairport user";
|
|
isSystemUser = true;
|
|
createHome = true;
|
|
home = "/var/lib/shairport-sync";
|
|
group = cfg.group;
|
|
extraGroups = [ "audio" ] ++ optional config.hardware.pulseaudio.enable "pulse";
|
|
};
|
|
groups.${cfg.group} = {};
|
|
};
|
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
allowedTCPPorts = [ 5000 ];
|
|
allowedUDPPortRanges = [ { from = 6001; to = 6011; } ];
|
|
};
|
|
|
|
systemd.services.shairport-sync =
|
|
{
|
|
description = "shairport-sync";
|
|
after = [ "network.target" "avahi-daemon.service" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
ExecStart = "${pkgs.shairport-sync}/bin/shairport-sync ${cfg.arguments}";
|
|
RuntimeDirectory = "shairport-sync";
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = [ pkgs.shairport-sync ];
|
|
|
|
};
|
|
|
|
}
|