summaryrefslogtreecommitdiffstats
path: root/lass/2configs
diff options
context:
space:
mode:
Diffstat (limited to 'lass/2configs')
-rw-r--r--lass/2configs/IM.nix2
-rw-r--r--lass/2configs/alacritty.nix13
-rw-r--r--lass/2configs/atuin-server.nix38
-rw-r--r--lass/2configs/baseX.nix69
-rw-r--r--lass/2configs/blue-host.nix2
-rw-r--r--lass/2configs/consul.nix43
-rw-r--r--lass/2configs/default.nix2
-rw-r--r--lass/2configs/et-server.nix7
-rw-r--r--lass/2configs/green-host.nix27
-rw-r--r--lass/2configs/libvirt.nix2
-rw-r--r--lass/2configs/mumble-reminder.nix107
-rw-r--r--lass/2configs/pipewire.nix2
-rw-r--r--lass/2configs/radio/default.nix250
-rw-r--r--lass/2configs/radio/news.nix3
-rw-r--r--lass/2configs/radio/radio.liq112
-rw-r--r--lass/2configs/radio/shell.nix7
-rw-r--r--lass/2configs/radio/weather.nix6
-rw-r--r--lass/2configs/radio/weather_for_ips.py5
-rw-r--r--lass/2configs/red-host.nix167
-rw-r--r--lass/2configs/websites/util.nix2
-rw-r--r--lass/2configs/weechat.nix221
-rw-r--r--lass/2configs/xmonad.nix14
-rw-r--r--lass/2configs/zsh.nix52
23 files changed, 894 insertions, 259 deletions
diff --git a/lass/2configs/IM.nix b/lass/2configs/IM.nix
index 8567def02..8db2a05d6 100644
--- a/lass/2configs/IM.nix
+++ b/lass/2configs/IM.nix
@@ -24,7 +24,7 @@ in {
restartIfChanged = false;
path = [
- pkgs.rxvt_unicode.terminfo
+ pkgs.rxvt-unicode-unwrapped.terminfo
];
serviceConfig = {
diff --git a/lass/2configs/alacritty.nix b/lass/2configs/alacritty.nix
index 903ddf6cc..e5e001a4c 100644
--- a/lass/2configs/alacritty.nix
+++ b/lass/2configs/alacritty.nix
@@ -1,21 +1,23 @@
{ config, lib, pkgs, ... }: let
alacritty-cfg = extrVals: builtins.toJSON ({
- font = {
+ font = let
+ family = "Iosevka";
+ in {
normal = {
- family = "Inconsolata";
+ family = family;
style = "Regular";
};
bold = {
- family = "Inconsolata";
+ family = family;
style = "Bold";
};
italic = {
- family = "Inconsolata";
+ family = family;
style = "Italic";
};
bold_italic = {
- family = "Inconsolata";
+ family = family;
style = "Bold Italic";
};
size = 8;
@@ -44,6 +46,7 @@
name = "alacritty";
paths = [
(pkgs.writeDashBin "alacritty" ''
+ ${pkgs.alacritty}/bin/alacritty --config-file /var/theme/config/alacritty.yaml msg create-window "$@" ||
${pkgs.alacritty}/bin/alacritty --config-file /var/theme/config/alacritty.yaml "$@"
'')
pkgs.alacritty
diff --git a/lass/2configs/atuin-server.nix b/lass/2configs/atuin-server.nix
new file mode 100644
index 000000000..ad959a311
--- /dev/null
+++ b/lass/2configs/atuin-server.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, ... }:
+{
+ services.postgresql = {
+ enable = true;
+ dataDir = "/var/state/postgresql/${config.services.postgresql.package.psqlSchema}";
+ ensureDatabases = [ "atuin" ];
+ ensureUsers = [{
+ name = "atuin";
+ ensurePermissions."DATABASE atuin" = "ALL PRIVILEGES";
+ }];
+ };
+ systemd.tmpfiles.rules = [
+ "d /var/state/postgresql 0700 postgres postgres -"
+ ];
+ users.groups.atuin = {};
+ users.users.atuin = {
+ uid = pkgs.stockholm.lib.genid_uint31 "atuin";
+ isSystemUser = true;
+ group = "atuin";
+ home = "/run/atuin";
+ createHome = true;
+ };
+
+ systemd.services.atuin = {
+ wantedBy = [ "multi-user.target" ];
+ environment = {
+ ATUIN_HOST = "0.0.0.0";
+ ATUIN_PORT = "8888";
+ ATUIN_OPEN_REGISTRATION = "true";
+ ATUIN_DB_URI = "postgres:///atuin";
+ };
+ serviceConfig = {
+ User = "atuin";
+ ExecStart = "${pkgs.atuin}/bin/atuin server start";
+ };
+ };
+ networking.firewall.allowedTCPPorts = [ 8888 ];
+}
diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix
index e94cbbd2c..efd6c8a24 100644
--- a/lass/2configs/baseX.nix
+++ b/lass/2configs/baseX.nix
@@ -7,7 +7,6 @@ in {
./alacritty.nix
./mpv.nix
./power-action.nix
- ./copyq.nix
./urxvt.nix
./xdg-open.nix
./yubikey.nix
@@ -78,9 +77,10 @@ in {
pavucontrol
ponymix
powertop
- rxvt_unicode-with-plugins
+ rxvt-unicode
sshvnc
sxiv
+ nsxiv
taskwarrior
termite
transgui
@@ -105,10 +105,55 @@ in {
enableGhostscriptFonts = true;
fonts = with pkgs; [
- hack-font
xorg.fontschumachermisc
- terminus_font_ttf
inconsolata
+ noto-fonts
+ (iosevka.override {
+ # https://typeof.net/Iosevka/customizer
+ privateBuildPlan = {
+ family = "Iosevka";
+ spacing = "term";
+ serifs = "slab";
+ no-ligation = true;
+
+ variants.design = {
+ capital-j = "serifless";
+ a = "double-storey-tailed";
+ b = "toothless-corner";
+ d = "toothless-corner-serifless";
+ f = "flat-hook-tailed";
+ g = "earless-corner";
+ i = "hooky";
+ j = "serifless";
+ l = "tailed";
+
+ m = "earless-corner-double-arch";
+ n = "earless-corner-straight";
+ p = "earless-corner";
+ q = "earless-corner";
+ r = "earless-corner";
+ u = "toothless-rounded";
+ y = "cursive-flat-hook";
+
+ one = "no-base-long-top-serif";
+ two = "straight-neck";
+ three = "flat-top";
+ four = "open";
+ six = "open-contour";
+ seven = "straight-serifless";
+ eight = "two-circles";
+ nine = "open-contour";
+ tilde = "low";
+ asterisk = "hex-low";
+ number-sign = "upright";
+ at = "short";
+ dollar = "open";
+ percent = "dots";
+ question = "corner-flat-hooked";
+ };
+ };
+ set = "kookiefonts";
+ })
];
};
@@ -174,4 +219,20 @@ in {
'';
};
};
+
+ services.clipmenu.enable = true;
+
+ # synchronize all the clipboards
+ systemd.user.services.autocutsel = {
+ enable = true;
+ wantedBy = [ "graphical-session.target" ];
+ after = [ "graphical-session.target" ];
+ serviceConfig = {
+ Type = "forking";
+ ExecStart = pkgs.writers.writeDash "autocutsel" ''
+ ${pkgs.autocutsel}/bin/autocutsel -fork -selection PRIMARY
+ ${pkgs.autocutsel}/bin/autocutsel -fork -selection CLIPBOARD
+ '';
+ };
+ };
}
diff --git a/lass/2configs/blue-host.nix b/lass/2configs/blue-host.nix
index 7aabf0931..532e55fe5 100644
--- a/lass/2configs/blue-host.nix
+++ b/lass/2configs/blue-host.nix
@@ -34,7 +34,7 @@ in {
config = { ... }: {
environment.systemPackages = [
pkgs.git
- pkgs.rxvt_unicode.terminfo
+ pkgs.rxvt-unicode-unwrapped.terminfo
];
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [
diff --git a/lass/2configs/consul.nix b/lass/2configs/consul.nix
new file mode 100644
index 000000000..b8d925de5
--- /dev/null
+++ b/lass/2configs/consul.nix
@@ -0,0 +1,43 @@
+{ config, lib, pkgs, ... }:
+{
+ services.consul = {
+ enable = true;
+ # dropPrivileges = false;
+ webUi = true;
+ # interface.bind = "retiolum";
+ extraConfig = {
+ bind_addr = config.krebs.build.host.nets.retiolum.ip4.addr;
+ bootstrap_expect = 3;
+ server = true;
+ # retry_join = config.services.consul.extraConfig.start_join;
+ retry_join = lib.mapAttrsToList (n: h:
+ lib.head h.nets.retiolum.aliases
+ ) (lib.filterAttrs (n: h: h.consul) config.krebs.hosts);
+ rejoin_after_leave = true;
+
+ # try to fix random lock loss on leader reelection
+ retry_interval = "3s";
+ performance = {
+ raft_multiplier = 8;
+ };
+ };
+ };
+
+ environment.etc."consul.d/testservice.json".text = builtins.toJSON {
+ service = {
+ name = "testing";
+ };
+ };
+
+ krebs.iptables.tables.filter.INPUT.rules = [
+ { predicate = "-i retiolum -p tcp --dport 8300"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p tcp --dport 8301"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p udp --dport 8301"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p tcp --dport 8302"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p udp --dport 8302"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p tcp --dport 8400"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p tcp --dport 8500"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p tcp --dport 8600"; target = "ACCEPT"; }
+ { predicate = "-i retiolum -p udp --dport 8500"; target = "ACCEPT"; }
+ ];
+}
diff --git a/lass/2configs/default.nix b/lass/2configs/default.nix
index e8ac55988..49a04e9c2 100644
--- a/lass/2configs/default.nix
+++ b/lass/2configs/default.nix
@@ -98,7 +98,7 @@ with import <stockholm/lib>;
jq
#style
- rxvt_unicode.terminfo
+ rxvt-unicode-unwrapped.terminfo
#monitoring tools
htop
diff --git a/lass/2configs/et-server.nix b/lass/2configs/et-server.nix
new file mode 100644
index 000000000..19961fb84
--- /dev/null
+++ b/lass/2configs/et-server.nix
@@ -0,0 +1,7 @@
+{ config, lib, pkgs, ... }:
+{
+ services.eternal-terminal = {
+ enable = true;
+ };
+ networking.firewall.allowedTCPPorts = [ config.services.eternal-terminal.port ];
+}
diff --git a/lass/2configs/green-host.nix b/lass/2configs/green-host.nix
index a83ed0544..1e41e8e02 100644
--- a/lass/2configs/green-host.nix
+++ b/lass/2configs/green-host.nix
@@ -2,32 +2,9 @@
{
imports = [
<stockholm/lass/2configs/container-networking.nix>
- <stockholm/lass/2configs/syncthing.nix>
];
- krebs.sync-containers.containers.green = {
- peers = [
- "echelon"
- "icarus"
- "littleT"
- "mors"
- "shodan"
- "skynet"
- "styx"
- ];
- hostIp = "10.233.2.15";
- localIp = "10.233.2.16";
- format = "ecryptfs";
- };
- services.borgbackup.jobs.sync-green = {
- encryption.mode = "none";
- paths = "/var/lib/sync-containers/green/ecryptfs";
- repo = "/var/lib/sync-containers/green/backup";
- compression = "auto,lzma";
- startAt = "daily";
- prune.keep = {
- daily = 7;
- weekly = 4;
- };
+ lass.sync-containers3.containers.green = {
+ sshKey = "${toString <secrets>}/green.sync.key";
};
}
diff --git a/lass/2configs/libvirt.nix b/lass/2configs/libvirt.nix
index 78d5ae0e9..d391e0d7b 100644
--- a/lass/2configs/libvirt.nix
+++ b/lass/2configs/libvirt.nix
@@ -1,8 +1,8 @@
{ config, lib, pkgs, ... }:
{
- users.users.mainUser.extraGroups = [ "libvirtd" ];
virtualisation.libvirtd.enable = true;
+ security.polkit.enable = true;
krebs.iptables.tables.filter.INPUT.rules = [
{ v6 = false; predicate = "-i virbr0 -p udp -m udp --dport 53"; target = "ACCEPT"; }
diff --git a/lass/2configs/mumble-reminder.nix b/lass/2configs/mumble-reminder.nix
new file mode 100644
index 000000000..fe75a96a6
--- /dev/null
+++ b/lass/2configs/mumble-reminder.nix
@@ -0,0 +1,107 @@
+{ config, lib, pkgs, ... }: let
+ write_to_irc = chan: pkgs.writeDash "write_to_irc" ''
+ ${pkgs.curl}/bin/curl -fsSv --unix-socket '${lib.removePrefix "unix:" config.krebs.reaktor2.mumble-reminder.API.listen}' http://z/ \
+ -H content-type:application/json \
+ -d "$(${pkgs.jq}/bin/jq -n \
+ --arg text "$1" '{
+ command:"PRIVMSG",
+ params:["${chan}",$text]
+ }'
+ )"
+ '';
+ animals = ''
+ Erdferkel
+ Paviane
+ Raupen
+ Australischen Wildhunde
+ Emus
+ Flundern
+ Gorillas
+ Kolibris
+ Schwarzfersenantilopen
+ Quallen
+ Kois
+ Faulaffen
+ Schraubenziegen
+ Nachtigalle
+ Okapis
+ Stachelschweine
+ Kurzschwanzkängurus
+ Waschbären
+ '';
+ systemPlugin = {
+ plugin = "system";
+ config = {
+ hooks.PRIVMSG = [
+ {
+ pattern = "^erriner mich$";
+ activate = "match";
+ command = {
+ filename = pkgs.writeDash "add_remind" ''
+ echo "$_from" >> /var/lib/reaktor2-mumble-reminder/users
+ sort /var/lib/reaktor2-mumble-reminder/users | uniq > /var/lib/reaktor2-mumble-reminder/users.tmp
+ mv /var/lib/reaktor2-mumble-reminder/users.tmp /var/lib/reaktor2-mumble-reminder/users
+ echo "Ich werde $_from in zukunft an das meetup errinern"
+ '';
+ };
+ }
+ {
+ pattern = "^nerv nicht$";
+ activate = "match";
+ command = {
+ filename = pkgs.writeDash "add_remind" ''
+ ${pkgs.gnused}/bin/sed -i "/$_from/d" /var/lib/reaktor2-mumble-reminder/users
+ echo "okok, Ich werde $_from nich mehr errinern"
+ '';
+ };
+ }
+ ];
+ };
+ };
+
+in {
+ krebs.reaktor2.mumble-reminder = {
+ hostname = "irc.hackint.org";
+ nick = "lassulus__";
+ API.listen = "unix:/var/lib/reaktor2-mumble-reminder/reaktor_hackint.sock";
+ plugins = [
+ {
+ plugin = "register";
+ config = {
+ channels = [
+ "#krebs"
+ "#nixos"
+ ];
+ };
+ }
+ systemPlugin
+ ];
+ port = "6697";
+ };
+ systemd.services.mumble-reminder-nixos = {
+ description = "weekly reminder for nixos mumble";
+ startAt = "Thu *-*-* 19:00:00 Europe/Berlin";
+ serviceConfig = {
+ ExecStart = pkgs.writers.writeDash "mumble_reminder" ''
+ animals='
+ ${animals}
+ '
+ ${write_to_irc "#nixos"} "Es ist Donnerstag meine $(echo "$animals" | grep -v '^$' | shuf -n1 )!"
+ ${write_to_irc "#nixos"} "kommt auf mumble://lassul.us"
+ '';
+ };
+ };
+ systemd.services.mumble-reminder-krebs = {
+ description = "weekly reminder for nixos mumble";
+ startAt = "Thu *-*-* 19:00:00 Europe/Berlin";
+ serviceConfig = {
+ ExecStart = pkgs.writers.writeDash "mumble_reminder" ''
+ animals='
+ ${animals}
+ '
+ ${write_to_irc "#krebs"} "Es ist Donnerstag meine $(echo "$animals" | grep -v '^$' | shuf -n1 )!"
+ ${write_to_irc "#krebs"} "$(cat /var/lib/reaktor2-mumble-reminder/users | ${pkgs.findutils}/bin/xargs echo) : mumble?"
+ '';
+ };
+ };
+}
diff --git a/lass/2configs/pipewire.nix b/lass/2configs/pipewire.nix
index f6ccd48d4..ec5a67b6e 100644
--- a/lass/2configs/pipewire.nix
+++ b/lass/2configs/pipewire.nix
@@ -9,7 +9,7 @@
};
environment.systemPackages = with pkgs; [
- alsaUtils
+ alsa-utils
pulseaudio
ponymix
];
diff --git a/lass/2configs/radio/default.nix b/lass/2configs/radio/default.nix
index 2f503eae9..dfb3d7e0b 100644
--- a/lass/2configs/radio/default.nix
+++ b/lass/2configs/radio/default.nix
@@ -1,85 +1,54 @@
-{ config, pkgs, ... }:
-with pkgs.stockholm.lib;
+{ config, pkgs, lib, ... }:
let
name = "radio";
music_dir = "/home/radio/music";
- add_random = pkgs.writeDashBin "add_random" ''
- ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" \
- | grep -Ev '/other/|/.graveyard/' \
- | grep '\.ogg$' \
- | shuf -n1 \
- | sed 's,${music_dir}/,,' \
- )"
- '';
-
- get_current_track_position = pkgs.writeDash "get_current_track_position" ''
- ${pkgs.mpc_cli}/bin/mpc status | ${pkgs.gawk}/bin/awk '/^\[playing\]/ { sub(/\/.+/,"",$3); split($3,a,/:/); print a[1]*60+a[2] }'
- '';
-
- skip_track = pkgs.writeBashBin "skip_track" ''
+ skip_track = pkgs.writers.writeBashBin "skip_track" ''
set -eu
- ${add_random}/bin/add_random
- 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 [[ "$current_track" =~ ^the_playlist/music/.* ]] && [ "$skip_count" -le 2 ]; then
- 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"
- else
- mkdir -p "$music_dir"/the_playlist/.graveyard/
- mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/.graveyard/
- echo killing: "$track_infos"
- fi
- ${pkgs.mpc_cli}/bin/mpc -q next
+ # TODO come up with new rating, without moving files
+ # current_track=$(${pkgs.curl}/bin/curl -fSs http://localhost:8002/current | ${pkgs.jq}/bin/jq -r .filename)
+ # track_infos=$(${print_current}/bin/print_current)
+ # skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$current_track" || echo 0)
+ # if [[ "$current_track" =~ .*/the_playlist/music/.* ]] && [ "$skip_count" -le 2 ]; then
+ # skip_count=$((skip_count+1))
+ # ${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$current_track"
+ # echo skipping: "$track_infos" skip_count: "$skip_count"
+ # else
+ # mkdir -p "$music_dir"/the_playlist/.graveyard/
+ # mv "$current_track" "$music_dir"/the_playlist/.graveyard/
+ # echo killing: "$track_infos"
+ # fi
+ ${pkgs.curl}/bin/curl -fSs -X POST http://localhost:8002/skip |
+ ${pkgs.jq}/bin/jq -r '.filename'
'';
good_track = pkgs.writeBashBin "good_track" ''
set -eu
- music_dir=${escapeShellArg music_dir}
- current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%)
+ current_track=$(${pkgs.curl}/bin/curl -fSs http://localhost:8002/current | ${pkgs.jq}/bin/jq -r .filename)
track_infos=$(${print_current}/bin/print_current)
- if [[ "$current_track" =~ ^the_playlist/music/.* ]]; then
- ${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$music_dir"/"$current_track"
- else
- mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/music/ || :
- fi
+ # TODO come up with new rating, without moving files
+ # if [[ "$current_track" =~ .*/the_playlist/music/.* ]]; then
+ # ${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$current_track"
+ # else
+ # mv "$current_track" "$music_dir"/the_playlist/music/ || :
+ # fi
echo good: "$track_infos"
'';
- track_youtube_link = pkgs.writeDash "track_youtube_link" ''
- ${pkgs.mpc_cli}/bin/mpc current -f %file% \
- | ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@https://www.youtube.com/watch?v=\1@'
- '';
-
print_current = pkgs.writeDashBin "print_current" ''
- echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \
- $(${track_youtube_link})"
- '';
-
- print_current_json = pkgs.writeDashBin "print_current_json" ''
- ${pkgs.jq}/bin/jq -n -c \
- --arg name "$(${pkgs.mpc_cli}/bin/mpc current)" \
- --arg artist "$(${pkgs.mpc_cli}/bin/mpc current -f %artist%)" \
- --arg title "$(${pkgs.mpc_cli}/bin/mpc current -f %title%)" \
- --arg filename "$(${pkgs.mpc_cli}/bin/mpc current -f %file%)" \
- --arg position "$(${get_current_track_position})" \
- --arg length "$(${pkgs.mpc_cli}/bin/mpc current -f %time%)" \
- --arg youtube "$(${track_youtube_link})" '{
- name: $name,
- artist: $artist,
- title: $title,
- filename: $filename,
- position: $position,
- length: $length,
- youtube: $youtube
- }'
+ file=$(${pkgs.curl}/bin/curl -fSs http://localhost:8002/current |
+ ${pkgs.jq}/bin/jq -r '.filename' |
+ ${pkgs.gnused}/bin/sed 's,^${music_dir},,'
+ )
+ link=$(${pkgs.curl}/bin/curl http://localhost:8002/current |
+ ${pkgs.jq}/bin/jq -r '.filename' |
+ ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@https://youtu.be/\1@'
+ )
+ echo "$file": "$link"
'';
set_irc_topic = pkgs.writeDash "set_irc_topic" ''
@@ -113,15 +82,14 @@ in {
users.users = {
"${name}" = rec {
inherit name;
- createHome = mkForce false;
+ createHome = lib.mkForce false;
group = name;
- uid = genid_uint31 name;
+ uid = pkgs.stockholm.lib.genid_uint31 name;
description = "radio manager";
home = "/home/${name}";
useDefaultShell = true;
openssh.authorizedKeys.keys = with config.krebs.users; [
lass.pubkey
- lass-mors.pubkey
];
};
};
@@ -131,50 +99,35 @@ in {
};
krebs.per-user.${name}.packages = with pkgs; [
- add_random
good_track
skip_track
print_current
- print_current_json
- ncmpcpp
- mpc_cli
];
- services.mpd = {
- enable = true;
- user = "radio";
- musicDirectory = "${music_dir}";
- dataDir = "/home/radio/state"; # TODO create this somwhere
- extraConfig = ''
- log_level "default"
- auto_update "yes"
- volume_normalization "yes"
-
- audio_output {
- type "httpd"
- name "raw radio"
- encoder "wave"
- port "7900"
- format "44100:16:2"
- always_on "yes" # prevent MPD from disconnecting all listeners when playback is stopped.
- tags "yes" # httpd supports sending tags to listening streams.
- }
- '';
+ services.liquidsoap.streams.radio = ./radio.liq;
+ systemd.services.radio = {
+ environment = {
+ RADIO_PORT = "8002";
+ HOOK_TRACK_CHANGE = pkgs.writers.writeDash "on_change" ''
+ set -xefu
+ LIMIT=1000 #how many tracks to keep in the history
+ HISTORY_FILE=/var/lib/radio/recent
+
+ listeners=$(${pkgs.curl}/bin/curl -fSs lassul.us:8000/status-json.xsl |
+ ${pkgs.jq}/bin/jq '[.icestats.source[].listeners] | add' || echo 0)
+ echo "$(${pkgs.coreutils}/bin/date -Is)" "$filename" | ${pkgs.coreutils}/bin/tee -a "$HISTORY_FILE"
+ echo "$(${pkgs.coreutils}/bin/tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE"
+ ${set_irc_topic} "playing: $filename listeners: $listeners"
+ '';
+ MUSIC = "${music_dir}/the_playlist";
+ ICECAST_HOST = "localhost";
+ };
+ path = [
+ pkgs.yt-dlp
+ ];
+ serviceConfig.User = lib.mkForce "radio";
};
- services.liquidsoap.streams.radio-news = pkgs.writeText "radio-news.liq" ''
- source = mksafe(input.http("http://localhost:7900/raw.wave"))
-
- output.icecast(mount = '/music.ogg', password = 'hackme', %vorbis(quality = 1), source)
- output.icecast(mount = '/music.mp3', password = 'hackme', %mp3.vbr(), source)
- output.icecast(mount = '/music.opus', password = 'hackme', %opus(bitrate = 96), source)
-
- extra_input = amplify(1.4, audio_to_stereo(input.harbor("live", port=1338)))
- o = smooth_add(normal = source, special = extra_input)
- output.icecast(mount = '/radio.ogg', password = 'hackme', %vorbis(quality = 1), o)
- output.icecast(mount = '/radio.mp3', password = 'hackme', %mp3.vbr(), o)
- output.icecast(mount = '/radio.opus', password = 'hackme', %opus(bitrate = 96), o)
- '';
services.icecast = {
enable = true;
hostname = "radio.lassul.us";
@@ -195,73 +148,8 @@ in {
};
};
- systemd.timers.radio = {
- description = "radio autoadder timer";
- wantedBy = [ "timers.target" ];
-
- timerConfig = {
- OnCalendar = "*:0/1";
- };
- };
-
- systemd.services.radio = let
- autoAdd = pkgs.writeDash "autoAdd" ''
- LIMIT=$1 #in seconds
-
- timeLeft () {
- playlistDuration=$(${pkgs.mpc_cli}/bin/mpc --format '%time%' playlist | ${pkgs.gawk}/bin/awk -F ':' 'BEGIN{t=0} {t+=$1*60+$2} END{print t}')
- currentTime=$(${get_current_track_position})
- expr ''${playlistDuration:-0} - ''${currentTime:-0}
- }
-
- if test $(timeLeft) -le $LIMIT; then
- ${add_random}/bin/add_random
- fi
- ${pkgs.mpc_cli}/bin/mpc play > /dev/null
- '';
- in {
- description = "radio playlist autoadder";
- after = [ "network.target" ];
-
- restartIfChanged = true;
-
- serviceConfig = {
- ExecStart = "${autoAdd} 150";
- };
- };
-
- systemd.services.radio-recent = let
- recentlyPlayed = pkgs.writeDash "recentlyPlayed" ''
- set -xefu
- LIMIT=1000 #how many tracks to keep in the history
- HISTORY_FILE=/var/lib/radio/recent
- while :; do
- ${pkgs.mpc_cli}/bin/mpc idle player > /dev/null
- ${pkgs.mpc_cli}/bin/mpc current -f %file%
- done | while read track; do
-
- listeners=$(${pkgs.curl}/bin/curl lassul.us:8000/status-json.xsl |
- ${pkgs.jq}/bin/jq '[.icestats.source[].listeners] | add')
- echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE"
- echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE"
- ${set_irc_topic} "playing: $track listeners: $listeners"
- done
- '';
- in {
- description = "radio recently played";
- after = [ "mpd.service" "network.target" ];
- wantedBy = [ "multi-user.target" ];
-
- restartIfChanged = true;
-
- serviceConfig = {
- ExecStart = recentlyPlayed;
- User = "radio";
- };
- };
-
# allow reaktor2 to modify files
- systemd.services."reaktor2-the_playlist".serviceConfig.DynamicUser = mkForce false;
+ systemd.services."reaktor2-the_playlist".serviceConfig.DynamicUser = lib.mkForce false;
krebs.reaktor2.the_playlist = {
hostname = "irc.hackint.org";
@@ -300,6 +188,12 @@ in {
like.filename = "${good_track}/bin/good_track";
current.filename = "${print_current}/bin/print_current";
+ wish.filename = pkgs.writeDash "wish" ''
+ echo "youtube-dl:$1" | ${pkgs.curl}/bin/curl -fSs http://localhost:8002/wish -d @- > /dev/null
+ '';
+ wishlist.filename = pkgs.writeDash "wishlist" ''
+ ${pkgs.curl}/bin/curl -fSs http://localhost:8002/wish | ${pkgs.jq}/bin/jq -r '.[]'
+ '';
suggest.filename = pkgs.writeDash "suggest" ''
echo "$@" >> playlist_suggest
'';
@@ -316,15 +210,8 @@ in {
user = {
name = "radio";
};
- script = ''. ${pkgs.writeDash "radio" ''
+ scriptFile = pkgs.writeDash "radio" ''
case "$Method $Request_URI" in
- "GET /current")
- printf 'HTTP/1.1 200 OK\r\n'
- printf 'Connection: close\r\n'
- printf '\r\n'
- ${print_current_json}/bin/print_current_json
- exit
- ;;
"POST /skip")
printf 'HTTP/1.1 200 OK\r\n'
printf 'Connection: close\r\n'
@@ -344,7 +231,7 @@ in {
exit
;;
esac
- ''}'';
+ '';
};
services.nginx = {
@@ -365,7 +252,7 @@ in {
alias /var/lib/radio/recent;
'';
locations."= /current".extraConfig = ''
- proxy_pass http://localhost:8001;
+ proxy_pass http://localhost:8002;
'';
locations."= /skip".extraConfig = ''
proxy_pass http://localhost:8001;
@@ -375,10 +262,11 @@ in {
'';
locations."= /radio.sh".alias = pkgs.writeScript "radio.sh" ''
#!/bin/sh
+ trap 'exit 0' EXIT
while sleep 1; do
mpv \
--cache-secs=0 --demuxer-readahead-secs=0 --untimed --cache-pause=no \
- 'http://lassul.us:8000/radio.opus'
+ 'http://lassul.us:8000/radio.ogg'
done
'';
locations."= /controls".extraConfig = ''
diff --git a/lass/2configs/radio/news.nix b/lass/2configs/radio/news.nix
index e5b5405ff..0dc711e6c 100644
--- a/lass/2configs/radio/news.nix
+++ b/lass/2configs/radio/news.nix
<