From c087d476f03b9e94a879ab1fa752ffe90de3e7f9 Mon Sep 17 00:00:00 2001 From: spl3g Date: Fri, 22 Aug 2025 22:24:50 +0500 Subject: feat: add server modules --- nixos/serverModules/gonic.nix | 88 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 nixos/serverModules/gonic.nix (limited to 'nixos/serverModules/gonic.nix') diff --git a/nixos/serverModules/gonic.nix b/nixos/serverModules/gonic.nix new file mode 100644 index 0000000..526d79e --- /dev/null +++ b/nixos/serverModules/gonic.nix @@ -0,0 +1,88 @@ +{ config, lib, ... }: +with lib; +let + cfg = config.gonic; +in +{ + options = { + gonic = { + enable = mkEnableOption "enable gonic configuration"; + + listenAddr = mkOption { + type = types.str; + default = "127.0.0.1:4747"; + description = '' + Address that gonic will listen on. + ''; + }; + + extraGroups = mkOption { + type = types.listOf (types.str); + default = []; + description = '' + Additional groups for gonic. + ''; + }; + + musicPaths = mkOption { + type = types.listOf (types.str); + description = '' + Directories with music in it. + ''; + }; + + podcastsPath = mkOption { + type = types.str; + default = "${cfg.stateDir}/podcasts"; + description = '' + Directory for podcasts. + ''; + }; + + playlistsPath = mkOption { + type = types.str; + default = "${cfg.stateDir}/playlists"; + description = '' + Directory for playlists. + ''; + }; + + stateDir = mkOption { + type = types.str; + default = "/var/lib/gonic"; + description = '' + A directory where gonic will keep their files. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + nixpkgs.overlays = [ + (final: prev: { + ffmpeg = prev.ffmpeg-headless; + }) + ]; + + systemd.services.gonic.serviceConfig = { + SupplementaryGroups = cfg.extraGroups; + }; + + systemd.tmpfiles.rules = [ + "d ${cfg.stateDir} 0755 nobody nogroup" + "d ${cfg.podcastsPath} 0755 nobody nogroup" + "d ${cfg.playlistsPath} 0755 nobody nogroup" + ]; + + services.gonic = { + enable = true; + settings = { + listen-addr = cfg.listenAddr; + music-path = cfg.musicPaths; + playlists-path = [cfg.podcastsPath]; + podcast-path = [cfg.playlistsPath]; + db-path = ["${cfg.stateDir}/gonic.db"]; + }; + }; + }; +} -- cgit v1.2.3