Merge pull request #207106 from autrimpo/gonic-module

nixos/gonic: init

Sandro 6197953f d6279d00

Changed files
+122
maintainers
nixos
doc
manual
release-notes
modules
services
audio
tests
pkgs
servers
gonic
+6
maintainers/maintainer-list.nix
···
githubId = 12958979;
name = "Mika Naylor";
};
autumnal = {
name = "Sven Friedrich";
email = "sven@autumnal.de";
···
githubId = 12958979;
name = "Mika Naylor";
};
+
autrimpo = {
+
email = "michal@koutensky.net";
+
github = "autrimpo";
+
githubId = 5968483;
+
name = "Michal Koutenský";
+
};
autumnal = {
name = "Sven Friedrich";
email = "sven@autumnal.de";
+2
nixos/doc/manual/release-notes/rl-2305.section.md
···
- [networkd-dispatcher](https://gitlab.com/craftyguy/networkd-dispatcher), a dispatcher service for systemd-networkd connection status changes. Available as [services.networkd-dispatcher](#opt-services.networkd-dispatcher.enable).
- [mmsd](https://gitlab.com/kop316/mmsd), a lower level daemon that transmits and recieves MMSes. Available as [services.mmsd](#opt-services.mmsd.enable).
- [QDMR](https://dm3mat.darc.de/qdmr/), a GUI application and command line tool for programming DMR radios [programs.qdmr](#opt-programs.qdmr.enable)
···
- [networkd-dispatcher](https://gitlab.com/craftyguy/networkd-dispatcher), a dispatcher service for systemd-networkd connection status changes. Available as [services.networkd-dispatcher](#opt-services.networkd-dispatcher.enable).
+
- [gonic](https://github.com/sentriz/gonic), a Subsonic music streaming server. Available as [services.gonic](#opt-services.gonic.enable).
+
- [mmsd](https://gitlab.com/kop316/mmsd), a lower level daemon that transmits and recieves MMSes. Available as [services.mmsd](#opt-services.mmsd.enable).
- [QDMR](https://dm3mat.darc.de/qdmr/), a GUI application and command line tool for programming DMR radios [programs.qdmr](#opt-programs.qdmr.enable)
+1
nixos/modules/module-list.nix
···
./services/audio/alsa.nix
./services/audio/botamusique.nix
./services/audio/gmediarender.nix
./services/audio/hqplayerd.nix
./services/audio/icecast.nix
./services/audio/jack.nix
···
./services/audio/alsa.nix
./services/audio/botamusique.nix
./services/audio/gmediarender.nix
+
./services/audio/gonic.nix
./services/audio/hqplayerd.nix
./services/audio/icecast.nix
./services/audio/jack.nix
+89
nixos/modules/services/audio/gonic.nix
···
···
+
{ config, lib, pkgs, ... }:
+
+
with lib;
+
+
let
+
cfg = config.services.gonic;
+
settingsFormat = pkgs.formats.keyValue {
+
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
+
listsAsDuplicateKeys = true;
+
};
+
in
+
{
+
options = {
+
services.gonic = {
+
+
enable = mkEnableOption (lib.mdDoc "Gonic music server");
+
+
settings = mkOption rec {
+
type = settingsFormat.type;
+
apply = recursiveUpdate default;
+
default = {
+
listen-addr = "127.0.0.1:4747";
+
cache-path = "/var/cache/gonic";
+
tls-cert = null;
+
tls-key = null;
+
};
+
example = {
+
music-path = [ "/mnt/music" ];
+
podcast-path = "/mnt/podcasts";
+
};
+
description = lib.mdDoc ''
+
Configuration for Gonic, see <https://github.com/sentriz/gonic#configuration-options> for supported values.
+
'';
+
};
+
+
};
+
};
+
+
config = mkIf cfg.enable {
+
systemd.services.gonic = {
+
description = "Gonic Media Server";
+
after = [ "network.target" ];
+
wantedBy = [ "multi-user.target" ];
+
serviceConfig = {
+
ExecStart =
+
let
+
# these values are null by default but should not appear in the final config
+
filteredSettings = filterAttrs (n: v: !((n == "tls-cert" || n == "tls-key") && v == null)) cfg.settings;
+
in
+
"${pkgs.gonic}/bin/gonic -config-path ${settingsFormat.generate "gonic" filteredSettings}";
+
DynamicUser = true;
+
StateDirectory = "gonic";
+
CacheDirectory = "gonic";
+
WorkingDirectory = "/var/lib/gonic";
+
RuntimeDirectory = "gonic";
+
RootDirectory = "/run/gonic";
+
ReadWritePaths = "";
+
BindReadOnlyPaths = [
+
# gonic can access scrobbling services
+
"-/etc/ssl/certs/ca-certificates.crt"
+
builtins.storeDir
+
cfg.settings.podcast-path
+
] ++ cfg.settings.music-path
+
++ lib.optional (cfg.settings.tls-cert != null) cfg.settings.tls-cert
+
++ lib.optional (cfg.settings.tls-key != null) cfg.settings.tls-key;
+
CapabilityBoundingSet = "";
+
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
+
RestrictNamespaces = true;
+
PrivateDevices = true;
+
PrivateUsers = true;
+
ProtectClock = true;
+
ProtectControlGroups = true;
+
ProtectHome = true;
+
ProtectKernelLogs = true;
+
ProtectKernelModules = true;
+
ProtectKernelTunables = true;
+
SystemCallArchitectures = "native";
+
SystemCallFilter = [ "@system-service" "~@privileged" ];
+
RestrictRealtime = true;
+
LockPersonality = true;
+
MemoryDenyWriteExecute = true;
+
UMask = "0066";
+
ProtectHostname = true;
+
};
+
};
+
};
+
+
meta.maintainers = [ maintainers.autrimpo ];
+
}
+1
nixos/tests/all-tests.nix
···
gocd-agent = handleTest ./gocd-agent.nix {};
gocd-server = handleTest ./gocd-server.nix {};
gollum = handleTest ./gollum.nix {};
google-oslogin = handleTest ./google-oslogin {};
gotify-server = handleTest ./gotify-server.nix {};
grafana = handleTest ./grafana {};
···
gocd-agent = handleTest ./gocd-agent.nix {};
gocd-server = handleTest ./gocd-server.nix {};
gollum = handleTest ./gollum.nix {};
+
gonic = handleTest ./gonic.nix {};
google-oslogin = handleTest ./google-oslogin {};
gotify-server = handleTest ./gotify-server.nix {};
grafana = handleTest ./grafana {};
+18
nixos/tests/gonic.nix
···
···
+
import ./make-test-python.nix ({ pkgs, ... }: {
+
name = "gonic";
+
+
nodes.machine = { ... }: {
+
services.gonic = {
+
enable = true;
+
settings = {
+
music-path = [ "/tmp" ];
+
podcast-path = "/tmp";
+
};
+
};
+
};
+
+
testScript = ''
+
machine.wait_for_unit("gonic")
+
machine.wait_for_open_port(4747)
+
'';
+
})
+5
pkgs/servers/gonic/default.nix
···
{ lib, stdenv, buildGoModule, fetchFromGitHub
, pkg-config, taglib, zlib
# Disable on-the-fly transcoding,
···
'"mpv"' \
'"${lib.getBin mpv}/bin/mpv"'
'';
meta = {
homepage = "https://github.com/sentriz/gonic";
···
{ lib, stdenv, buildGoModule, fetchFromGitHub
+
, nixosTests
, pkg-config, taglib, zlib
# Disable on-the-fly transcoding,
···
'"mpv"' \
'"${lib.getBin mpv}/bin/mpv"'
'';
+
+
passthru = {
+
tests.gonic = nixosTests.gonic;
+
};
meta = {
homepage = "https://github.com/sentriz/gonic";