zaphyra's git: nixfiles

zaphyra's nixfiles

commit 44fdbb976925394071b0614bd2f319847c7e140a
parent edfb1cd524446658a8a3716a08c924d63a231f18
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Mon, 21 Jul 2025 08:55:16 +0200

config/home/zaphyra/services: add `owntone`
2 files changed, 64 insertions(+), 0 deletions(-)
A
config/home/zaphyra/services/owntone.nix
|
62
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M
config/nixos/modules/users/zaphyra.nix
|
2
++
diff --git a/config/home/zaphyra/services/owntone.nix b/config/home/zaphyra/services/owntone.nix
@@ -0,0 +1,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" ];
+    };
+  };
+
+}+
\ No newline at end of file
diff --git a/config/nixos/modules/users/zaphyra.nix b/config/nixos/modules/users/zaphyra.nix
@@ -59,6 +59,8 @@ in
             [
               configure.xdg
 
+              services.owntone
+
               programs.ghostty
               programs.ssh
               programs.git