diff options
author | Ethel Morgan <eth@ethulhu.co.uk> | 2020-05-22 16:37:24 +0100 |
---|---|---|
committer | Ethel Morgan <eth@ethulhu.co.uk> | 2020-05-22 16:37:24 +0100 |
commit | a0000bf3f1789555cdd1d8b586ff611ef9ad7e64 (patch) | |
tree | 8354d5d2890083e0766ba8139193fac601bc6544 | |
parent | 50b27be54d368f38945bae71bc0683330c2a7693 (diff) |
create nixpkgs for upmpdcli and dependencies, also a NixOS module
Diffstat (limited to '')
-rw-r--r-- | module-list.nix | 1 | ||||
-rw-r--r-- | modules/upmpdcli.nix | 78 | ||||
-rw-r--r-- | pkgs/default.nix | 8 | ||||
-rw-r--r-- | pkgs/libnpupnp/default.nix | 39 | ||||
-rw-r--r-- | pkgs/libupnpp/default.nix | 42 | ||||
-rw-r--r-- | pkgs/upmpdcli/default.nix | 43 |
6 files changed, 209 insertions, 2 deletions
diff --git a/module-list.nix b/module-list.nix index 6f59f49..a431b95 100644 --- a/module-list.nix +++ b/module-list.nix @@ -2,5 +2,6 @@ ./modules/keyboard.nix ./modules/linode.nix ./modules/overlays.nix + ./modules/upmpdcli.nix ./modules/yubikey.nix ] diff --git a/modules/upmpdcli.nix b/modules/upmpdcli.nix new file mode 100644 index 0000000..5b83a2f --- /dev/null +++ b/modules/upmpdcli.nix @@ -0,0 +1,78 @@ +{ config, lib, pkgs, ... }: +with lib; + +let + cfg = config.services.upmpdcli; + + cacheDir = "upmpdcli"; + + upmpdConf = pkgs.writeText "upmpd.conf" '' + cachedir = /var/cache/${cacheDir} + + friendlyname = ${cfg.friendlyName} + + mpdhost = ${cfg.mpd.host} + mpdport = ${toString cfg.mpd.port} + + ${optionalString (cfg.mpd.password != "") "${cfg.mpd.password}"} + + ${cfg.extraConfig} + ''; + +in { + options.services.upmpdcli = { + enable = mkEnableOption "Run upmpdcli server"; + + friendlyName = mkOption { + type = types.str; + default = "UpMpd"; + description = "Friendly Name used for UPnP discovery."; + }; + + mpd = { + host = mkOption { + type = types.str; + default = config.services.mpd.network.listenAddress; + description = "Host of the MPD server."; + }; + port = mkOption { + type = types.int; + default = config.services.mpd.network.port; + description = "Port of the MPD server."; + }; + password = mkOption { + type = types.str; + default = ""; + description = "Password of the MPD server."; + }; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ + pkgs.eth.upmpdcli + ]; + + systemd.services.upmpdcli = { + enable = true; + description = ""; + wants = [ "network.target" ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.openssl pkgs.python3 ]; + serviceConfig = { + DynamicUser = "yes"; + CacheDirectory = cacheDir; + Type = "simple"; + ExecStart="${pkgs.eth.upmpdcli}/bin/upmpdcli -c ${upmpdConf}"; + Restart = "always"; + RestartSec = "1min"; + }; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index f4b4a25..01810e2 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,5 +1,9 @@ -self: super: { +pkgs: super: { eth = { - recipesEthMoe = self.callPackage ( builtins.fetchGit { url = "https://github.com/ethulhu/recipes.eth.moe"; } ) {}; + recipesEthMoe = pkgs.callPackage ( builtins.fetchGit { url = "https://github.com/ethulhu/recipes.eth.moe"; } ) {}; + + libnpupnp = pkgs.callPackage ./libnpupnp { }; + libupnpp = pkgs.callPackage ./libupnpp { }; + upmpdcli = pkgs.callPackage ./upmpdcli { }; }; } diff --git a/pkgs/libnpupnp/default.nix b/pkgs/libnpupnp/default.nix new file mode 100644 index 0000000..ced2d58 --- /dev/null +++ b/pkgs/libnpupnp/default.nix @@ -0,0 +1,39 @@ +{ pkgs ? import <nixpkgs> {} +, autoconf +, autoreconfHook +, curl +, expat +, fetchgit +, libmicrohttpd +, pkgconfig +, stdenv +}: + +stdenv.mkDerivation rec { + name = "libnpupnp-${version}"; + version = "latest"; + + src = fetchgit { + url = "https://framagit.org/medoc92/npupnp.git"; + rev = "98433263968de83f13416bf096a31fa354a646fa"; + sha256 = "0i5hd7pbmcdhh46hqf50881jbl7ycv3gpvczbpzkx5ffbnpxxika"; + }; + + nativeBuildInputs = [ + autoconf + autoreconfHook + pkgconfig + ]; + + buildInputs = [ + curl.dev + expat + libmicrohttpd + ]; + + meta = { + description = "A C++ base UPnP library, derived from Portable UPnP, a.k.a libupnp"; + homepage = "https://framagit.org/medoc92/npupnp"; + license = stdenv.lib.licenses.bsd3; + }; +} diff --git a/pkgs/libupnpp/default.nix b/pkgs/libupnpp/default.nix new file mode 100644 index 0000000..5775462 --- /dev/null +++ b/pkgs/libupnpp/default.nix @@ -0,0 +1,42 @@ +{ pkgs ? import <nixpkgs> {} +, autoconf +, autoreconfHook +, curl +, expat +, fetchgit +, libmicrohttpd +, libnpupnp ? pkgs.eth.libnpupnp +, pkgconfig +, stdenv +}: + +stdenv.mkDerivation rec { + name = "libupnpp-${version}"; + version = "latest"; + + src = fetchgit { + url = "https://framagit.org/medoc92/libupnpp.git"; + rev = "762e35f4f66df183b8df8b1fc4dbab187068441d"; + sha256 = "085virkyz8cp55kd6k3zadhclh10qi78ijd84dnbmk852w57xsx9"; + }; + + nativeBuildInputs = [ + autoconf + autoreconfHook + pkgconfig + ]; + + buildInputs = [ + curl.dev + libnpupnp + expat + ]; + + enableParallelBuilding = true; + + meta = { + description = "A higher level C++ API over libnpupnp or libupnp"; + homepage = "https://www.lesbonscomptes.com/upmpdcli/libupnpp-refdoc/libupnpp-ctl.html"; + license = stdenv.lib.licenses.lgpl21; + }; +} diff --git a/pkgs/upmpdcli/default.nix b/pkgs/upmpdcli/default.nix new file mode 100644 index 0000000..7ae3ec0 --- /dev/null +++ b/pkgs/upmpdcli/default.nix @@ -0,0 +1,43 @@ +{ pkgs ? import <nixpkgs> {} +, autoconf +, jsoncpp +, autoreconfHook +, curl +, fetchgit +, libmicrohttpd +, libupnpp ? pkgs.eth.libupnpp +, mpd_clientlib +, pkgconfig +, stdenv +}: + +stdenv.mkDerivation rec { + name = "upmpdcli-${version}"; + version = "latest"; + + src = fetchgit { + url = "https://framagit.org/medoc92/upmpdcli.git"; + rev = "898b202b9c23be423775207a5407046a1e70fd52"; + sha256 = "0i25za83r2rgipx3m72n8cma7s2jqibvgm6r0kh4kcy2rlxwz0kv"; + }; + + nativeBuildInputs = [ + autoconf + autoreconfHook + pkgconfig + ]; + + buildInputs = [ + jsoncpp + curl.dev + libmicrohttpd + libupnpp + mpd_clientlib + ]; + + meta = { + description = "An UPnP Audio Media Renderer based on MPD"; + homepage = "https://www.lesbonscomptes.com/upmpdcli/"; + license = stdenv.lib.licenses.lgpl21; + }; +} |