From 00a575ca43519e2ae66691d820725351a8cd7eae Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 28 Jul 2016 12:59:29 +0200 Subject: [PATCH] m ps3netsrv: init --- 3modules/default.nix | 7 +++-- 3modules/ps3netsrv.nix | 58 +++++++++++++++++++++++++++++++++++++ 5pkgs/ps3netsrv/default.nix | 2 +- 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 3modules/ps3netsrv.nix diff --git a/3modules/default.nix b/3modules/default.nix index febebaa..7fc095b 100644 --- a/3modules/default.nix +++ b/3modules/default.nix @@ -2,11 +2,12 @@ _: { imports = [ - ./snapraid.nix - ./umts.nix - ./taskserver.nix ./awesome-extra.nix ./forward-journal.nix + ./ps3netsrv.nix + ./snapraid.nix + ./taskserver.nix + ./umts.nix ]; } diff --git a/3modules/ps3netsrv.nix b/3modules/ps3netsrv.nix new file mode 100644 index 0000000..2268163 --- /dev/null +++ b/3modules/ps3netsrv.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with config.krebs.lib; +let + cfg = config.makefu.ps3netsrv; + + out = { + options.makefu.ps3netsrv = api; + config = lib.mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "ps3netsrv"; + + servedir = mkOption { + description = "path to serve, must be set"; + type = types.str; + }; + + package = mkOption { + type = types.package; + default = pkgs.ps3netsrv; + }; + + user = mkOption { + description = ''user which will run ps3netsrv''; + type = types.str; + default = "ps3netsrv"; + }; + }; + + imp = { + systemd.services.ps3netsrv = { + description = "ps3netsrv server"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + restartIfChanged = true; + unitConfig = { + Documentation = "https://www.arm-blog.com/playing-ps3-games-from-your-nas/" ; + ConditionPathExists = cfg.servedir; + }; + serviceConfig = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/ps3netsrv++ ${shell.escape cfg.servedir}"; + PrivateTmp = true; + User = "${cfg.user}"; + }; + }; + + # TODO only create if user is ps3netsrv + users.users.ps3netsrv = { + uid = genid "ps3netsrv"; + }; + users.groups.ps3netsrv.gid = genid "ps3netsrv"; + }; +in +out + diff --git a/5pkgs/ps3netsrv/default.nix b/5pkgs/ps3netsrv/default.nix index 9041859..f62ee0c 100644 --- a/5pkgs/ps3netsrv/default.nix +++ b/5pkgs/ps3netsrv/default.nix @@ -10,7 +10,7 @@ stdenv.mkDerivation rec { url = "https://github.com/dirkvdb/ps3netsrv--"; fetchSubmodules = true; rev = "e54a66cbf142b86e2cffc1701984b95adb921e81"; # latest @ 2016-05-24 - sha256 = "0l7bp18cs3xr2qgsmcf18diccski49mj9whngxm9isi8wd4r9inj"; + sha256 = "09hvmfzqy2jckpsml0z1gkcnar8sigmgs1q66k718fph2d3g54sa"; }; nativeBuildInputs = [ gnugrep ];