{ config, lib, pkgs, ... }: { home.persistence."/nix/persist/home/${config.home.username}".directories = [ "owntone/.local/share/owntone" ]; systemd.user.services.owntone = let configFile = pkgs.writeText "owntone.conf" '' general { uid = "${config.home.username}" db_path = "/home/${config.home.username}/.local/share/owntone/db_songs3.db" loglevel = log logfile = "/home/${config.home.username}/.local/share/owntone/owntone.log" cache_dir = "/home/${config.home.username}/.local/share/owntone/cache" speaker_autoselect = true } airplay_shared { control_port = 7200 timing_port = 7201 } library { name = "owntone on %h" port = 3689 clear_queue_on_stop_disable = true directories = { "/home/${config.home.username}/Music", "/home/${config.home.username}/Audiobooks" } audiobooks = { "/Audiobooks" } } audio { nickname = "Computer" type = "pulseaudio" } streaming {} ''; in { Unit = { Description = "owntone music server"; ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session.target" "pipewire-pulse.service" ]; StartLimitBurst = 5; StartLimitIntervalSec = 10; }; Service = { ExecStart = "${lib.getExe pkgs.owntone} -f -c ${configFile}"; Restart = "on-failure"; RestartSec = 5; }; Install = { WantedBy = [ "graphical-session.target" ]; }; }; }