This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 2configs / home-media.nix
3.1 kB 105 lines
1{ self, pkgs, ... }: 2{ 3 imports = [ 4 ]; 5 users.users.media = { 6 isNormalUser = true; 7 uid = self.inputs.stockholm.lib.genid_uint31 "media"; 8 extraGroups = [ 9 "video" 10 "audio" 11 "pipewire" 12 ]; 13 packages = [ 14 (pkgs.writers.writeDashBin "mpv" '' 15 if test -e "$1"; then 16 mpv-ipc-cli loadfile "$(realpath "$1")" 17 else 18 mpv-ipc-cli loadfile "$1" 19 fi 20 '') 21 ]; 22 }; 23 24 users.users.mainUser.packages = [ 25 (pkgs.writers.writeDashBin "mpv" '' 26 if test -e "$1"; then 27 mpv-ipc-cli loadfile "$(realpath "$1")" 28 else 29 mpv-ipc-cli loadfile "$1" 30 fi 31 '') 32 ]; 33 34 services.xserver.displayManager.autoLogin = { 35 enable = true; 36 user = "media"; 37 }; 38 39 hardware.pulseaudio.configFile = pkgs.writeText "pulse.pa" '' 40 .include ${pkgs.pulseaudioFull}/etc/pulse/default.pa 41 load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;10.42.0.0/24 auth-anonymous=1 42 ''; 43 44 environment.systemPackages = [ 45 (pkgs.writers.writeDashBin "mpv-ipc-cli" '' 46 set -efux 47 ${pkgs.jq}/bin/jq -nc '{ "command": $ARGS.positional }' --args "$@" | ${pkgs.socat}/bin/socat - /tmp/mpv.ipc 48 '') 49 (pkgs.writers.writeDashBin "ipc-mpv" '' 50 /run/current-system/sw/bin/mpv \ 51 --audio-display=no --audio-channels=stereo \ 52 --audio-samplerate=48000 --audio-format=s16 \ 53 --ao-pcm-file=/run/snapserver/snapfifo --ao=pcm \ 54 --audio-delay=-1 \ 55 "$@" 56 '') 57 pkgs.mpvc 58 (pkgs.writers.writeDashBin "iptv" '' 59 curl -Ssf 'https://iptv-org.github.io/iptv/index.nsfw.m3u' | 60 sed 's/.*,//' | 61 sed -z 's/\nhttp/,http/g' | 62 fzf --bind='enter:execute(echo {} | cut -d ',' -f 2 | xargs -0 mpv-ipc-cli loadfile)' 63 '') 64 ]; 65 66 environment.variables.SOCKET = "/tmp/mpv.ipc"; 67 systemd.services.mpvd = { 68 wantedBy = [ "multi-user.target" ]; 69 environment.DISPLAY = ":0"; 70 serviceConfig = { 71 User = "media"; 72 RemainAfterExit = true; 73 Nice = "-10"; 74 ExecStart = '' 75 ${pkgs.tmux}/bin/tmux -2 new-session -d -s mpvd -- /run/current-system/sw/bin/ipc-mpv \ 76 --audio-display=no --audio-channels=stereo \ 77 --audio-samplerate=48000 --audio-format=s16 \ 78 --ao-pcm-file=/run/snapserver/snapfifo --ao=pcm \ 79 --audio-delay=-1 \ 80 --network-timeout=3 \ 81 --untimed --cache-pause=no \ 82 --idle=yes --force-window=yes \ 83 --loop-playlist=inf \ 84 --input-ipc-server=/tmp/mpv.ipc 85 ''; 86 ExecStop = "${pkgs.tmux}/bin/tmux kill-session -t mpvd"; 87 ExecStartPre = [ 88 "+${pkgs.writers.writeDash "remove_socket" '' 89 set -efux 90 rm -f /tmp/mpv.ipc 91 ''}" 92 ]; 93 ExecStartPost = [ 94 "+${pkgs.writers.writeDash "fix_permissions" '' 95 set -efux 96 until test -e /tmp/mpv.ipc; do 97 sleep 1 98 done 99 # sleep 2 100 chmod 666 /tmp/mpv.ipc || : 101 ''}" 102 ]; 103 }; 104 }; 105}