From e9d795cc37696ea3352262f88227c899f9851842 Mon Sep 17 00:00:00 2001 From: kat witch Date: Wed, 12 May 2021 01:52:15 +0100 Subject: [PATCH] pkgs/libreelec-dvb-firmware: init + hosts/ostara: tvheadend Samhain has a virtualhost for it to make it accessible on Yggdrasil. --- hosts/ostara/nixos/default.nix | 42 ++++++++++++++++++++++++- hosts/samhain/nixos/virtualhosts.nix | 1 + pkgs/default.nix | 2 ++ pkgs/libreelec-dvb-firmware/default.nix | 26 +++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 pkgs/libreelec-dvb-firmware/default.nix diff --git a/hosts/ostara/nixos/default.nix b/hosts/ostara/nixos/default.nix index 59035cf5..6993e147 100644 --- a/hosts/ostara/nixos/default.nix +++ b/hosts/ostara/nixos/default.nix @@ -1,4 +1,6 @@ -{ config, users, pkgs, profiles, ... }: +{ lib, config, users, pkgs, profiles, ... }: + +with lib; { imports = [ ./hw.nix profiles.laptop ]; @@ -16,5 +18,43 @@ networking.interfaces.enp1s0.useDHCP = true; networking.interfaces.wlp2s0.useDHCP = true; + katnet.public.interfaces = singleton "wlp2s0"; + + katnet.public.tcp.ports = [ 9981 9982 ]; + + hardware.firmware = [ pkgs.libreelec-dvb-firmware ]; + + services.tvheadend.enable = true; + + systemd.services.tvheadend.enable = lib.mkForce false; + + systemd.services.tvheadend-kat = { + description = "Tvheadend TV streaming server"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + script = '' + ${pkgs.tvheadend}/bin/tvheadend \ + --http_root /tvheadend \ + --http_port 9981 \ + --htsp_port 9982 \ + -f \ + -C \ + -p ${config.users.users.tvheadend.home}/tvheadend.pid \ + -u tvheadend \ + -g video + ''; + serviceConfig = { + Type = "forking"; + PIDFile = "${config.users.users.tvheadend.home}/tvheadend.pid"; + Restart = "always"; + RestartSec = 5; + User = "tvheadend"; + Group = "video"; + + ExecStop = "${pkgs.coreutils}/bin/rm ${config.users.users.tvheadend.home}/tvheadend.pid"; + }; + }; + + system.stateVersion = "20.09"; } diff --git a/hosts/samhain/nixos/virtualhosts.nix b/hosts/samhain/nixos/virtualhosts.nix index 03cf25b5..fb77bd95 100644 --- a/hosts/samhain/nixos/virtualhosts.nix +++ b/hosts/samhain/nixos/virtualhosts.nix @@ -19,6 +19,7 @@ with lib; proxy_set_header Connection "upgrade"; ''; }; + "/tvheadend/".proxyPass = "http://192.168.1.245:9981"; "/" = { root = "/mnt/zraw/media/"; extraConfig = "autoindex on;"; diff --git a/pkgs/default.nix b/pkgs/default.nix index fece3fca..90f5e111 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -51,6 +51,8 @@ let obs-studio = super.obs-studio.override { pipewireSupport = true; }; + libreelec-dvb-firmware = self.callPackage ./libreelec-dvb-firmware { }; + hextorgba = (import ../lib/colorhelpers.nix { inherit (super) lib; }).hextorgba; diff --git a/pkgs/libreelec-dvb-firmware/default.nix b/pkgs/libreelec-dvb-firmware/default.nix new file mode 100644 index 00000000..39caf669 --- /dev/null +++ b/pkgs/libreelec-dvb-firmware/default.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchFromGitHub, lib}: + +stdenv.mkDerivation rec { + name = "libreelec-fw-dvb"; + version = "1.4.2"; + + src = fetchFromGitHub { + repo = "dvb-firmware"; + owner = "LibreElec"; + rev = version; + sha256 = "1xnfl4gp6d81gpdp86v5xgcqiqz2nf1i43sb3a4i5jqs8kxcap2k"; + }; + + buildPhase = ""; + installPhase = '' + mkdir -p $out/lib + cp -rv firmware $out/lib/ + ''; + + meta = with lib; { + license = lib.licenses.unfreeRedistributableFirmware; + maintainers = with maintainers; [ kittywitch ]; + platforms = with platforms; linux; + }; +} +