feat: restructured snapcast

main
Ricard Illa 2023-08-19 18:36:21 +02:00
parent 36a64d5fdc
commit 42ad65fc34
Signed by: rilla
GPG Key ID: 525307BD467E4205
7 changed files with 62 additions and 23 deletions

View File

@ -9,6 +9,7 @@
./hardware-configuration.nix
./file-systems.nix
./home-manager.nix
./snapcast.nix
outputs.nixosModules.common
outputs.nixosModules.desktop
];

View File

@ -15,7 +15,9 @@
imports = [
outputs.homeManagerModules.common
outputs.homeManagerModules.extra
outputs.homeManagerModules.snapcast
];
snapclient.enable = true;
};
};
}

View File

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
services.snapserver = {
enable = true;
codec = "flac";
streams = {
pipewire = {
type = "pipe";
location = "/run/snapserver/pipewire";
};
};
};
systemd.user.services.snapcast-sink = {
wantedBy = [ "pipewire.service" ];
after = [ "pipewire.service" ];
bindsTo = [ "pipewire.service" ];
path = with pkgs; [ gawk pulseaudio ];
script = ''
pactl load-module module-pipe-sink file=/run/snapserver/pipewire sink_name=Snapcast format=s16le rate=48000
'';
};
}

View File

@ -29,7 +29,7 @@
neovim = import ./neovim;
pass = import ./pass;
rss = import ./rss;
snapcast = import ./snapcast;
snapclient = import ./snapclient;
sound = import ./sound;
ssh = import ./ssh;
syncthing = import ./syncthing;

View File

@ -20,7 +20,6 @@
../msg
../music
../rss
../snapcast
../sound
../syncthing
../theming

View File

@ -1,21 +0,0 @@
{ config, pkgs, ... }:
let snapserver_ip = "192.168.1.144";
in
{
home.packages = [ pkgs.snapcast ];
systemd.user.services.snapclient = {
Unit = {
After = [ "pipewire.service" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.snapcast}/bin/snapclient --host ${snapserver_ip}";
};
Install = {
WantedBy = [ "pipewire.service" ];
};
};
}

View File

@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:
let
cfg = config.snapclient;
in
{
options.snapclient = {
enable = lib.mkEnableOption "snapclient";
snapserver-host = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = "host running snapserver to connect to";
};
package = lib.mkOption {
type = lib.types.package;
default = pkgs.snapcast;
defaultText = "pkgs.snapcast";
description = "package for snapcast";
};
};
config = lib.mkIf cfg.enable {
systemd.user.services.snapclient = {
Service = {
Type = "simple";
ExecStart = "${cfg.package}/bin/snapclient --host ${cfg.snapserver-host}";
};
Unit.After = [ "pipewire.service" ];
Install.WantedBy = [ "pipewire.service" ];
};
};
}