From e951d875609d46870c0f5c35f9c43d4d3a9a82ce Mon Sep 17 00:00:00 2001
From: Ethel Morgan <eth@ethulhu.co.uk>
Date: Sat, 23 May 2020 18:17:24 +0100
Subject: add a helix package and a helix-player module

---
 module-list.nix          |  1 +
 modules/helix-player.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
 pkgs/default.nix         |  2 ++
 3 files changed, 53 insertions(+)
 create mode 100644 modules/helix-player.nix

diff --git a/module-list.nix b/module-list.nix
index 41a06cf..401dea6 100644
--- a/module-list.nix
+++ b/module-list.nix
@@ -1,5 +1,6 @@
 [
   ./modules/keyboard.nix
+  ./modules/helix-player.nix
   ./modules/linode.nix
   ./modules/overlays.nix
   ./modules/upmpdcli.nix
diff --git a/modules/helix-player.nix b/modules/helix-player.nix
new file mode 100644
index 0000000..d73fc16
--- /dev/null
+++ b/modules/helix-player.nix
@@ -0,0 +1,50 @@
+{ config, lib, pkgs, ... }:
+with lib;
+
+let
+
+  cfg = config.services.helix-player;
+  helixPackage = pkgs.eth.helix;
+
+  runtimeDirectory = "helix-player";
+  socket = "/run/${runtimeDirectory}/listen.sock";
+
+in {
+
+  options.services.helix-player = {
+
+    enable = mkEnableOption "Whether to enable helix-player";
+
+    socket = mkOption {
+      type = types.str;
+      readOnly = true;
+      description = "Path of the UNIX socket to listen on.";
+      example = socket;
+    };
+  };
+
+
+  config = mkIf cfg.enable {
+
+    services.helix-player.socket = socket;
+
+    environment.systemPackages = [
+      helixPackage
+    ];
+
+    systemd.services.helix-player = {
+      enable = true;
+      description = "Helix UPnP player & controller";
+      wants = [ "network.target" ];
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        DynamicUser = "yes";
+        Group = config.services.nginx.group;
+        RuntimeDirectory = "${runtimeDirectory}";
+        ExecStart = "${helixPackage}/bin/helix-player -socket ${socket}";
+      };
+    };
+  };
+
+}
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 01810e2..5ea0599 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -2,6 +2,8 @@ pkgs: super: {
   eth = {
     recipesEthMoe = pkgs.callPackage ( builtins.fetchGit { url = "https://github.com/ethulhu/recipes.eth.moe"; } ) {};
 
+    helix = pkgs.callPackage ( builtins.fetchGit { url = "https://github.com/ethulhu/helix"; rev = "142be94fb81ee3ff7aba1694836fd45330d22862"; } ) {};
+
     libnpupnp = pkgs.callPackage ./libnpupnp { };
     libupnpp  = pkgs.callPackage ./libupnpp  { };
     upmpdcli  = pkgs.callPackage ./upmpdcli  { };
-- 
cgit v1.2.3