1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 { 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" ];
};
};
}