home-manager/services/gonic: init

Even though it's pointless in practice since it needs firewall for
security-oriented systems but still... could be useful for desktop
systems where security is permissive.
This commit is contained in:
Gabriel Arazas 2024-08-01 12:29:56 +08:00
parent 3c56efb777
commit 2a2526f196
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
5 changed files with 78 additions and 0 deletions

View File

@ -9,6 +9,7 @@
./services/bleachbit.nix
./services/distant.nix
./services/gallery-dl.nix
./services/gonic.nix
./services/matcha.nix
./services/plover.nix
./services/yt-dlp.nix

View File

@ -0,0 +1,54 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.gonic;
settingsFormat = pkgs.formats.keyValue {
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
listsAsDuplicateKeys = true;
};
settingsFile = settingsFormat.generate "gonic-settings-config" cfg.settings;
in
{
options.services.gonic = {
enable = lib.mkEnableOption "Gonic, a Subsonic-compatible music server";
package = lib.mkPackageOption pkgs "gonic" { };
settings = lib.mkOption {
type = settingsFormat.type;
default = { };
description = ''
Configuration to be included to the service.
'';
example = lib.literalExpression ''
{
music-path = [ config.xdg.userDirs.music ];
podcast-path = [ "''${config.xdg.userDirs.music}/Podcasts" ];
}
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.gonic" pkgs
lib.platforms.linux)
];
systemd.user.services.gonic = {
Unit = {
Description = "Gonic media server";
Documentation = [ "https://github.com/sentriz/gonic/wiki" ];
After = [ "network.target" ];
};
Service = {
ExecStart = "${lib.getExe' cfg.package "gonic"} -config-path ${settingsFile}";
Restart = "on-failure";
};
Install.WantedBy = [ "default.target" ];
};
};
}

View File

@ -60,6 +60,7 @@ import nmt {
./services/archivebox
./services/bleachbit
./services/gallery-dl
./services/gonic
./services/matcha
./services/plover
./services/yt-dlp

View File

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
{
services.gonic = {
enable = true;
package = pkgs.gonic;
settings = {
music-path = [ config.xdg.userDirs.music ];
podcast-path = [ "${config.xdg.userDirs.music}/Podcasts" ];
};
};
test.stubs.gonic = { };
nmt.script = ''
assertFileExists home-files/.config/systemd/user/gonic.service
'';
}

View File

@ -0,0 +1,3 @@
{
gonic-basic = ./basic.nix;
}