summaryrefslogtreecommitdiffstats
path: root/lass/2configs
diff options
context:
space:
mode:
Diffstat (limited to 'lass/2configs')
-rw-r--r--lass/2configs/exim-smarthost.nix8
-rw-r--r--lass/2configs/games.nix2
-rw-r--r--lass/2configs/green-host.nix2
-rw-r--r--lass/2configs/mpv.nix76
-rw-r--r--lass/2configs/radio.nix31
-rw-r--r--lass/2configs/sync/decsync.nix4
-rw-r--r--lass/2configs/sync/weechat.nix2
-rw-r--r--lass/2configs/syncthing.nix16
-rw-r--r--lass/2configs/websites/domsen.nix6
9 files changed, 125 insertions, 22 deletions
diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix
index 56560863..08a226e6 100644
--- a/lass/2configs/exim-smarthost.nix
+++ b/lass/2configs/exim-smarthost.nix
@@ -102,6 +102,14 @@
"microsoft@lassul.us"
"stickers@lassul.us"
"nextbike@lassul.us"
+ "mytello@lassul.us"
+ "camp@lassul.us"
+ "urlwatch@lassul.us"
+ "lidl@lassul.us"
+ "geizhals@lassul.us"
+ "auschein@lassul.us"
+ "tleech@lassul.us"
+ "durstexpress@lassul.us"
];
in {
diff --git a/lass/2configs/games.nix b/lass/2configs/games.nix
index c0e6beba..63bfa53e 100644
--- a/lass/2configs/games.nix
+++ b/lass/2configs/games.nix
@@ -65,7 +65,7 @@ in {
createHome = true;
useDefaultShell = true;
packages = with pkgs; [
- minecraft
+ # minecraft
steam-run
scummvm
dolphinEmu
diff --git a/lass/2configs/green-host.nix b/lass/2configs/green-host.nix
index 1421eede..0cccbc30 100644
--- a/lass/2configs/green-host.nix
+++ b/lass/2configs/green-host.nix
@@ -20,7 +20,7 @@ with import <stockholm/lib>;
}
];
- krebs.syncthing.folders."/var/lib/sync-containers".peers = [ "icarus" "skynet" "littleT" "shodan" ];
+ services.syncthing.declarative.folders."/var/lib/sync-containers".devices = [ "icarus" "skynet" "littleT" "shodan" ];
krebs.permown."/var/lib/sync-containers" = {
owner = "root";
group = "syncthing";
diff --git a/lass/2configs/mpv.nix b/lass/2configs/mpv.nix
index b3de42c7..5d7bfed6 100644
--- a/lass/2configs/mpv.nix
+++ b/lass/2configs/mpv.nix
@@ -2,11 +2,85 @@
let
+ download_subs = pkgs.writers.writePython3 "download_sub" {
+ libraries = [ pkgs.python3Packages.subliminal ];
+ } ''
+ from subliminal import download_best_subtitles, scan_video
+ from babelfish import Language
+ import sys
+
+ video_filename = sys.argv[1]
+
+ vid = scan_video(video_filename)
+ try:
+ sub = download_best_subtitles([vid], {Language('eng')})[vid][0]
+
+ filename = '/tmp/' + vid.title + '.srt'
+
+ with open(filename, 'wb+') as file:
+ file.write(sub.content)
+
+ print(filename)
+ except: # noqa
+ print("/dev/null")
+ '';
+
+ autosub = pkgs.writeText "autosub.lua" ''
+ -- Requires Subliminal version 1.0 or newer
+ -- Make sure to specify your system's Subliminal location below:
+ local utils = require 'mp.utils'
+
+ -- Log function: log to both terminal and mpv OSD (On-Screen Display)
+ function log(string, secs)
+ secs = secs or 2 -- secs defaults to 2 when the secs parameter is absent
+ mp.msg.warn(string) -- This logs to the terminal
+ mp.osd_message(string, secs) -- This logs to mpv screen
+ end
+
+ function download()
+ log('Searching subtitles ...', 10)
+ table = { args = {"${download_subs}", mp.get_property('path')} }
+ result = utils.subprocess(table)
+ if result.error == nil then
+ -- remove trailing newline from subtitle filename
+ filename = string.gsub(result.stdout, "\n", "")
+ log(filename)
+ mp.commandv('sub_add', filename)
+ log('Subtitles ready!')
+ else
+ log('Subtitles failed downloading')
+ end
+ end
+
+ -- Control function: only download if necessary
+ function control_download()
+ duration = tonumber(mp.get_property('duration'))
+ if duration < 900 then
+ mp.msg.warn('Video is less than 15 minutes\n', '=> NOT downloading any subtitles')
+ return
+ end
+ -- There does not seem to be any documentation for the 'sub' property,
+ -- but it works on both internally encoded as well as external subtitle files!
+ -- -> sub = '1' when subtitles are present
+ -- -> sub = 'no' when subtitles are not present
+ -- -> sub = 'auto' when called before the 'file-loaded' event is triggered
+ sub = mp.get_property('sub')
+ if sub == '1' then
+ mp.msg.warn('Sub track is already present\n', '=> NOT downloading other subtitles')
+ return
+ end
+ mp.msg.warn('No sub track was detected\n', '=> Proceeding to download subtitles:')
+ download()
+ end
+
+ mp.add_key_binding('S', "download_subs", download)
+ '';
+
mpv = pkgs.symlinkJoin {
name = "mpv";
paths = [
(pkgs.writeDashBin "mpv" ''
- exec ${pkgs.mpv}/bin/mpv --no-config "$@"
+ exec ${pkgs.mpv}/bin/mpv --no-config --script=${autosub} "$@"
'')
pkgs.mpv
];
diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix
index b24d7af3..74b15a0a 100644
--- a/lass/2configs/radio.nix
+++ b/lass/2configs/radio.nix
@@ -9,13 +9,28 @@ let
admin-password = import <secrets/icecast-admin-pw>;
source-password = import <secrets/icecast-source-pw>;
+ music_dir = "/home/radio/music";
+
add_random = pkgs.writeDashBin "add_random" ''
${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.mpc_cli}/bin/mpc ls the_playlist/music | grep '\.ogg$' | shuf -n1)"
'';
skip_track = pkgs.writeDashBin "skip_track" ''
+ set -eu
+
${add_random}/bin/add_random
- echo skipping: "$(${print_current}/bin/print_current)"
+ music_dir=${escapeShellArg music_dir}
+ current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%)
+ track_infos=$(${print_current}/bin/print_current)
+ skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$music_dir"/"$current_track" || echo 0)
+ if [ "$skip_count" -gt 2 ]; then
+ mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/
+ echo killing: "$track_infos"
+ else
+ skip_count=$((skip_count+1))
+ ${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$music_dir"/"$current_track"
+ echo skipping: "$track_infos" skip_count: "$skip_count"
+ fi
${pkgs.mpc_cli}/bin/mpc -q next
'';
@@ -57,7 +72,7 @@ in {
services.mpd = {
enable = true;
group = "radio";
- musicDirectory = "/home/radio/music";
+ musicDirectory = "${music_dir}";
extraConfig = ''
log_level "default"
auto_update "yes"
@@ -178,11 +193,15 @@ in {
};
};
+ # allow reaktor2 to modify files
+ systemd.services."reaktor2-the_playlist".serviceConfig.DynamicUser = mkForce false;
+
krebs.reaktor2.the_playlist = {
hostname = "irc.freenode.org";
port = "6697";
useTLS = true;
nick = "the_playlist";
+ username = "radio";
plugins = [
{
plugin = "register";
@@ -199,8 +218,8 @@ in {
workdir = config.krebs.reaktor2.the_playlist.stateDir;
hooks.PRIVMSG = [
{
- #activate = "match";
- pattern = "^\\s*([0-9A-Za-z._][0-9A-Za-z._-]*)(?:\\s+(.*\\S))?\\s*$";
+ activate = "match";
+ pattern = "^(?:.*\\s)?\\s*the_playlist:\\s*([0-9A-Za-z._][0-9A-Za-z._-]*)(?:\\s+(.*\\S))?\\s*$";
command = 1;
arguments = [2];
commands = {
@@ -258,9 +277,9 @@ in {
alias ${html};
'';
};
- krebs.syncthing.folders."the_playlist" = {
+ services.syncthing.declarative.folders."the_playlist" = {
path = "/home/radio/music/the_playlist";
- peers = [ "mors" "phone" "prism" "xerxes" ];
+ devices = [ "mors" "phone" "prism" "xerxes" ];
};
krebs.permown."/home/radio/music/the_playlist" = {
owner = "radio";
diff --git a/lass/2configs/sync/decsync.nix b/lass/2configs/sync/decsync.nix
index c3f6511c..9caefdd2 100644
--- a/lass/2configs/sync/decsync.nix
+++ b/lass/2configs/sync/decsync.nix
@@ -1,7 +1,7 @@
{
- krebs.syncthing.folders.decsync = {
+ services.syncthing.declarative.folders.decsync = {
path = "/home/lass/decsync";
- peers = [ "mors" "blue" "green" "phone" ];
+ devices = [ "mors" "blue" "green" "phone" ];
};
krebs.permown."/home/lass/decsync" = {
owner = "lass";
diff --git a/lass/2configs/sync/weechat.nix b/lass/2configs/sync/weechat.nix
index 30c7b262..ccbfc75a 100644
--- a/lass/2configs/sync/weechat.nix
+++ b/lass/2configs/sync/weechat.nix
@@ -1,5 +1,5 @@
{
- krebs.syncthing.folders."/home/lass/.weechat".peers = [ "blue" "green" "mors" ];
+ services.syncthing.declarative.folders."/home/lass/.weechat".devices = [ "blue" "green" "mors" ];
krebs.permown."/home/lass/.weechat" = {
owner = "lass";
group = "syncthing";
diff --git a/lass/2configs/syncthing.nix b/lass/2configs/syncthing.nix
index d4df17b9..5397c2ca 100644
--- a/lass/2configs/syncthing.nix
+++ b/lass/2configs/syncthing.nix
@@ -7,18 +7,20 @@ in {
enable = true;
group = "syncthing";
configDir = "/var/lib/syncthing";
+ declarative = {
+ key = toString <secrets/syncthing.key>;
+ cert = toString <secrets/syncthing.cert>;
+ devices = mk_peers all_peers;
+ folders."/home/lass/sync" = {
+ devices = attrNames (filterAttrs (n: v: n != "phone") own_peers);
+ # ignorePerms = false;
+ };
+ };
};
krebs.iptables.tables.filter.INPUT.rules = [
{ predicate = "-p tcp --dport 22000"; target = "ACCEPT";}
{ predicate = "-p udp --dport 21027"; target = "ACCEPT";}
];
- krebs.syncthing = {
- enable = true;
- cert = toString <secrets/syncthing.cert>;
- key = toString <secrets/syncthing.key>;
- peers = mk_peers all_peers;
- folders."/home/lass/sync".peers = attrNames (filterAttrs (n: v: n != "phone") own_peers);
- };
system.activationScripts.syncthing-home = ''
${pkgs.coreutils}/bin/chmod a+x /home/lass
diff --git a/lass/2configs/websites/domsen.nix b/lass/2configs/websites/domsen.nix
index 80ed12ed..bd113567 100644
--- a/lass/2configs/websites/domsen.nix
+++ b/lass/2configs/websites/domsen.nix
@@ -270,14 +270,14 @@ in {
};
boot.kernel.sysctl."fs.inotify.max_user_watches" = "1048576";
- krebs.syncthing.folders = {
+ services.syncthing.declarative.folders = {
domsen-backups = {
path = "/backups/domsen";
- peers = [ "domsen-backup" ];
+ devices = [ "domsen-backup" ];
};
domsen-backup-srv-http = {
path = "/srv/http";
- peers = [ "domsen-backup" ];
+ devices = [ "domsen-backup" ];
};
};