aboutsummaryrefslogtreecommitdiff
path: root/modules/nixosModules/gonic.nix
diff options
context:
space:
mode:
authorspl3g <notspl3g@duck.com>2026-03-18 18:01:41 +0300
committerspl3g <notspl3g@duck.com>2026-03-18 18:01:59 +0300
commit03648b3d9f177227df40129bed22558f6924b91c (patch)
tree8a22eda142beeafd9002a8d5901ba9428a77ad52 /modules/nixosModules/gonic.nix
parentdc19a2b583b3ab50d8e36ff0a90ca633495f675f (diff)
so.. v2 i guess
Diffstat (limited to 'modules/nixosModules/gonic.nix')
-rw-r--r--modules/nixosModules/gonic.nix114
1 files changed, 114 insertions, 0 deletions
diff --git a/modules/nixosModules/gonic.nix b/modules/nixosModules/gonic.nix
new file mode 100644
index 0000000..0f1907a
--- /dev/null
+++ b/modules/nixosModules/gonic.nix
@@ -0,0 +1,114 @@
+{inputs, ...}: {
+ flake.nixosModules.gonic = {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ 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.
+ '';
+ };
+
+ settings = mkOption {
+ default = {};
+ description = ''
+ Additional gonic settings
+ '';
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ systemd.services.gonic.serviceConfig = {
+ DynamicUser = lib.mkForce false;
+ User = "gonic";
+ Group = "gonic";
+ SupplementaryGroups = cfg.extraGroups;
+ ReadWritePaths = [
+ cfg.podcastsPath
+ cfg.playlistsPath
+ ];
+ };
+
+ users = {
+ groups = {
+ gonic = {};
+ };
+
+ users.gonic = {
+ isSystemUser = true;
+ group = "gonic";
+ };
+ };
+
+ systemd.tmpfiles.rules = [
+ "d ${cfg.stateDir} 0755 gonic gonic"
+ "d ${cfg.podcastsPath} 0755 gonic gonic"
+ "d ${cfg.playlistsPath} 0755 gonic gonic"
+ ];
+
+ services.gonic = {
+ enable = true;
+ settings =
+ {
+ listen-addr = cfg.listenAddr;
+ music-path = cfg.musicPaths;
+ playlists-path = [cfg.playlistsPath];
+ podcast-path = [cfg.podcastsPath];
+ db-path = ["${cfg.stateDir}/gonic.db"];
+ }
+ // cfg.settings;
+ };
+ };
+ };
+}