diff --git a/.bin/toposort.nix b/.bin/toposort.nix index c8bbf43..4957aaa 100644 --- a/.bin/toposort.nix +++ b/.bin/toposort.nix @@ -1,50 +1,81 @@ let lib = import ; -in rec { +in +rec { inherit lib; input = [ { - x = ["pool" "zfs"]; - y = ["mdadm" "raid1"]; + x = [ + "pool" + "zfs" + ]; + y = [ + "mdadm" + "raid1" + ]; } { - x = ["pool" "zfs"]; - y = ["disk" "sda"]; + x = [ + "pool" + "zfs" + ]; + y = [ + "disk" + "sda" + ]; } { - x = ["mdadm" "raid1"]; - y = ["disk" "sdb"]; + x = [ + "mdadm" + "raid1" + ]; + y = [ + "disk" + "sdb" + ]; } { - x = ["mdadm" "raid1"]; - y = ["disk" "sdc"]; + x = [ + "mdadm" + "raid1" + ]; + y = [ + "disk" + "sdc" + ]; } ]; - outNodes = node: graph: - lib.unique - (builtins.map (e: e.y) - (builtins.filter (v: v.x == node) graph)); + outNodes = node: graph: lib.unique (builtins.map (e: e.y) (builtins.filter (v: v.x == node) graph)); - vertices = graph: - lib.unique - (builtins.map (x: x.y) graph ++ builtins.map (x: x.x) graph); + vertices = graph: lib.unique (builtins.map (x: x.y) graph ++ builtins.map (x: x.x) graph); deleteVertex = node: graph: (builtins.filter (v: v.x != node && v.y != node) graph); - findSink = graph: - lib.findFirst - (v: outNodes v graph == []) - (lib.trace graph (builtins.abort "No sink found")) - (vertices graph); + findSink = + graph: + lib.findFirst (v: outNodes v graph == [ ]) (lib.trace graph (builtins.abort "No sink found")) ( + vertices graph + ); - topSort = graph: - if graph == [] - then [] - else if builtins.length graph == 1 - then let only = builtins.head graph; in [only.y only.x] - else let sink = findSink graph; in [sink] ++ topSort (deleteVertex sink graph); + topSort = + graph: + if graph == [ ] then + [ ] + else if builtins.length graph == 1 then + let + only = builtins.head graph; + in + [ + only.y + only.x + ] + else + let + sink = findSink graph; + in + [ sink ] ++ topSort (deleteVertex sink graph); output = topSort input; } diff --git a/configs/admin-essentials.nix b/configs/admin-essentials.nix index aa6618d..74642da 100644 --- a/configs/admin-essentials.nix +++ b/configs/admin-essentials.nix @@ -2,71 +2,71 @@ pkgs, lib, ... -}: let +}: +let darwin = lib.strings.hasSuffix "-darwin" pkgs.stdenv.hostPlatform.system; -in { - environment.systemPackages = - [ - pkgs.htop - pkgs.w3m - pkgs.wget - # ARCHIVE TOOLS - pkgs.unzip - pkgs.unrar - pkgs.p7zip - pkgs.sshuttle - pkgs.zip - # MONITORS - pkgs.iftop # interface bandwidth monitor - pkgs.lsof # list open files - # SHELL - pkgs.sqlite - pkgs.fd # better find - pkgs.tree - pkgs.parallel # for parallel, since moreutils shadows task spooler - pkgs.ripgrep # better grep - pkgs.rlwrap - pkgs.progress # display progress bars for pipes - pkgs.file # determine file type - pkgs.gdu # ncurses disk usage (ncdu is broken) - pkgs.rmlint # remove duplicate files - pkgs.jq # json toolkit - pkgs.jless # less(1) for json - pkgs.fq # toolkit for yaml, xml and binaries - pkgs.bc # calculator - pkgs.pari # gp -- better calculator - pkgs.ts - pkgs.vimv - pkgs.vg - pkgs.fkill - pkgs.cyberlocker-tools - pkgs.untilport - pkgs.kpaste - # HARDWARE - pkgs.pciutils # for lspci - ] - ++ lib.optionals (!darwin) [ - pkgs.usbutils # for lsusb - pkgs.lshw # for lshw - pkgs.iotop # I/O load monitor - pkgs.psmisc # for killall, pstree - ]; +in +{ + environment.systemPackages = [ + pkgs.htop + pkgs.w3m + pkgs.wget + # ARCHIVE TOOLS + pkgs.unzip + pkgs.unrar + pkgs.p7zip + pkgs.sshuttle + pkgs.zip + # MONITORS + pkgs.iftop # interface bandwidth monitor + pkgs.lsof # list open files + # SHELL + pkgs.sqlite + pkgs.fd # better find + pkgs.tree + pkgs.parallel # for parallel, since moreutils shadows task spooler + pkgs.ripgrep # better grep + pkgs.rlwrap + pkgs.progress # display progress bars for pipes + pkgs.file # determine file type + pkgs.gdu # ncurses disk usage (ncdu is broken) + pkgs.rmlint # remove duplicate files + pkgs.jq # json toolkit + pkgs.jless # less(1) for json + pkgs.fq # toolkit for yaml, xml and binaries + pkgs.bc # calculator + pkgs.pari # gp -- better calculator + pkgs.ts + pkgs.vimv + pkgs.vg + pkgs.fkill + pkgs.cyberlocker-tools + pkgs.untilport + pkgs.kpaste + # HARDWARE + pkgs.pciutils # for lspci + ] + ++ lib.optionals (!darwin) [ + pkgs.usbutils # for lsusb + pkgs.lshw # for lshw + pkgs.iotop # I/O load monitor + pkgs.psmisc # for killall, pstree + ]; - - security.wrappers = { - pmount = { - setuid = true; - owner = "root"; - group = "root"; - source = "${pkgs.pmount}/bin/pmount"; - }; - pumount = { - setuid = true; - owner = "root"; - group = "root"; - source = "${pkgs.pmount}/bin/pumount"; - }; + security.wrappers = { + pmount = { + setuid = true; + owner = "root"; + group = "root"; + source = "${pkgs.pmount}/bin/pmount"; }; + pumount = { + setuid = true; + owner = "root"; + group = "root"; + source = "${pkgs.pmount}/bin/pumount"; + }; + }; environment.interactiveShellInit = '' # Use XDG_RUNTIME_DIR for temporary files if available @@ -75,21 +75,22 @@ in { fi ''; - environment.shellAliases = let - take = pkgs.writers.writeDash "take" '' - mkdir "$1" && cd "$1" - ''; - cdt = pkgs.writers.writeDash "cdt" '' - cd $(mktemp -p "$XDG_RUNTIME_DIR" -d "cdt-XXXXXX") - pwd - ''; - wcd = pkgs.writers.writeDash "wcd" '' - cd "$(readlink "$(${pkgs.which}/bin/which --skip-alias "$1")" | xargs dirname)/.." - ''; - where = pkgs.writers.writeDash "where" '' - readlink "$(${pkgs.which}/bin/which --skip-alias "$1")" | xargs dirname - ''; - in + environment.shellAliases = + let + take = pkgs.writers.writeDash "take" '' + mkdir "$1" && cd "$1" + ''; + cdt = pkgs.writers.writeDash "cdt" '' + cd $(mktemp -p "$XDG_RUNTIME_DIR" -d "cdt-XXXXXX") + pwd + ''; + wcd = pkgs.writers.writeDash "wcd" '' + cd "$(readlink "$(${pkgs.which}/bin/which --skip-alias "$1")" | xargs dirname)/.." + ''; + where = pkgs.writers.writeDash "where" '' + readlink "$(${pkgs.which}/bin/which --skip-alias "$1")" | xargs dirname + ''; + in { nixi = "nix repl nixpkgs"; take = "source ${take}"; @@ -110,16 +111,17 @@ in { la = "${pkgs.coreutils}/bin/ls --color=auto --time-style=long-iso --almost-all -l"; } // ( - if darwin - then {} - else { - "ß" = "${pkgs.util-linux}/bin/setsid"; - ip = "${pkgs.iproute2}/bin/ip -c"; - # systemd - s = "${pkgs.systemd}/bin/systemctl"; - us = "${pkgs.systemd}/bin/systemctl --user"; - j = "${pkgs.systemd}/bin/journalctl"; - uj = "${pkgs.systemd}/bin/journalctl --user"; - } + if darwin then + { } + else + { + "ß" = "${pkgs.util-linux}/bin/setsid"; + ip = "${pkgs.iproute2}/bin/ip -c"; + # systemd + s = "${pkgs.systemd}/bin/systemctl"; + us = "${pkgs.systemd}/bin/systemctl --user"; + j = "${pkgs.systemd}/bin/journalctl"; + uj = "${pkgs.systemd}/bin/journalctl --user"; + } ); } diff --git a/configs/alacritty.nix b/configs/alacritty.nix index 0baa9ec..696b57f 100644 --- a/configs/alacritty.nix +++ b/configs/alacritty.nix @@ -2,8 +2,10 @@ pkgs, lib, ... -}: let -in { +}: +let +in +{ environment.variables.TERMINAL = "alacritty"; home-manager.users.me = { diff --git a/configs/android.nix b/configs/android.nix index 898224d..2955822 100644 --- a/configs/android.nix +++ b/configs/android.nix @@ -1,5 +1,5 @@ { programs.adb.enable = true; - users.users.me.extraGroups = ["adbusers"]; + users.users.me.extraGroups = [ "adbusers" ]; } diff --git a/configs/bash.nix b/configs/bash.nix index 1aeb572..d542722 100644 --- a/configs/bash.nix +++ b/configs/bash.nix @@ -1,7 +1,7 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ programs.bash = { - promptInit = '' - PS1="$(${pkgs.ncurses}/bin/tput bold)\w \$([[ \$? == 0 ]] && echo \"\[\033[1;32m\]\" || echo \"\[\033[1;31m\]\")\$$(${pkgs.ncurses}/bin/tput sgr0) "''; + promptInit = ''PS1="$(${pkgs.ncurses}/bin/tput bold)\w \$([[ \$? == 0 ]] && echo \"\[\033[1;32m\]\" || echo \"\[\033[1;31m\]\")\$$(${pkgs.ncurses}/bin/tput sgr0) "''; interactiveShellInit = '' set -o vi ''; diff --git a/configs/bluetooth.nix b/configs/bluetooth.nix index 8d2a18f..f5abf1e 100644 --- a/configs/bluetooth.nix +++ b/configs/bluetooth.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ hardware.bluetooth = { enable = true; settings.general = { diff --git a/configs/bots/autorenkalender.nix b/configs/bots/autorenkalender.nix index bf90abf..6da7b04 100644 --- a/configs/bots/autorenkalender.nix +++ b/configs/bots/autorenkalender.nix @@ -2,16 +2,18 @@ config, inputs, ... -}: let +}: +let autorenkalender = inputs.autorenkalender.packages.x86_64-linux.default; -in { +in +{ niveum.bots.autorenkalender = { enable = true; time = "07:00"; telegram = { enable = true; tokenFile = config.age.secrets.telegram-token-kmein.path; - chatIds = ["@autorenkalender"]; + chatIds = [ "@autorenkalender" ]; parseMode = "Markdown"; }; command = "${autorenkalender}/bin/autorenkalender"; diff --git a/configs/bots/celan.nix b/configs/bots/celan.nix index 2af5d27..b82d100 100644 --- a/configs/bots/celan.nix +++ b/configs/bots/celan.nix @@ -3,64 +3,69 @@ lib, config, ... -}: { +}: +{ niveum.bots.celan = { enable = true; time = "08:00"; telegram = { enable = true; tokenFile = config.age.secrets.telegram-token-kmein.path; - chatIds = ["@PaulCelan"]; + chatIds = [ "@PaulCelan" ]; }; mastodon = { enable = true; tokenFile = config.age.secrets.mastodon-token-celan.path; language = "de"; }; - command = toString (pkgs.writers.writePython3 "random-celan.py" { libraries = [pkgs.python3Packages.lxml]; } '' - from lxml import etree - import random + command = toString ( + pkgs.writers.writePython3 "random-celan.py" { libraries = [ pkgs.python3Packages.lxml ]; } '' + from lxml import etree + import random - def xml_text(elements): - return "".join("".join(t.itertext()) for t in elements).strip() + def xml_text(elements): + return "".join("".join(t.itertext()) for t in elements).strip() - tree = etree.parse('${pkgs.fetchurl { - url = "http://c.krebsco.de/celan.tei.xml"; - hash = "sha256-HgNmJYfhuwyfm+FcNtnnYWpJpIIU1ElHLeLiIFjF9mE="; - }}') - root = tree.getroot() + tree = etree.parse('${ + pkgs.fetchurl { + url = "http://c.krebsco.de/celan.tei.xml"; + hash = "sha256-HgNmJYfhuwyfm+FcNtnnYWpJpIIU1ElHLeLiIFjF9mE="; + } + }') + root = tree.getroot() - tei = {"tei": "http://www.tei-c.org/ns/1.0"} + tei = {"tei": "http://www.tei-c.org/ns/1.0"} - poems = root.xpath(".//tei:lg[@type='poem']", namespaces=tei) + poems = root.xpath(".//tei:lg[@type='poem']", namespaces=tei) - poem = random.choice(poems) + poem = random.choice(poems) - for stanza in poem.xpath("./tei:lg[@type='stanza']", namespaces=tei): - for line in stanza.xpath('./tei:l', namespaces=tei): - if line.text: - print(line.text.strip()) - print() + for stanza in poem.xpath("./tei:lg[@type='stanza']", namespaces=tei): + for line in stanza.xpath('./tei:l', namespaces=tei): + if line.text: + print(line.text.strip()) + print() - current_element = poem - while current_element is not None: - if current_element.tag == "{http://www.tei-c.org/ns/1.0}text": - text_element = current_element + current_element = poem + while current_element is not None: + if current_element.tag == "{http://www.tei-c.org/ns/1.0}text": + text_element = current_element - title = xml_text(text_element.xpath("./tei:front/tei:docTitle", - namespaces=tei)) - print(f"Aus: #{title.replace(" ", "_")}", end=" ") + title = xml_text(text_element.xpath("./tei:front/tei:docTitle", + namespaces=tei)) + print(f"Aus: #{title.replace(" ", "_")}", end=" ") - if date := xml_text(text_element.xpath("./tei:front/tei:docDate", - namespaces=tei)): - print(f"({date})") - break - current_element = current_element.getparent() + if date := xml_text(text_element.xpath("./tei:front/tei:docDate", + namespaces=tei)): + print(f"({date})") + break + current_element = current_element.getparent() - print("\n\n#PaulCelan #Celan #Lyrik #poetry") - ''); + print("\n\n#PaulCelan #Celan #Lyrik #poetry") + '' + ); }; age.secrets = { diff --git a/configs/bots/default.nix b/configs/bots/default.nix index 177e0f4..29be346 100644 --- a/configs/bots/default.nix +++ b/configs/bots/default.nix @@ -4,11 +4,13 @@ lib, inputs, ... -}: let +}: +let telebots = inputs.telebots.defaultPackage.x86_64-linux; reverseDirectory = "/run/telegram-reverse"; proverbDirectory = "/run/telegram-proverb"; -in { +in +{ imports = [ ./logotheca.nix ./transits.nix @@ -25,13 +27,21 @@ in { telegram-token-kmein.file = ../../secrets/telegram-token-kmein.age; }; - systemd.tmpfiles.rules = map (path: - pkgs.lib.niveum.tmpfilesConfig { - type = "d"; - mode = "0750"; - age = "1h"; - inherit path; - }) [reverseDirectory proverbDirectory]; + systemd.tmpfiles.rules = + map + ( + path: + pkgs.lib.niveum.tmpfilesConfig { + type = "d"; + mode = "0750"; + age = "1h"; + inherit path; + } + ) + [ + reverseDirectory + proverbDirectory + ]; niveum.passport.services = [ { @@ -59,9 +69,9 @@ in { }; systemd.services.telegram-reverse = { - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; description = "Telegram reverse bot"; - path = [pkgs.ffmpeg]; + path = [ pkgs.ffmpeg ]; enable = true; script = '' TELEGRAM_BOT_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/token")" ${telebots}/bin/telegram-reverse @@ -72,7 +82,7 @@ in { }; systemd.services.telegram-streaming-link = { - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; description = "Telegram bot converting YouTube Music <-> Spotify"; enable = true; script = '' @@ -83,7 +93,7 @@ in { }; systemd.services.telegram-betacode = { - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; description = "Telegram beta code bot"; enable = true; script = '' @@ -94,7 +104,7 @@ in { }; systemd.services.telegram-proverb = { - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; description = "Telegram proverb bot"; enable = true; script = '' diff --git a/configs/bots/hesychius.nix b/configs/bots/hesychius.nix index 8406dd7..3677d82 100644 --- a/configs/bots/hesychius.nix +++ b/configs/bots/hesychius.nix @@ -4,9 +4,11 @@ inputs, lib, ... -}: let +}: +let hesychius = inputs.scripts.outPath + "/hesychius/hesychius.txt"; -in { +in +{ niveum.bots.hesychius = { enable = true; time = "08:00"; @@ -18,7 +20,7 @@ in { telegram = { enable = true; tokenFile = config.age.secrets.telegram-token-kmein.path; - chatIds = ["@HesychiosAlexandreus"]; + chatIds = [ "@HesychiosAlexandreus" ]; }; command = "${pkgs.coreutils}/bin/shuf -n1 ${hesychius}"; }; diff --git a/configs/bots/logotheca.nix b/configs/bots/logotheca.nix index db25bf3..032abb4 100644 --- a/configs/bots/logotheca.nix +++ b/configs/bots/logotheca.nix @@ -2,14 +2,15 @@ pkgs, config, ... -}: { +}: +{ niveum.bots.logotheca = { enable = true; time = "08/6:00"; telegram = { enable = true; tokenFile = config.age.secrets.telegram-token-kmein.path; - chatIds = ["-1001760262519"]; + chatIds = [ "-1001760262519" ]; parseMode = "Markdown"; }; matrix = { diff --git a/configs/bots/nachtischsatan.nix b/configs/bots/nachtischsatan.nix index 86dc987..f36cef8 100644 --- a/configs/bots/nachtischsatan.nix +++ b/configs/bots/nachtischsatan.nix @@ -3,31 +3,36 @@ config, lib, ... -}: let - nachtischsatan-bot = {tokenFile}: - pkgs.writers.writePython3 "nachtischsatan-bot" { - libraries = [pkgs.python3Packages.python-telegram-bot]; - } '' - from telegram.ext import Application, ContextTypes, MessageHandler, filters - from telegram import Update - import random - import time +}: +let + nachtischsatan-bot = + { tokenFile }: + pkgs.writers.writePython3 "nachtischsatan-bot" + { + libraries = [ pkgs.python3Packages.python-telegram-bot ]; + } + '' + from telegram.ext import Application, ContextTypes, MessageHandler, filters + from telegram import Update + import random + import time - async def flubber(update: Update, context: ContextTypes.DEFAULT_TYPE): - time.sleep(random.randrange(4000) / 1000) - await update.message.reply_text("*flubberflubber*") + async def flubber(update: Update, context: ContextTypes.DEFAULT_TYPE): + time.sleep(random.randrange(4000) / 1000) + await update.message.reply_text("*flubberflubber*") - with open('${tokenFile}', 'r') as tokenFile: - token = tokenFile.read().strip() - application = Application.builder().token(token).build() - application.add_handler(MessageHandler(filters.ALL, flubber)) - application.run_polling() - ''; -in { + with open('${tokenFile}', 'r') as tokenFile: + token = tokenFile.read().strip() + application = Application.builder().token(token).build() + application.add_handler(MessageHandler(filters.ALL, flubber)) + application.run_polling() + ''; +in +{ systemd.services.telegram-nachtischsatan = { - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; description = "*flubberflubber*"; enable = true; script = toString (nachtischsatan-bot { diff --git a/configs/bots/nietzsche.nix b/configs/bots/nietzsche.nix index f94a59e..d18f6cc 100644 --- a/configs/bots/nietzsche.nix +++ b/configs/bots/nietzsche.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ niveum.bots.nietzsche = { enable = true; time = "08:00"; @@ -11,15 +12,17 @@ tokenFile = config.age.secrets.mastodon-token-nietzsche.path; language = "de"; }; - command = toString (pkgs.writers.writeBash "random-nietzsche" '' - set -efu - random_number=$(( ($RANDOM % 10) + 1 )) - if [ "$random_number" -eq 1 ]; then - ${pkgs.random-zeno}/bin/random-zeno "/Literatur/M/Nietzsche,+Friedrich" - else - ${pkgs.random-zeno}/bin/random-zeno "/Philosophie/M/Nietzsche,+Friedrich" - fi - ''); + command = toString ( + pkgs.writers.writeBash "random-nietzsche" '' + set -efu + random_number=$(( ($RANDOM % 10) + 1 )) + if [ "$random_number" -eq 1 ]; then + ${pkgs.random-zeno}/bin/random-zeno "/Literatur/M/Nietzsche,+Friedrich" + else + ${pkgs.random-zeno}/bin/random-zeno "/Philosophie/M/Nietzsche,+Friedrich" + fi + '' + ); }; systemd.timers.bot-nietzsche.timerConfig.RandomizedDelaySec = "10h"; diff --git a/configs/bots/smyth.nix b/configs/bots/smyth.nix index 1a526c6..aa2813b 100644 --- a/configs/bots/smyth.nix +++ b/configs/bots/smyth.nix @@ -3,7 +3,8 @@ pkgs, lib, ... -}: { +}: +{ niveum.bots.smyth = { enable = true; time = "08:00"; @@ -15,42 +16,44 @@ telegram = { enable = true; tokenFile = config.age.secrets.telegram-token-kmein.path; - chatIds = ["@HerbertWeirSmyth"]; + chatIds = [ "@HerbertWeirSmyth" ]; }; - command = toString (pkgs.writers.writeDash "random-smyth" '' - set -efu + command = toString ( + pkgs.writers.writeDash "random-smyth" '' + set -efu - good_curl() { - ${pkgs.curl}/bin/curl "$@" \ - --compressed \ - -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ - -H 'Accept-Language: en-US,en;q=0.5' \ - -H 'DNT: 1' \ - -H 'Connection: keep-alive' \ - -H 'Upgrade-Insecure-Requests: 1' \ - -H 'Sec-Fetch-Dest: document' \ - -H 'Sec-Fetch-Mode: navigate' \ - -H 'Sec-Fetch-Site: cross-site' \ - -H 'Priority: u=0, i' \ - -H 'Pragma: no-cache' \ - -H 'Cache-Control: no-cache' - } + good_curl() { + ${pkgs.curl}/bin/curl "$@" \ + --compressed \ + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ + -H 'Accept-Language: en-US,en;q=0.5' \ + -H 'DNT: 1' \ + -H 'Connection: keep-alive' \ + -H 'Upgrade-Insecure-Requests: 1' \ + -H 'Sec-Fetch-Dest: document' \ + -H 'Sec-Fetch-Mode: navigate' \ + -H 'Sec-Fetch-Site: cross-site' \ + -H 'Priority: u=0, i' \ + -H 'Pragma: no-cache' \ + -H 'Cache-Control: no-cache' + } - RANDOM_SECTION=$( - good_curl -sSL http://www.perseus.tufts.edu/hopper/xmltoc?doc=Perseus%3Atext%3A1999.04.0007%3Asmythp%3D1 \ - | ${pkgs.gnugrep}/bin/grep -o 'ref="[^"]*"' \ - | ${pkgs.coreutils}/bin/shuf -n1 \ - | ${pkgs.gnused}/bin/sed 's/^ref="//;s/"$//' - ) + RANDOM_SECTION=$( + good_curl -sSL http://www.perseus.tufts.edu/hopper/xmltoc?doc=Perseus%3Atext%3A1999.04.0007%3Asmythp%3D1 \ + | ${pkgs.gnugrep}/bin/grep -o 'ref="[^"]*"' \ + | ${pkgs.coreutils}/bin/shuf -n1 \ + | ${pkgs.gnused}/bin/sed 's/^ref="//;s/"$//' + ) - url="http://www.perseus.tufts.edu/hopper/text?doc=$RANDOM_SECTION" - good_curl -sSL "$url"\ - | ${pkgs.htmlq}/bin/htmlq '#text_main' \ - | ${pkgs.gnused}/bin/sed 's/<\/\?hr>//g' \ - | ${pkgs.pandoc}/bin/pandoc -f html -t plain --wrap=none + url="http://www.perseus.tufts.edu/hopper/text?doc=$RANDOM_SECTION" + good_curl -sSL "$url"\ + | ${pkgs.htmlq}/bin/htmlq '#text_main' \ + | ${pkgs.gnused}/bin/sed 's/<\/\?hr>//g' \ + | ${pkgs.pandoc}/bin/pandoc -f html -t plain --wrap=none - printf '\n%s\n\n#AncientGreek' "$url" - ''); + printf '\n%s\n\n#AncientGreek' "$url" + '' + ); }; systemd.timers.bot-smyth.timerConfig.RandomizedDelaySec = "10h"; diff --git a/configs/bots/tlg-wotd.nix b/configs/bots/tlg-wotd.nix index 9bd3690..5dad798 100644 --- a/configs/bots/tlg-wotd.nix +++ b/configs/bots/tlg-wotd.nix @@ -2,138 +2,153 @@ pkgs, config, ... -}: let +}: +let mastodonEndpoint = "https://social.krebsco.de"; -in { +in +{ systemd.services.bot-tlg-wotd = { # TODO reenable # once https://github.com/NixOS/nixpkgs/pull/462893 is in stable NixOS enable = true; - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; startAt = "9:30"; - path = [ pkgs.jq pkgs.curl pkgs.recode pkgs.deno pkgs.imagemagick pkgs.gawk pkgs.gnugrep pkgs.coreutils ]; + path = [ + pkgs.jq + pkgs.curl + pkgs.recode + pkgs.deno + pkgs.imagemagick + pkgs.gawk + pkgs.gnugrep + pkgs.coreutils + ]; environment = { NPM_CONFIG_CACHE = "/tmp"; CLTK_DATA = "/tmp"; }; script = '' - set -efux + set -efux - chat_id=@tlgwotd + chat_id=@tlgwotd - export TELEGRAM_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/telegram-token")" - export MASTODON_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/mastodon-token")" + export TELEGRAM_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/telegram-token")" + export MASTODON_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/mastodon-token")" - json_data=$(curl -sSL http://stephanus.tlg.uci.edu/Iris/Wotd | recode html..utf8) + json_data=$(curl -sSL http://stephanus.tlg.uci.edu/Iris/Wotd | recode html..utf8) - word=$(echo "$json_data" | jq -r '.word') - compact_word=$(echo "$word" | sed 's/,.*$//') - definition=$(echo "$json_data" | jq -r '.definition | sub("<.*>"; "") | rtrimstr(" ")') - first_occurrence=$(echo "$json_data" | jq -r '.firstOccurrence') - total_occurrences=$(echo "$json_data" | jq -r '.totalOccurrences') - telegram_caption="*$word* ‘$definition’ + word=$(echo "$json_data" | jq -r '.word') + compact_word=$(echo "$word" | sed 's/,.*$//') + definition=$(echo "$json_data" | jq -r '.definition | sub("<.*>"; "") | rtrimstr(" ")') + first_occurrence=$(echo "$json_data" | jq -r '.firstOccurrence') + total_occurrences=$(echo "$json_data" | jq -r '.totalOccurrences') + telegram_caption="*$word* ‘$definition’ - First occurrence (century): $first_occurrence - Number of occurrences (in all Ancient Greek texts): $total_occurrences" - mastodon_caption="$word ‘$definition’ + First occurrence (century): $first_occurrence + Number of occurrences (in all Ancient Greek texts): $total_occurrences" + mastodon_caption="$word ‘$definition’ - First occurrence (century): $first_occurrence - Number of occurrences (in all Ancient Greek texts): $total_occurrences" + First occurrence (century): $first_occurrence + Number of occurrences (in all Ancient Greek texts): $total_occurrences" - #ancientgreek #classics #wotd #wordoftheday + #ancientgreek #classics #wotd #wordoftheday - transliteration=$(${pkgs.writers.writePython3 "translit.py" { - libraries = py: [ py.cltk ]; - } '' - import sys - from cltk.phonology.grc.transcription import Transcriber + transliteration=$(${ + pkgs.writers.writePython3 "translit.py" + { + libraries = py: [ py.cltk ]; + } + '' + import sys + from cltk.phonology.grc.transcription import Transcriber - probert = Transcriber("Attic", "Probert") - text = " ".join(sys.argv[1:]) - ipa = probert.transcribe(text) + probert = Transcriber("Attic", "Probert") + text = " ".join(sys.argv[1:]) + ipa = probert.transcribe(text) - print(ipa) - ''} "$compact_word") + print(ipa) + '' + } "$compact_word") - photo_path=/tmp/output.png + photo_path=/tmp/output.png - hex_to_rgb() { - hex="$1" - r=$(printf "%d" "0x$(echo "$hex" | cut -c2-3)") - g=$(printf "%d" "0x$(echo "$hex" | cut -c4-5)") - b=$(printf "%d" "0x$(echo "$hex" | cut -c6-7)") - echo "$r $g $b" - } + hex_to_rgb() { + hex="$1" + r=$(printf "%d" "0x$(echo "$hex" | cut -c2-3)") + g=$(printf "%d" "0x$(echo "$hex" | cut -c4-5)") + b=$(printf "%d" "0x$(echo "$hex" | cut -c6-7)") + echo "$r $g $b" + } - calculate_luminance() { - r="$1" - g="$2" - b="$3" + calculate_luminance() { + r="$1" + g="$2" + b="$3" - r_l=$(echo "$r" | awk '{print ($1 / 255 <= 0.03928) ? $1 / 255 / 12.92 : (($1 / 255 + 0.055) / 1.055)^2.4}') - g_l=$(echo "$g" | awk '{print ($1 / 255 <= 0.03928) ? $1 / 255 / 12.92 : (($1 / 255 + 0.055) / 1.055)^2.4}') - b_l=$(echo "$b" | awk '{print ($1 / 255 <= 0.03928) ? $1 / 255 / 12.92 : (($1 / 255 + 0.055) / 1.055)^2.4}') + r_l=$(echo "$r" | awk '{print ($1 / 255 <= 0.03928) ? $1 / 255 / 12.92 : (($1 / 255 + 0.055) / 1.055)^2.4}') + g_l=$(echo "$g" | awk '{print ($1 / 255 <= 0.03928) ? $1 / 255 / 12.92 : (($1 / 255 + 0.055) / 1.055)^2.4}') + b_l=$(echo "$b" | awk '{print ($1 / 255 <= 0.03928) ? $1 / 255 / 12.92 : (($1 / 255 + 0.055) / 1.055)^2.4}') - echo "$r_l $g_l $b_l" | awk '{print 0.2126*$1 + 0.7152*$2 + 0.0722*$3}' - } + echo "$r_l $g_l $b_l" | awk '{print 0.2126*$1 + 0.7152*$2 + 0.0722*$3}' + } - hex_color="#$(echo "$compact_word" | md5sum | cut -c 1-6)" - if echo "$hex_color" | grep -qE '^#[0-9A-Fa-f]{6}$'; then - set -- $(hex_to_rgb "$hex_color") - r="$1" - g="$2" - b="$3" - fi + hex_color="#$(echo "$compact_word" | md5sum | cut -c 1-6)" + if echo "$hex_color" | grep -qE '^#[0-9A-Fa-f]{6}$'; then + set -- $(hex_to_rgb "$hex_color") + r="$1" + g="$2" + b="$3" + fi - luminance=$(calculate_luminance "$r" "$g" "$b") + luminance=$(calculate_luminance "$r" "$g" "$b") - threshold="0.1" - echo "$r $g $b" - if [ "$(echo "$luminance" | awk -v threshold="$threshold" '{print ($1 > threshold)}')" -eq 1 ]; then - color1="black" - color2="#333" - else - color1="white" - color2=lightgrey - fi + threshold="0.1" + echo "$r $g $b" + if [ "$(echo "$luminance" | awk -v threshold="$threshold" '{print ($1 > threshold)}')" -eq 1 ]; then + color1="black" + color2="#333" + else + color1="white" + color2=lightgrey + fi - magick -size 1400x846 \ - xc:"$hex_color" \ - -font "${pkgs.gentium}/share/fonts/truetype/GentiumBookPlus-Bold.ttf" \ - -fill "$color1" \ - -pointsize 150 -gravity west \ - -annotate +100-160 "$compact_word" \ - -font "${pkgs.gentium}/share/fonts/truetype/GentiumBookPlus-Regular.ttf" \ - -fill "$color2" \ - -pointsize 60 -gravity west \ - -annotate +100+00 "$transliteration" \ - -fill "$color1" \ - -annotate +100+120 "‘$definition’" \ - -fill "$color2" \ - -pointsize 40 -gravity southwest \ - -annotate +100+60 "attested $total_occurrences times" \ - -pointsize 40 -gravity southeast \ - -annotate +100+60 "$(date -I)" \ - "$photo_path" + magick -size 1400x846 \ + xc:"$hex_color" \ + -font "${pkgs.gentium}/share/fonts/truetype/GentiumBookPlus-Bold.ttf" \ + -fill "$color1" \ + -pointsize 150 -gravity west \ + -annotate +100-160 "$compact_word" \ + -font "${pkgs.gentium}/share/fonts/truetype/GentiumBookPlus-Regular.ttf" \ + -fill "$color2" \ + -pointsize 60 -gravity west \ + -annotate +100+00 "$transliteration" \ + -fill "$color1" \ + -annotate +100+120 "‘$definition’" \ + -fill "$color2" \ + -pointsize 40 -gravity southwest \ + -annotate +100+60 "attested $total_occurrences times" \ + -pointsize 40 -gravity southeast \ + -annotate +100+60 "$(date -I)" \ + "$photo_path" - curl -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendPhoto" \ - -F "chat_id=\"$chat_id\"" \ - -F "photo=@$photo_path" \ - -F parse_mode=Markdown \ - -F caption="$telegram_caption" + curl -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendPhoto" \ + -F "chat_id=\"$chat_id\"" \ + -F "photo=@$photo_path" \ + -F parse_mode=Markdown \ + -F caption="$telegram_caption" - mastodon_upload_response=$(curl -X POST "${mastodonEndpoint}/api/v2/media" \ - -H "Authorization: Bearer $MASTODON_TOKEN" \ - -F "file=@$photo_path" \ - -F "description=$word ‘$definition’") - mastodon_image_id=$(echo $mastodon_upload_response | jq -r .id) - curl -X POST "${mastodonEndpoint}/api/v1/statuses" \ - -H "Authorization: Bearer $MASTODON_TOKEN" \ - -d "status=$mastodon_caption" \ - -d "visibility=public" \ - -d "media_ids[]=$mastodon_image_id" + mastodon_upload_response=$(curl -X POST "${mastodonEndpoint}/api/v2/media" \ + -H "Authorization: Bearer $MASTODON_TOKEN" \ + -F "file=@$photo_path" \ + -F "description=$word ‘$definition’") + mastodon_image_id=$(echo $mastodon_upload_response | jq -r .id) + curl -X POST "${mastodonEndpoint}/api/v1/statuses" \ + -H "Authorization: Bearer $MASTODON_TOKEN" \ + -d "status=$mastodon_caption" \ + -d "visibility=public" \ + -d "media_ids[]=$mastodon_image_id" ''; serviceConfig = { Type = "oneshot"; diff --git a/configs/bots/transits.nix b/configs/bots/transits.nix index 8e5aa0a..aff0314 100644 --- a/configs/bots/transits.nix +++ b/configs/bots/transits.nix @@ -3,7 +3,8 @@ pkgs, lib, ... -}: let +}: +let toSymbols = pkgs.writers.writeDash "to-symbols" '' ${pkgs.gnused}/bin/sed ' s/\bTri\b/△/; @@ -40,7 +41,8 @@ s/^\s*// ' ''; -in { +in +{ niveum.bots.transits = { enable = true; time = "*:0/1"; @@ -51,19 +53,21 @@ in { telegram = { enable = true; tokenFile = config.age.secrets.telegram-token-kmein.path; - chatIds = ["-1001796440545"]; + chatIds = [ "-1001796440545" ]; }; - command = toString (pkgs.writers.writeDash "common-transits" '' - set -efu + command = toString ( + pkgs.writers.writeDash "common-transits" '' + set -efu - now=$(${pkgs.coreutils}/bin/date +%_H:%M | ${pkgs.gnused}/bin/sed 's/^\s*//') - date=$(${pkgs.coreutils}/bin/date +'%m %d %Y') - ( - cd ${pkgs.astrolog}/bin - # ./astrolog -Yt -Yd -q 10 22 1999 6:32 -zN Kassel -td $date -R Uranus Neptune Pluto "North Node" - ./astrolog -qd $date -zN Berlin -Yt -Yd -d -R Uranus Neptune Pluto "North Node" -A 2 - ) | ${toSymbols} | ${pkgs.coreutils}/bin/sort -n | ${pkgs.gnugrep}/bin/grep "^$now" || : - ''); + now=$(${pkgs.coreutils}/bin/date +%_H:%M | ${pkgs.gnused}/bin/sed 's/^\s*//') + date=$(${pkgs.coreutils}/bin/date +'%m %d %Y') + ( + cd ${pkgs.astrolog}/bin + # ./astrolog -Yt -Yd -q 10 22 1999 6:32 -zN Kassel -td $date -R Uranus Neptune Pluto "North Node" + ./astrolog -qd $date -zN Berlin -Yt -Yd -d -R Uranus Neptune Pluto "North Node" -A 2 + ) | ${toSymbols} | ${pkgs.coreutils}/bin/sort -n | ${pkgs.gnugrep}/bin/grep "^$now" || : + '' + ); }; age.secrets = { diff --git a/configs/browser.nix b/configs/browser.nix index 85c3372..6f2b23a 100644 --- a/configs/browser.nix +++ b/configs/browser.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ environment.systemPackages = [ pkgs.cro pkgs.tor-browser @@ -13,76 +14,78 @@ home-manager.users.me = { programs.firefox = { enable = true; - profiles = let - defaultSettings = { - "beacon.enabled" = false; - "browser.bookmarks.showMobileBookmarks" = true; - "browser.newtab.preload" = false; - "browser.search.isUS" = false; - "browser.search.region" = "DE"; - "browser.send_pings" = false; - "browser.shell.checkDefaultBrowser" = false; - "browser.startup.homepage" = "chrome://browser/content/blanktab.html"; - "browser.uidensity" = 1; - "browser.urlbar.placeholderName" = "Search"; - "datareporting.healthreport.service.enabled" = false; - "datareporting.healthreport.uploadEnabled" = false; - "datareporting.policy.dataSubmissionEnabled" = false; - "datareporting.sessions.current.clean" = true; - "distribution.searchplugins.defaultLocale" = "de-DE"; - "general.smoothScroll" = true; - "identity.fxaccounts.account.device.name" = config.networking.hostName; - "network.cookie.cookieBehavior" = 1; - "privacy.donottrackheader.enabled" = true; - "privacy.trackingprotection.enabled" = true; - "privacy.trackingprotection.pbmode.enabled" = true; - "privacy.trackingprotection.socialtracking.enabled" = true; - "services.sync.declinedEngines" = "passwords"; - "services.sync.engine.passwords" = false; - "signon.autofillForms" = false; - "signon.rememberSignons" = false; - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; - "toolkit.telemetry.archive.enabled" = false; - "toolkit.telemetry.bhrPing.enabled" = false; - "toolkit.telemetry.cachedClientID" = ""; - "toolkit.telemetry.enabled" = false; - "toolkit.telemetry.firstShutdownPing.enabled" = false; - "toolkit.telemetry.hybridContent.enabled" = false; - "toolkit.telemetry.newProfilePing.enabled" = false; - "toolkit.telemetry.prompted" = 2; - "toolkit.telemetry.rejected" = true; - "toolkit.telemetry.server" = ""; - "toolkit.telemetry.shutdownPingSender.enabled" = false; - "toolkit.telemetry.unified" = false; - "toolkit.telemetry.unifiedIsOptIn" = false; - "toolkit.telemetry.updatePing.enabled" = false; - "ui.prefersReducedMotion" = 1; + profiles = + let + defaultSettings = { + "beacon.enabled" = false; + "browser.bookmarks.showMobileBookmarks" = true; + "browser.newtab.preload" = false; + "browser.search.isUS" = false; + "browser.search.region" = "DE"; + "browser.send_pings" = false; + "browser.shell.checkDefaultBrowser" = false; + "browser.startup.homepage" = "chrome://browser/content/blanktab.html"; + "browser.uidensity" = 1; + "browser.urlbar.placeholderName" = "Search"; + "datareporting.healthreport.service.enabled" = false; + "datareporting.healthreport.uploadEnabled" = false; + "datareporting.policy.dataSubmissionEnabled" = false; + "datareporting.sessions.current.clean" = true; + "distribution.searchplugins.defaultLocale" = "de-DE"; + "general.smoothScroll" = true; + "identity.fxaccounts.account.device.name" = config.networking.hostName; + "network.cookie.cookieBehavior" = 1; + "privacy.donottrackheader.enabled" = true; + "privacy.trackingprotection.enabled" = true; + "privacy.trackingprotection.pbmode.enabled" = true; + "privacy.trackingprotection.socialtracking.enabled" = true; + "services.sync.declinedEngines" = "passwords"; + "services.sync.engine.passwords" = false; + "signon.autofillForms" = false; + "signon.rememberSignons" = false; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "toolkit.telemetry.archive.enabled" = false; + "toolkit.telemetry.bhrPing.enabled" = false; + "toolkit.telemetry.cachedClientID" = ""; + "toolkit.telemetry.enabled" = false; + "toolkit.telemetry.firstShutdownPing.enabled" = false; + "toolkit.telemetry.hybridContent.enabled" = false; + "toolkit.telemetry.newProfilePing.enabled" = false; + "toolkit.telemetry.prompted" = 2; + "toolkit.telemetry.rejected" = true; + "toolkit.telemetry.server" = ""; + "toolkit.telemetry.shutdownPingSender.enabled" = false; + "toolkit.telemetry.unified" = false; + "toolkit.telemetry.unifiedIsOptIn" = false; + "toolkit.telemetry.updatePing.enabled" = false; + "ui.prefersReducedMotion" = 1; + }; + in + { + default = { + id = 0; + isDefault = true; + settings = defaultSettings; + # extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + # ublock-origin + # darkreader + # sponsorblock + # consent-o-matic + # i-dont-care-about-cookies + # # auto-tab-discard TODO what is this + # ]; + userChrome = '' + #TabsToolbar { + visibility: collapse !important; + } + ''; + }; }; - in { - default = { - id = 0; - isDefault = true; - settings = defaultSettings; - # extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - # ublock-origin - # darkreader - # sponsorblock - # consent-o-matic - # i-dont-care-about-cookies - # # auto-tab-discard TODO what is this - # ]; - userChrome = '' - #TabsToolbar { - visibility: collapse !important; - } - ''; - }; - }; }; }; home-manager.users.me = { - stylix.targets.firefox.profileNames = ["default"]; + stylix.targets.firefox.profileNames = [ "default" ]; }; environment.variables.BROWSER = "firefox"; diff --git a/configs/clipboard.nix b/configs/clipboard.nix index 8d20597..b6aa82e 100644 --- a/configs/clipboard.nix +++ b/configs/clipboard.nix @@ -2,6 +2,7 @@ config, pkgs, ... -}: { +}: +{ services.clipmenu.enable = true; } diff --git a/configs/cloud.nix b/configs/cloud.nix index 245aad9..53c1385 100644 --- a/configs/cloud.nix +++ b/configs/cloud.nix @@ -3,7 +3,8 @@ lib, pkgs, ... -}: { +}: +{ systemd.user.services.systemd-tmpfiles-clean = { enable = true; wantedBy = [ "default.target" ]; @@ -14,27 +15,40 @@ }; }; - systemd.user.tmpfiles.users.me.rules = map pkgs.lib.niveum.tmpfilesConfig [ - { - type = "d"; - mode = "0755"; - age = "7d"; - path = "${config.users.users.me.home}/sync/Downloads"; - } - { - type = "d"; - mode = "0755"; - age = "7d"; - path = "${config.users.users.me.home}/cloud/nextcloud/tmp"; - } - ] ++ map (path: pkgs.lib.niveum.tmpfilesConfig { - type = "L+"; - user = config.users.users.me.name; - group = config.users.users.me.group; - mode = "0755"; - argument = "${config.users.users.me.home}/sync/${path}"; - path = "${config.users.users.me.home}/${path}"; - }) [".ssh" ".gnupg" ".pki" ".local/share/aerc"]; + systemd.user.tmpfiles.users.me.rules = + map pkgs.lib.niveum.tmpfilesConfig [ + { + type = "d"; + mode = "0755"; + age = "7d"; + path = "${config.users.users.me.home}/sync/Downloads"; + } + { + type = "d"; + mode = "0755"; + age = "7d"; + path = "${config.users.users.me.home}/cloud/nextcloud/tmp"; + } + ] + ++ + map + ( + path: + pkgs.lib.niveum.tmpfilesConfig { + type = "L+"; + user = config.users.users.me.name; + group = config.users.users.me.group; + mode = "0755"; + argument = "${config.users.users.me.home}/sync/${path}"; + path = "${config.users.users.me.home}/${path}"; + } + ) + [ + ".ssh" + ".gnupg" + ".pki" + ".local/share/aerc" + ]; services.gnome.gnome-keyring.enable = true; security.pam.services.lightdm.enableGnomeKeyring = true; @@ -48,20 +62,22 @@ systemd.user.services.nextcloud-syncer = { enable = false; - wants = ["network-online.target"]; - wantedBy = ["default.target"]; + wants = [ "network-online.target" ]; + wantedBy = [ "default.target" ]; startAt = "*:00/10"; - script = let - kieran = { - user = "kieran"; - passwordFile = config.age.secrets.nextcloud-password-kieran.path; - endpoint = "https://cloud.kmein.de"; - target = "${config.users.users.me.home}/notes"; - }; - in '' - mkdir -p ${lib.escapeShellArg kieran.target} - ${pkgs.nextcloud-client}/bin/nextcloudcmd --non-interactive --user ${kieran.user} --password "$(cat ${kieran.passwordFile})" --path /Notes ${lib.escapeShellArg kieran.target} ${kieran.endpoint} - ''; + script = + let + kieran = { + user = "kieran"; + passwordFile = config.age.secrets.nextcloud-password-kieran.path; + endpoint = "https://cloud.kmein.de"; + target = "${config.users.users.me.home}/notes"; + }; + in + '' + mkdir -p ${lib.escapeShellArg kieran.target} + ${pkgs.nextcloud-client}/bin/nextcloudcmd --non-interactive --user ${kieran.user} --password "$(cat ${kieran.passwordFile})" --path /Notes ${lib.escapeShellArg kieran.target} ${kieran.endpoint} + ''; serviceConfig = { Type = "oneshot"; Restart = "on-failure"; @@ -77,13 +93,16 @@ } | ${pkgs.fzf}/bin/fzf)" exec ${pkgs.zathura}/bin/zathura "$book" '') - (let - kieran = { - user = "kieran.meinhardt@gmail.com"; - passwordFile = config.age.secrets.mega-password.path; - }; - megatools = command: ''${pkgs.megatools}/bin/megatools ${command} --username ${lib.escapeShellArg kieran.user} --password "$(cat ${kieran.passwordFile})"''; - in + ( + let + kieran = { + user = "kieran.meinhardt@gmail.com"; + passwordFile = config.age.secrets.mega-password.path; + }; + megatools = + command: + ''${pkgs.megatools}/bin/megatools ${command} --username ${lib.escapeShellArg kieran.user} --password "$(cat ${kieran.passwordFile})"''; + in pkgs.writers.writeDashBin "book-mega" '' set -efu selection="$(${megatools "ls"} | ${pkgs.fzf}/bin/fzf)" @@ -100,7 +119,8 @@ ${megatools "get"} "$selection" exec ${pkgs.zathura}/bin/zathura "$(basename "$selection")" ) - '') + '' + ) ]; age.secrets.mega-password = { @@ -122,13 +142,22 @@ devices = pkgs.lib.niveum.syncthingIds; folders = { "${config.users.users.me.home}/sync" = { - devices = ["kabsa" "manakish" "fatteh"]; + devices = [ + "kabsa" + "manakish" + "fatteh" + ]; label = "sync"; versioning.type = "trashcan"; versioning.params.cleanoutDays = 100; }; "${config.users.users.me.home}/mobile" = { - devices = ["kabsa" "manakish" "fatteh" "kibbeh"]; + devices = [ + "kabsa" + "manakish" + "fatteh" + "kibbeh" + ]; id = "mobile"; label = "mobile"; versioning.type = "trashcan"; diff --git a/configs/default.nix b/configs/default.nix index fc7a7b8..4b6dd43 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -137,10 +137,14 @@ in agent = { enable = true; pinentryPackage = pkgs.pinentry-qt; - settings = let defaultCacheTtl = 2 * 60 * 60; in { - default-cache-ttl = defaultCacheTtl; - max-cache-ttl = 4 * defaultCacheTtl; - }; + settings = + let + defaultCacheTtl = 2 * 60 * 60; + in + { + default-cache-ttl = defaultCacheTtl; + max-cache-ttl = 4 * defaultCacheTtl; + }; }; }; @@ -253,16 +257,20 @@ in ./mastodon-bot.nix { home-manager.users.me = { - xdg.userDirs = let pictures = "${config.users.users.me.home}/cloud/nextcloud/Bilder"; in { - enable = true; - documents = "${config.users.users.me.home}/cloud/nextcloud/Documents"; - desktop = "/tmp"; - download = "${config.users.users.me.home}/sync/Downloads"; - music = "${config.users.users.me.home}/mobile/audio"; - publicShare = "${config.users.users.me.home}/cloud/nextcloud/tmp"; - videos = pictures; - pictures = pictures; - }; + xdg.userDirs = + let + pictures = "${config.users.users.me.home}/cloud/nextcloud/Bilder"; + in + { + enable = true; + documents = "${config.users.users.me.home}/cloud/nextcloud/Documents"; + desktop = "/tmp"; + download = "${config.users.users.me.home}/sync/Downloads"; + music = "${config.users.users.me.home}/mobile/audio"; + publicShare = "${config.users.users.me.home}/cloud/nextcloud/tmp"; + videos = pictures; + pictures = pictures; + }; }; } ]; diff --git a/configs/direnv.nix b/configs/direnv.nix index d7475f7..1506ba3 100644 --- a/configs/direnv.nix +++ b/configs/direnv.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: let +{ pkgs, ... }: +let nixify = pkgs.writers.writeDashBin "nixify" '' set -efuC @@ -16,8 +17,12 @@ ''${EDITOR:-vim} shell.nix fi ''; -in { - environment.systemPackages = [pkgs.direnv nixify]; +in +{ + environment.systemPackages = [ + pkgs.direnv + nixify + ]; home-manager.users.me.programs.direnv = { enable = true; diff --git a/configs/docker.nix b/configs/docker.nix index 027fb14..518c670 100644 --- a/configs/docker.nix +++ b/configs/docker.nix @@ -2,7 +2,8 @@ lib, pkgs, ... -}: { +}: +{ virtualisation.docker = { enable = true; # for ICE wifi, ref https://gist.github.com/sunsided/7840e89ff4e11b64a2d7503fafa0290c @@ -11,6 +12,9 @@ "--fixed-cidr=172.39.1.0/25" ]; }; - users.users.me.extraGroups = ["docker"]; - environment.systemPackages = [pkgs.docker pkgs.docker-compose]; + users.users.me.extraGroups = [ "docker" ]; + environment.systemPackages = [ + pkgs.docker + pkgs.docker-compose + ]; } diff --git a/configs/dunst.nix b/configs/dunst.nix index 835cd86..505380e 100644 --- a/configs/dunst.nix +++ b/configs/dunst.nix @@ -2,9 +2,11 @@ lib, pkgs, ... -}: let +}: +let sgr = code: string: ''\u001b[${code}m${string}\u001b[0m''; -in { +in +{ environment.systemPackages = [ (pkgs.writers.writeDashBin "notifications" '' ${pkgs.dunst}/bin/dunstctl history \ diff --git a/configs/flameshot.nix b/configs/flameshot.nix index 8528d11..c282493 100644 --- a/configs/flameshot.nix +++ b/configs/flameshot.nix @@ -2,7 +2,8 @@ lib, pkgs, ... -}: { +}: +{ home-manager.users.me = { services.flameshot = { enable = true; diff --git a/configs/fonts.nix b/configs/fonts.nix index fbcdf6b..fee0bb5 100644 --- a/configs/fonts.nix +++ b/configs/fonts.nix @@ -1,20 +1,25 @@ { pkgs, ... -}: let - zip-font = name: arguments: let - directory = pkgs.fetchzip arguments; - in - pkgs.runCommand name {} '' +}: +let + zip-font = + name: arguments: + let + directory = pkgs.fetchzip arguments; + in + pkgs.runCommand name { } '' mkdir -p $out/share/fonts/{truetype,opentype,woff} ${pkgs.findutils}/bin/find ${directory} -name '*.ttf' -exec install '{}' $out/share/fonts/truetype \; ${pkgs.findutils}/bin/find ${directory} -name '*.otf' -exec install '{}' $out/share/fonts/opentype \; ${pkgs.findutils}/bin/find ${directory} -name '*.woff' -exec install '{}' $out/share/fonts/woff \; ''; - simple-ttf = name: arguments: let - file = pkgs.fetchurl arguments; - in - pkgs.runCommand name {} '' + simple-ttf = + name: arguments: + let + file = pkgs.fetchurl arguments; + in + pkgs.runCommand name { } '' mkdir -p $out/share/fonts/truetype install ${file} $out/share/fonts/truetype ''; @@ -57,7 +62,8 @@ url = "https://github.com/microsoft/font-tools/raw/1092cb23520967830001a0807eb21d6a44dda522/EgyptianOpenType/font/eot.ttf"; sha256 = "1n294vhcx90270pnsw1dbk6izd61fjvbnjrh4hcf98ff3s540x0c"; }; -in { +in +{ fonts = { enableDefaultPackages = true; fontDir.enable = true; @@ -117,12 +123,28 @@ in { vollkorn zilla-slab ]; # google-fonts league-of-moveable-type - fontconfig.defaultFonts = let emoji = ["Noto Color Emoji"]; in { - monospace = ["Noto Sans Mono"] ++ emoji; - serif = ["Noto Serif" "Noto Naskh Arabic" "Noto Serif Devanagari"]; - sansSerif = ["Noto Sans Display" "Noto Naskh Arabic" "Noto Sans Hebrew" "Noto Sans Devanagari" "Noto Sans CJK JP" "Noto Sans Coptic" "Noto Sans Syriac Western"]; - inherit emoji; - }; + fontconfig.defaultFonts = + let + emoji = [ "Noto Color Emoji" ]; + in + { + monospace = [ "Noto Sans Mono" ] ++ emoji; + serif = [ + "Noto Serif" + "Noto Naskh Arabic" + "Noto Serif Devanagari" + ]; + sansSerif = [ + "Noto Sans Display" + "Noto Naskh Arabic" + "Noto Sans Hebrew" + "Noto Sans Devanagari" + "Noto Sans CJK JP" + "Noto Sans Coptic" + "Noto Sans Syriac Western" + ]; + inherit emoji; + }; # xelatex fails with woff files # ref https://tex.stackexchange.com/questions/392144/xelatex-and-fontspec-crash-trying-to-find-woff-file-for-some-fonts-but-not-other fontconfig.localConf = '' diff --git a/configs/fzf.nix b/configs/fzf.nix index 8911d51..f8f9412 100644 --- a/configs/fzf.nix +++ b/configs/fzf.nix @@ -1,24 +1,27 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ programs.fzf = { fuzzyCompletion = true; keybindings = true; }; home-manager.users.me = { - programs.fzf = let - defaultCommand = "${pkgs.fd}/bin/fd --type f --strip-cwd-prefix --follow --no-ignore-vcs --exclude .git"; - in { - enable = true; - defaultCommand = defaultCommand; - defaultOptions = ["--height=40%"]; - changeDirWidgetCommand = "${pkgs.fd}/bin/fd --type d"; - changeDirWidgetOptions = [ - "--preview='${pkgs.tree}/bin/tree -L 1 {}'" - "--bind=space:toggle-preview" - "--preview-window=hidden" - ]; - fileWidgetCommand = defaultCommand; - fileWidgetOptions = ["--preview='head -$LINES {}'"]; - }; + programs.fzf = + let + defaultCommand = "${pkgs.fd}/bin/fd --type f --strip-cwd-prefix --follow --no-ignore-vcs --exclude .git"; + in + { + enable = true; + defaultCommand = defaultCommand; + defaultOptions = [ "--height=40%" ]; + changeDirWidgetCommand = "${pkgs.fd}/bin/fd --type d"; + changeDirWidgetOptions = [ + "--preview='${pkgs.tree}/bin/tree -L 1 {}'" + "--bind=space:toggle-preview" + "--preview-window=hidden" + ]; + fileWidgetCommand = defaultCommand; + fileWidgetOptions = [ "--preview='head -$LINES {}'" ]; + }; }; } diff --git a/configs/hledger.nix b/configs/hledger.nix index aba6ba7..367d354 100644 --- a/configs/hledger.nix +++ b/configs/hledger.nix @@ -1,26 +1,30 @@ { pkgs, ... -}: let +}: +let ledgerDirectory = "/home/kfm/sync/src/ledger"; hora = pkgs.callPackage ../packages/hora.nix { timeLedger = "${ledgerDirectory}/time.timeclock"; }; -in { - environment.systemPackages = let - git = "${pkgs.git}/bin/git -C ${ledgerDirectory}"; - in [ - hora - pkgs.hledger - (pkgs.writers.writeDashBin "hledger-git" '' - if [ "$1" = entry ]; then - ${pkgs.hledger}/bin/hledger balance -V > "${ledgerDirectory}/balance.txt" - ${git} add balance.txt - ${git} commit --all --message="$(date -Im)" - else - ${git} $* - fi - '') - (pkgs.writers.writeDashBin "hledger-edit" '' - $EDITOR ${ledgerDirectory}/current.journal - '') - ]; +in +{ + environment.systemPackages = + let + git = "${pkgs.git}/bin/git -C ${ledgerDirectory}"; + in + [ + hora + pkgs.hledger + (pkgs.writers.writeDashBin "hledger-git" '' + if [ "$1" = entry ]; then + ${pkgs.hledger}/bin/hledger balance -V > "${ledgerDirectory}/balance.txt" + ${git} add balance.txt + ${git} commit --all --message="$(date -Im)" + else + ${git} $* + fi + '') + (pkgs.writers.writeDashBin "hledger-edit" '' + $EDITOR ${ledgerDirectory}/current.journal + '') + ]; } diff --git a/configs/htop.nix b/configs/htop.nix index 25e3fc1..b49530d 100644 --- a/configs/htop.nix +++ b/configs/htop.nix @@ -22,8 +22,18 @@ sort_key = "PERCENT_CPU"; tree_view = false; update_process_names = false; - right_meters = ["Uptime" "Tasks" "LoadAverage" "Battery"]; - left_meters = ["LeftCPUs2" "RightCPUs2" "Memory" "Swap"]; + right_meters = [ + "Uptime" + "Tasks" + "LoadAverage" + "Battery" + ]; + left_meters = [ + "LeftCPUs2" + "RightCPUs2" + "Memory" + "Swap" + ]; }; }; }; diff --git a/configs/i3.nix b/configs/i3.nix index b4fe99b..dfc5370 100644 --- a/configs/i3.nix +++ b/configs/i3.nix @@ -3,7 +3,8 @@ pkgs, lib, ... -}: let +}: +let klem = pkgs.klem.override { options.dmenu = "${pkgs.dmenu}/bin/dmenu -i -p klem"; options.scripts = { @@ -51,7 +52,8 @@ ''; }; }; -in { +in +{ age.secrets = { github-token-i3status-rust = { file = ../secrets/github-token-i3status-rust.age; @@ -105,179 +107,215 @@ in { ''; }; - home-manager.users.me = let - modifier = "Mod4"; - infoWorkspace = "ℹ"; - messageWorkspace = "✉"; - modes.resize = { - "Escape" = ''mode "default"''; - "Return" = ''mode "default"''; - "h" = "resize shrink width 10 px or 5 ppt"; - "j" = "resize grow height 10 px or 5 ppt"; - "k" = "resize shrink height 10 px or 5 ppt"; - "l" = "resize grow width 10 px or 5 ppt"; - }; - gaps.inner = 4; - floating = { - titlebar = false; - border = 1; - }; - bars = let position = "bottom"; in [ - (lib.recursiveUpdate config.home-manager.users.me.stylix.targets.i3.exportedBarConfig + home-manager.users.me = + let + modifier = "Mod4"; + infoWorkspace = "ℹ"; + messageWorkspace = "✉"; + modes.resize = { + "Escape" = ''mode "default"''; + "Return" = ''mode "default"''; + "h" = "resize shrink width 10 px or 5 ppt"; + "j" = "resize grow height 10 px or 5 ppt"; + "k" = "resize shrink height 10 px or 5 ppt"; + "l" = "resize grow width 10 px or 5 ppt"; + }; + gaps.inner = 4; + floating = { + titlebar = false; + border = 1; + }; + bars = + let + position = "bottom"; + in + [ + (lib.recursiveUpdate config.home-manager.users.me.stylix.targets.i3.exportedBarConfig { + workspaceButtons = true; + mode = "hide"; # "dock"; + inherit position; + statusCommand = toString ( + pkgs.writers.writeDash "i3status-rust" '' + export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})" + export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})" + exec ${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml + '' + ); + fonts = { + names = [ + "${config.stylix.fonts.sansSerif.name}" + "FontAwesome 6 Free" + ]; + size = config.stylix.fonts.sizes.desktop * 0.8; + }; + }) + ]; + window = { + titlebar = false; + border = 2; + hideEdgeBorders = "smart"; + commands = [ + { + criteria = { + class = "floating"; + }; + command = "floating enable"; + } + { + criteria = { + class = "fzfmenu"; + }; + command = "floating enable"; + } + { + criteria = { + class = ".*"; + }; + command = "border pixel 2"; + } + { + criteria = { + class = "mpv"; + }; + command = lib.strings.concatStringsSep ", " [ + "floating enable" + "sticky enable" + "fullscreen disable" + "resize set 640 480" + "move position mouse" + ]; + } + ]; + }; + colors = + let + background = config.lib.stylix.colors.withHashtag.base00; + in { - workspaceButtons = true; - mode = "hide"; # "dock"; - inherit position; - statusCommand = toString (pkgs.writers.writeDash "i3status-rust" '' - export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})" - export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})" - exec ${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml - ''); - fonts = { - names = ["${config.stylix.fonts.sansSerif.name}" "FontAwesome 6 Free"]; - size = config.stylix.fonts.sizes.desktop * 0.8; + unfocused = { + border = lib.mkForce background; + childBorder = lib.mkForce background; }; - }) - ]; - window = { - titlebar = false; - border = 2; - hideEdgeBorders = "smart"; - commands = [ - { - criteria = {class = "floating";}; - command = "floating enable"; - } - { - criteria = {class = "fzfmenu";}; - command = "floating enable"; - } - { - criteria = {class = ".*";}; - command = "border pixel 2"; - } - { - criteria = {class = "mpv";}; - command = lib.strings.concatStringsSep ", " [ - "floating enable" - "sticky enable" - "fullscreen disable" - "resize set 640 480" - "move position mouse" - ]; - } - ]; - }; - colors = let - background = config.lib.stylix.colors.withHashtag.base00; - in { - unfocused = { - border = lib.mkForce background; - childBorder = lib.mkForce background; - }; - }; - keybindings = - lib.listToAttrs (map (x: lib.nameValuePair "${modifier}+Shift+${toString x}" "move container to workspace ${toString x}") (lib.range 1 9)) - // lib.listToAttrs (map (x: lib.nameValuePair "${modifier}+${toString x}" "workspace ${toString x}") (lib.range 1 9)) - // { - "${modifier}+i" = "workspace ${infoWorkspace}"; - "${modifier}+m" = "workspace ${messageWorkspace}"; + }; + keybindings = + lib.listToAttrs ( + map ( + x: lib.nameValuePair "${modifier}+Shift+${toString x}" "move container to workspace ${toString x}" + ) (lib.range 1 9) + ) + // lib.listToAttrs ( + map (x: lib.nameValuePair "${modifier}+${toString x}" "workspace ${toString x}") (lib.range 1 9) + ) + // { + "${modifier}+i" = "workspace ${infoWorkspace}"; + "${modifier}+m" = "workspace ${messageWorkspace}"; - "${modifier}+Shift+h" = "move left 25 px"; - "${modifier}+Shift+j" = "move down 25 px"; - "${modifier}+Shift+k" = "move up 25 px"; - "${modifier}+Shift+l" = "move right 25 px"; - "${modifier}+h" = "focus left"; - "${modifier}+j" = "focus down"; - "${modifier}+k" = "focus up"; - "${modifier}+l" = "focus right"; + "${modifier}+Shift+h" = "move left 25 px"; + "${modifier}+Shift+j" = "move down 25 px"; + "${modifier}+Shift+k" = "move up 25 px"; + "${modifier}+Shift+l" = "move right 25 px"; + "${modifier}+h" = "focus left"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + "${modifier}+l" = "focus right"; - # "${modifier}+Shift+b" = "move container to workspace prev"; - # "${modifier}+Shift+n" = "move container to workspace next"; - # "${modifier}+b" = "workspace prev"; - # "${modifier}+n" = "workspace next"; + # "${modifier}+Shift+b" = "move container to workspace prev"; + # "${modifier}+Shift+n" = "move container to workspace next"; + # "${modifier}+b" = "workspace prev"; + # "${modifier}+n" = "workspace next"; - "${modifier}+Shift+c" = "reload"; - "${modifier}+Shift+q" = "kill"; - "${modifier}+Shift+r" = "restart"; + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+q" = "kill"; + "${modifier}+Shift+r" = "restart"; - "${modifier}+z" = "sticky toggle"; - "${modifier}+Shift+z" = "floating toggle"; + "${modifier}+z" = "sticky toggle"; + "${modifier}+Shift+z" = "floating toggle"; - "${modifier}+Shift+s" = "move scratchpad"; - "${modifier}+s" = ''[class="^(?i)(?!obsidian).*"] scratchpad show''; - "${modifier}+o" = ''[class="obsidian"] scratchpad show''; + "${modifier}+Shift+s" = "move scratchpad"; + "${modifier}+s" = ''[class="^(?i)(?!obsidian).*"] scratchpad show''; + "${modifier}+o" = ''[class="obsidian"] scratchpad show''; - "${modifier}+c" = "split h"; - "${modifier}+e" = "layout toggle split"; - "${modifier}+f" = "fullscreen toggle"; - "${modifier}+r" = "mode resize"; - "${modifier}+v" = "split v"; - "${modifier}+w" = "layout tabbed"; - "${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu"; + "${modifier}+c" = "split h"; + "${modifier}+e" = "layout toggle split"; + "${modifier}+f" = "fullscreen toggle"; + "${modifier}+r" = "mode resize"; + "${modifier}+v" = "split v"; + "${modifier}+w" = "layout tabbed"; + "${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu"; - "${modifier}+Return" = "exec ${lib.getExe pkgs.niveum-terminal}"; - "${modifier}+t" = "exec ${lib.getExe pkgs.niveum-filemanager}"; - "${modifier}+y" = "exec ${lib.getExe pkgs.niveum-browser}"; + "${modifier}+Return" = "exec ${lib.getExe pkgs.niveum-terminal}"; + "${modifier}+t" = "exec ${lib.getExe pkgs.niveum-filemanager}"; + "${modifier}+y" = "exec ${lib.getExe pkgs.niveum-browser}"; - "${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}"; - "${modifier}+Shift+d" = "exec ${pkgs.notemenu}/bin/notemenu"; - "${modifier}+p" = "exec rofi-pass"; - "${modifier}+Shift+p" = "exec rofi-pass --insert"; - "${modifier}+u" = "exec ${pkgs.unicodmenu}/bin/unicodmenu"; - "${modifier}+Shift+u" = "exec ${pkgs.writers.writeDash "last-unicode" ''${pkgs.xdotool}/bin/xdotool type --delay 1000 "$(${pkgs.gawk}/bin/awk 'END{print $1}' ~/.cache/unicodmenu)"''}"; + "${modifier}+d" = + "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}"; + "${modifier}+Shift+d" = "exec ${pkgs.notemenu}/bin/notemenu"; + "${modifier}+p" = "exec rofi-pass"; + "${modifier}+Shift+p" = "exec rofi-pass --insert"; + "${modifier}+u" = "exec ${pkgs.unicodmenu}/bin/unicodmenu"; + "${modifier}+Shift+u" = + "exec ${pkgs.writers.writeDash "last-unicode" ''${pkgs.xdotool}/bin/xdotool type --delay 1000 "$(${pkgs.gawk}/bin/awk 'END{print $1}' ~/.cache/unicodmenu)"''}"; - "${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" '' - if ${pkgs.procps}/bin/pgrep screenkey; then - exec ${pkgs.procps}/bin/pkill screenkey - else - exec ${pkgs.screenkey}/bin/screenkey - fi - ''}"; - "${modifier}+F12" = "exec ${klem}/bin/klem"; - "XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5"; - "XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t"; - "XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5"; - "XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc"; - "XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; - "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; - "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; + "${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" '' + if ${pkgs.procps}/bin/pgrep screenkey; then + exec ${pkgs.procps}/bin/pkill screenkey + else + exec ${pkgs.screenkey}/bin/screenkey + fi + ''}"; + "${modifier}+F12" = "exec ${klem}/bin/klem"; + "XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5"; + "XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t"; + "XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5"; + "XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc"; + "XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; + "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; - # key names detected with xorg.xev: - # XF86WakeUp (fn twice) - # XF86Battery (fn f3) - # XF86Sleep (fn f4) - actually suspends - # XF86WLAN - # XF86WebCam (fn f6) - # XF86TouchpadToggle (fn f8) - # XF86Suspend (fn f12) - actually suspends to disk - # Num_Lock (fn Roll) - numlocks - # XF86Audio{Prev,Next,Mute,Play,Stop} - # XF86Forward - # XF86Back - # XF86Launch1 (thinkvantage) - }; - in { - stylix.targets.i3.enable = true; + # key names detected with xorg.xev: + # XF86WakeUp (fn twice) + # XF86Battery (fn f3) + # XF86Sleep (fn f4) - actually suspends + # XF86WLAN + # XF86WebCam (fn f6) + # XF86TouchpadToggle (fn f8) + # XF86Suspend (fn f12) - actually suspends to disk + # Num_Lock (fn Roll) - numlocks + # XF86Audio{Prev,Next,Mute,Play,Stop} + # XF86Forward + # XF86Back + # XF86Launch1 (thinkvantage) + }; + in + { + stylix.targets.i3.enable = true; - xsession.windowManager.i3 = { - enable = true; - extraConfig = '' - bindsym --release ${modifier}+Shift+w exec xsecurelock + xsession.windowManager.i3 = { + enable = true; + extraConfig = '' + bindsym --release ${modifier}+Shift+w exec xsecurelock - exec "${pkgs.obsidian}/bin/obsidian" - for_window [class="obsidian"] , move scratchpad + exec "${pkgs.obsidian}/bin/obsidian" + for_window [class="obsidian"] , move scratchpad - assign [class="message"] ${messageWorkspace} - exec "${pkgs.writers.writeDash "irc" "exec ${pkgs.alacritty}/bin/alacritty --class message -e ssh weechat@makanek -t tmux attach-session -t IM"}" - exec "${pkgs.writers.writeDash "email" "exec ${pkgs.alacritty}/bin/alacritty --class message -e aerc"}" + assign [class="message"] ${messageWorkspace} + exec "${pkgs.writers.writeDash "irc" "exec ${pkgs.alacritty}/bin/alacritty --class message -e ssh weechat@makanek -t tmux attach-session -t IM"}" + exec "${pkgs.writers.writeDash "email" "exec ${pkgs.alacritty}/bin/alacritty --class message -e aerc"}" - exec --no-startup-id ${pkgs.xss-lock}/bin/xss-lock -- xsecurelock - ''; - config = { - inherit modifier gaps modes bars floating window colors; + exec --no-startup-id ${pkgs.xss-lock}/bin/xss-lock -- xsecurelock + ''; + config = { + inherit + modifier + gaps + modes + bars + floating + window + colors + ; keybindings = keybindings // { "${modifier}+F6" = "exec ${pkgs.xorg.xkill}/bin/xkill"; "${modifier}+F9" = "exec ${pkgs.redshift}/bin/redshift -O 4000 -b 0.85"; @@ -288,7 +326,7 @@ in { # "${modifier}+x" = "exec ${new-workspace}"; "XF86Display" = "exec ${pkgs.dmenu-randr}/bin/dmenu-randr"; }; + }; }; }; - }; } diff --git a/configs/i3status-rust.nix b/configs/i3status-rust.nix index 950941a..e32555e 100644 --- a/configs/i3status-rust.nix +++ b/configs/i3status-rust.nix @@ -2,7 +2,8 @@ pkgs, config, ... -}: { +}: +{ age.secrets = { miniflux-api-token = { file = ../secrets/miniflux-api-token.age; @@ -18,22 +19,24 @@ bars.bottom = { icons = "awesome6"; settings = { - theme.overrides = let - colours = config.lib.stylix.colors.withHashtag; - in { - idle_bg = colours.base00; - idle_fg = colours.base05; - good_bg = colours.base00; - good_fg = colours.base0B; - warning_bg = colours.base00; - warning_fg = colours.base0A; - critical_bg = colours.base00; - critical_fg = colours.base09; - info_bg = colours.base00; - info_fg = colours.base04; - separator_bg = colours.base00; - separator = " "; - }; + theme.overrides = + let + colours = config.lib.stylix.colors.withHashtag; + in + { + idle_bg = colours.base00; + idle_fg = colours.base05; + good_bg = colours.base00; + good_fg = colours.base0B; + warning_bg = colours.base00; + warning_fg = colours.base0A; + critical_bg = colours.base00; + critical_fg = colours.base09; + info_bg = colours.base00; + info_fg = colours.base04; + separator_bg = colours.base00; + separator = " "; + }; }; blocks = [ { @@ -70,7 +73,7 @@ block = "memory"; format = "$icon $mem_used.eng(prefix:G)"; } - {block = "load";} + { block = "load"; } { block = "time"; format = "$icon $timestamp.datetime(f:'%Y-%m-%d (%W %a) %H:%M', l:de_DE)"; diff --git a/configs/khal.nix b/configs/khal.nix index 54e1a8a..552f325 100644 --- a/configs/khal.nix +++ b/configs/khal.nix @@ -3,14 +3,16 @@ pkgs, lib, ... -}: let +}: +let davHome = "~/.local/share/dav"; kmeinCloud = { davEndpoint = "https://cloud.kmein.de/remote.php/dav"; username = "kieran"; passwordFile = config.age.secrets.nextcloud-password-kieran.path; }; -in { +in +{ age.secrets = { nextcloud-password-kieran = { file = ../secrets/nextcloud-password-kieran.age; @@ -45,8 +47,8 @@ in { systemd.user.services.vdirsyncer = { enable = true; - wants = ["network-online.target"]; - wantedBy = ["default.target"]; + wants = [ "network-online.target" ]; + wantedBy = [ "default.target" ]; startAt = "*:00/10"; script = '' ${pkgs.vdirsyncer}/bin/vdirsyncer sync && ${pkgs.khal}/bin/khal printcalendars # https://lostpackets.de/khal/configure.html#syncing diff --git a/configs/lb.nix b/configs/lb.nix index 6ab5700..82e6443 100644 --- a/configs/lb.nix +++ b/configs/lb.nix @@ -2,10 +2,11 @@ lib, pkgs, ... -}: { +}: +{ systemd.services.lb-subscription = { enable = true; - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; startAt = "weekly"; serviceConfig = { user = "kfm"; diff --git a/configs/mastodon-bot.nix b/configs/mastodon-bot.nix index 14f1008..510d6db 100644 --- a/configs/mastodon-bot.nix +++ b/configs/mastodon-bot.nix @@ -1,7 +1,8 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ systemd.services.imaginary-illuminations = { enable = false; - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; serviceConfig = { User = "kfm"; Group = "users"; diff --git a/configs/monitoring.nix b/configs/monitoring.nix index 4f59b3e..8ba6409 100644 --- a/configs/monitoring.nix +++ b/configs/monitoring.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ services.nginx.virtualHosts.default = { locations."= /stub_status".extraConfig = "stub_status;"; }; @@ -41,12 +42,12 @@ systemd.services.promtail = { description = "Promtail service for Loki"; - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; serviceConfig = { ExecStart = '' ${pkgs.grafana-loki}/bin/promtail --config.file ${ - (pkgs.formats.yaml {}).generate "promtail.yaml" { + (pkgs.formats.yaml { }).generate "promtail.yaml" { server = { http_listen_port = 28183; grpc_listen_port = 0; @@ -55,9 +56,7 @@ clients = [ { url = "http://${ - if config.networking.hostName == "makanek" - then "127.0.0.1" - else "makanek.r" + if config.networking.hostName == "makanek" then "127.0.0.1" else "makanek.r" }:3100/loki/api/v1/push"; } ]; @@ -71,7 +70,7 @@ }; relabel_configs = [ { - source_labels = ["__journal__systemd_unit"]; + source_labels = [ "__journal__systemd_unit" ]; target_label = "unit"; } ]; diff --git a/configs/mpv.nix b/configs/mpv.nix index 48088d5..2df0053 100644 --- a/configs/mpv.nix +++ b/configs/mpv.nix @@ -3,9 +3,11 @@ lib, config, ... -}: let +}: +let swallow = command: "${pkgs.swallow}/bin/swallow ${command}"; -in { +in +{ environment.shellAliases.smpv = swallow "mpv"; nixpkgs.overlays = [ @@ -19,7 +21,11 @@ in { enable = true; config = { ytdl-format = "bestvideo[height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/best"; - ytdl-raw-options = lib.concatStringsSep "," [''sub-lang="de,en"'' "write-sub=" "write-auto-sub="]; + ytdl-raw-options = lib.concatStringsSep "," [ + ''sub-lang="de,en"'' + "write-sub=" + "write-auto-sub=" + ]; screenshot-template = "%F-%wH%wM%wS-%#04n"; script-opts = "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp"; ao = "pulse"; # no pipewire for me :( diff --git a/configs/neovim.nix b/configs/neovim.nix index 0b9b60c..40815a9 100644 --- a/configs/neovim.nix +++ b/configs/neovim.nix @@ -3,12 +3,16 @@ lib, config, ... -}: let - vim-kmein = (pkgs.vim-kmein.override { - # stylixColors = config.lib.stylix.colors; - colorscheme = "base16-gruvbox-dark-medium"; - }); -in { +}: +let + vim-kmein = ( + pkgs.vim-kmein.override { + # stylixColors = config.lib.stylix.colors; + colorscheme = "base16-gruvbox-dark-medium"; + } + ); +in +{ environment.variables.EDITOR = lib.getExe vim-kmein; environment.shellAliases.vi = "nvim"; environment.shellAliases.vim = "nvim"; diff --git a/configs/networkmanager.nix b/configs/networkmanager.nix index 03e2d00..1a07fbf 100644 --- a/configs/networkmanager.nix +++ b/configs/networkmanager.nix @@ -1,7 +1,8 @@ { pkgs, ... -}: { +}: +{ programs.nm-applet.enable = true; networking.networkmanager = { @@ -12,10 +13,10 @@ ]; wifi.macAddress = "random"; ethernet.macAddress = "random"; - unmanaged = ["docker*"]; + unmanaged = [ "docker*" ]; }; - users.users.me.extraGroups = ["networkmanager"]; + users.users.me.extraGroups = [ "networkmanager" ]; environment.systemPackages = [ pkgs.speedtest-cli diff --git a/configs/newsboat.nix b/configs/newsboat.nix index 7eb8e3e..df072bf 100644 --- a/configs/newsboat.nix +++ b/configs/newsboat.nix @@ -2,7 +2,8 @@ pkgs, config, ... -}: { +}: +{ environment.systemPackages = [ (pkgs.writers.writeDashBin "miniflux-watch-later" '' miniflux_api_token=$(cat ${config.age.secrets.miniflux-api-token.path}) diff --git a/configs/nix.nix b/configs/nix.nix index 571fb41..c79baa9 100644 --- a/configs/nix.nix +++ b/configs/nix.nix @@ -2,13 +2,14 @@ pkgs, inputs, ... -}: { +}: +{ nixpkgs = { config.allowUnfree = true; }; nix = { package = pkgs.nixVersions.stable; extraOptions = "experimental-features = nix-command flakes"; - nixPath = ["nixpkgs=${inputs.nixpkgs}"]; + nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; }; } diff --git a/configs/openweathermap.nix b/configs/openweathermap.nix index ccb6383..78c8bfa 100644 --- a/configs/openweathermap.nix +++ b/configs/openweathermap.nix @@ -2,21 +2,23 @@ pkgs, lib, ... -}: let +}: +let openweathermap-repo = pkgs.fetchFromGitHub { owner = "ip1981"; repo = "openweathermap"; rev = "9cfef7b14ac5af7109449b54b1cb352b4c76167a"; sha256 = "0sm43wicvw2fy7nq65s8vch6jjb5bszqr4ilnhibayamj4jcpw53"; }; - openweathermap = pkgs.haskellPackages.callCabal2nix "openweathermap" openweathermap-repo {}; + openweathermap = pkgs.haskellPackages.callCabal2nix "openweathermap" openweathermap-repo { }; openweathermap-key = lib.strings.fileContents ; -in { +in +{ nixpkgs.config.packageOverrides = pkgs: { weather = pkgs.writers.writeDashBin "weather" '' ${openweathermap}/bin/openweathermap --api-key ${openweathermap-key} "$@" ''; }; - environment.systemPackages = [pkgs.weather]; + environment.systemPackages = [ pkgs.weather ]; } diff --git a/configs/packages.nix b/configs/packages.nix index 05edc9c..87040ff 100644 --- a/configs/packages.nix +++ b/configs/packages.nix @@ -4,19 +4,22 @@ lib, inputs, ... -}: let - worldradio = pkgs.callPackage ../packages/worldradio.nix {}; +}: +let + worldradio = pkgs.callPackage ../packages/worldradio.nix { }; - zoteroStyle = { - name, - sha256, - }: { - name = "${name}.csl"; - path = pkgs.fetchurl { - url = "https://www.zotero.org/styles/${name}"; - inherit sha256; + zoteroStyle = + { + name, + sha256, + }: + { + name = "${name}.csl"; + path = pkgs.fetchurl { + url = "https://www.zotero.org/styles/${name}"; + inherit sha256; + }; }; - }; cslDirectory = pkgs.linkFarm "citation-styles" [ (zoteroStyle { name = "chicago-author-date-de"; @@ -32,7 +35,8 @@ }) ]; - astrolog = pkgs.astrolog.overrideAttrs (old: + astrolog = pkgs.astrolog.overrideAttrs ( + old: old // { installPhase = '' @@ -51,8 +55,10 @@ /^:I /s/80/120/ # wider text output ' $out/astrolog/astrolog.as ''; - }); -in { + } + ); +in +{ home-manager.users.me.home.file = { ".csl".source = cslDirectory; ".local/share/pandoc/csl".source = cslDirectory; # as of pandoc 2.11, it includes citeproc @@ -233,7 +239,11 @@ in { go texlive.combined.scheme-full latexrun - (aspellWithDicts (dict: [dict.de dict.en dict.en-computers])) + (aspellWithDicts (dict: [ + dict.de + dict.en + dict.en-computers + ])) # haskellPackages.pandoc-citeproc text2pdf lowdown diff --git a/configs/polkit.nix b/configs/polkit.nix index 3763f85..8b321bb 100644 --- a/configs/polkit.nix +++ b/configs/polkit.nix @@ -1,6 +1,8 @@ -{config, ...}: let +{ config, ... }: +let user = config.users.users.me.name; -in { +in +{ security.polkit.extraConfig = '' polkit.addRule(function(action, subject) { if (subject.user == "${user}" && action.id == "org.freedesktop.systemd1.manage-units") { diff --git a/configs/power-action.nix b/configs/power-action.nix index b466908..dd5919d 100644 --- a/configs/power-action.nix +++ b/configs/power-action.nix @@ -2,9 +2,11 @@ pkgs, config, ... -}: let +}: +let suspend = pkgs.writers.writeDash "suspend" "${pkgs.systemd}/bin/systemctl suspend"; -in { +in +{ services.power-action = { enable = true; plans.suspend = { diff --git a/configs/printing.nix b/configs/printing.nix index 7d23837..bc92b71 100644 --- a/configs/printing.nix +++ b/configs/printing.nix @@ -1,9 +1,11 @@ -{pkgs, lib, ...}: let +{ pkgs, lib, ... }: +let hp-driver = pkgs.hplip; -in { +in +{ services.printing = { enable = true; - drivers = [hp-driver]; + drivers = [ hp-driver ]; }; environment.systemPackages = [ @@ -30,7 +32,6 @@ in { ]; } /* -HP/hp-officejet_4650_series.ppd.gz -drv:///hp/hpcups.drv/hp-officejet_4650_series.ppd + HP/hp-officejet_4650_series.ppd.gz + drv:///hp/hpcups.drv/hp-officejet_4650_series.ppd */ - diff --git a/configs/retiolum.nix b/configs/retiolum.nix index 180b274..be46d85 100644 --- a/configs/retiolum.nix +++ b/configs/retiolum.nix @@ -2,8 +2,11 @@ config, pkgs, ... -}: { - networking.hosts = {"42:0:ca48:f98f:63d7:31ce:922b:245d" = ["go"];}; +}: +{ + networking.hosts = { + "42:0:ca48:f98f:63d7:31ce:922b:245d" = [ "go" ]; + }; services.tinc.networks.retiolum = { rsaPrivateKeyFile = config.age.secrets.retiolum-rsa.path; diff --git a/configs/rofi.nix b/configs/rofi.nix index c7c9d3b..e3b0277 100644 --- a/configs/rofi.nix +++ b/configs/rofi.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ home-manager.users.me.programs.rofi = { enable = true; pass = { @@ -13,6 +14,6 @@ help_color="#FF0000" ''; # help_color set by https://github.com/mrossinek/dotfiles/commit/13fc5f24caa78c8f20547bf473266879507f13bf }; - plugins = [pkgs.rofi-calc]; + plugins = [ pkgs.rofi-calc ]; }; } diff --git a/configs/sound.nix b/configs/sound.nix index 295d83c..e721b26 100644 --- a/configs/sound.nix +++ b/configs/sound.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ services.pipewire = { enable = true; alsa = { @@ -9,7 +10,7 @@ jack.enable = true; }; - systemd.user.services.pipewire-pulse.path = [pkgs.pulseaudio]; + systemd.user.services.pipewire-pulse.path = [ pkgs.pulseaudio ]; services.avahi = { enable = true; diff --git a/configs/stardict.nix b/configs/stardict.nix index 2982681..6ba75aa 100644 --- a/configs/stardict.nix +++ b/configs/stardict.nix @@ -3,7 +3,8 @@ lib, inputs, ... -}: let +}: +let locker = x: "https://c.krebsco.de/${x}"; dictionaries = { lojban = { @@ -105,40 +106,42 @@ sha256 = "0cx086zvb86bmz7i8vnsch4cj4fb0cp165g4hig4982zakj6f2jd"; }; }; - sanskrit = let - repo = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f"; - in { - BoehtlingkRoth = pkgs.fetchzip { - url = "${repo}/sa-head/german-entries/tars/Bohtlingk-and-Roth-Grosses-Petersburger-Worterbuch__2021-10-05_14-23-18Z__19MB.tar.gz"; - sha256 = "13414a8rgd7hd5ffar6nl68nk3ys60wjkgb7m11hp0ahaasmf6ly"; - stripRoot = false; + sanskrit = + let + repo = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f"; + in + { + BoehtlingkRoth = pkgs.fetchzip { + url = "${repo}/sa-head/german-entries/tars/Bohtlingk-and-Roth-Grosses-Petersburger-Worterbuch__2021-10-05_14-23-18Z__19MB.tar.gz"; + sha256 = "13414a8rgd7hd5ffar6nl68nk3ys60wjkgb7m11hp0ahaasmf6ly"; + stripRoot = false; + }; + BoehtlingkRothKurz = pkgs.fetchzip { + url = "${repo}/sa-head/german-entries/tars/Bohtlingk-Sanskrit-Worterbuch-in-kurzerer-Fassung__2021-10-05_14-23-18Z__10MB.tar.gz"; + sha256 = "15yx31yrk40k9nn6kaysp4pprzj8dpd13dj3wafklc3izm8lr2wq"; + stripRoot = false; + }; + MonierWilliams = pkgs.fetchzip { + url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/mw-cologne__2021-10-06_00-16-23Z__16MB.tar.gz"; + sha256 = "0p99ybxwxmmd94hf035hvm2hhnfy84av7qq79xf28bh2rbx6s9ng"; + stripRoot = false; + }; + MonierWilliamsEnglish = pkgs.fetchzip { + url = "${repo}/en-head/tars/mw-english-sanskrit__2021-10-05_14-23-18Z__3MB.tar.gz"; + sha256 = "09a61hhii4b1m2fkrlh4rm2xnlgwrllh84iypbc6wyj00w9jkl3x"; + stripRoot = false; + }; + Borooah = pkgs.fetchzip { + url = "${repo}/en-head/tars/borooah__2021-10-05_14-23-18Z__2MB.tar.gz"; + sha256 = "0qmmfbynqgv125v48383i51ky9yi69zibhh7vwk95gyar2yrprn2"; + stripRoot = false; + }; + ApteEnglish = pkgs.fetchzip { + url = "${repo}/en-head/tars/apte-english-sanskrit-cologne__2021-10-06_00-12-51Z__1MB.tar.gz"; + sha256 = "064ysm24ydc534ca689y5i2flnra8jkmh8zn0gsb6n8hdsb0d1lq"; + stripRoot = false; + }; }; - BoehtlingkRothKurz = pkgs.fetchzip { - url = "${repo}/sa-head/german-entries/tars/Bohtlingk-Sanskrit-Worterbuch-in-kurzerer-Fassung__2021-10-05_14-23-18Z__10MB.tar.gz"; - sha256 = "15yx31yrk40k9nn6kaysp4pprzj8dpd13dj3wafklc3izm8lr2wq"; - stripRoot = false; - }; - MonierWilliams = pkgs.fetchzip { - url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/mw-cologne__2021-10-06_00-16-23Z__16MB.tar.gz"; - sha256 = "0p99ybxwxmmd94hf035hvm2hhnfy84av7qq79xf28bh2rbx6s9ng"; - stripRoot = false; - }; - MonierWilliamsEnglish = pkgs.fetchzip { - url = "${repo}/en-head/tars/mw-english-sanskrit__2021-10-05_14-23-18Z__3MB.tar.gz"; - sha256 = "09a61hhii4b1m2fkrlh4rm2xnlgwrllh84iypbc6wyj00w9jkl3x"; - stripRoot = false; - }; - Borooah = pkgs.fetchzip { - url = "${repo}/en-head/tars/borooah__2021-10-05_14-23-18Z__2MB.tar.gz"; - sha256 = "0qmmfbynqgv125v48383i51ky9yi69zibhh7vwk95gyar2yrprn2"; - stripRoot = false; - }; - ApteEnglish = pkgs.fetchzip { - url = "${repo}/en-head/tars/apte-english-sanskrit-cologne__2021-10-06_00-12-51Z__1MB.tar.gz"; - sha256 = "064ysm24ydc534ca689y5i2flnra8jkmh8zn0gsb6n8hdsb0d1lq"; - stripRoot = false; - }; - }; oed = { OED1 = pkgs.fetchzip { url = locker "stardict-Oxford_English_Dictionary_2nd_Ed._P1-2.4.2.tar.bz2"; @@ -178,9 +181,11 @@ }; }; - makeStardictDataDir = dicts: pkgs.linkFarm "dictionaries" (lib.mapAttrsToList (name: path: {inherit name path;}) dicts); + makeStardictDataDir = + dicts: pkgs.linkFarm "dictionaries" (lib.mapAttrsToList (name: path: { inherit name path; }) dicts); - makeStardict = name: dicts: + makeStardict = + name: dicts: pkgs.writers.writeDashBin name '' set -efu export SDCV_PAGER=${toString sdcvPager} @@ -188,7 +193,13 @@ ''; sdcvPager = pkgs.writers.writeDash "sdcvPager" '' - export PATH=${lib.makeBinPath [pkgs.gnused pkgs.ncurses pkgs.less]} + export PATH=${ + lib.makeBinPath [ + pkgs.gnused + pkgs.ncurses + pkgs.less + ] + } sed " s!1!¹!gI s!2!²!gI @@ -291,7 +302,8 @@ s!]*>!!gI " | less -FR ''; -in { +in +{ # environment.etc.stardict.source = toString (makeStardictDataDir ({ # Crum = pkgs.fetchzip { # url = "http://download.huzheng.org/misc/stardict-Coptic-English_all_dialects-2.4.2.tar.bz2"; @@ -325,64 +337,63 @@ in { ]; } /* -https://github.com/latin-dict/Georges1910/releases/download/v1.0/Georges1910-stardict.zip -https://github.com/nikita-moor/latin-dictionary/releases/download/2020-02-14/LiddellScott1940-stardict.zip -http://download.huzheng.org/bigdict/stardict-Cambridge_Dictionary_of_American_Idioms-2.4.2.tar.bz2 -http://download.huzheng.org/bigdict/stardict-Concise_Oxford_Thesaurus_2nd_Ed-2.4.2.tar.bz2 -http://download.huzheng.org/bigdict/stardict-Urban_Dictionary_P1-2.4.2.tar.bz2 -http://download.huzheng.org/bigdict/stardict-Urban_Dictionary_P2-2.4.2.tar.bz2 + https://github.com/latin-dict/Georges1910/releases/download/v1.0/Georges1910-stardict.zip + https://github.com/nikita-moor/latin-dictionary/releases/download/2020-02-14/LiddellScott1940-stardict.zip + http://download.huzheng.org/bigdict/stardict-Cambridge_Dictionary_of_American_Idioms-2.4.2.tar.bz2 + http://download.huzheng.org/bigdict/stardict-Concise_Oxford_Thesaurus_2nd_Ed-2.4.2.tar.bz2 + http://download.huzheng.org/bigdict/stardict-Urban_Dictionary_P1-2.4.2.tar.bz2 + http://download.huzheng.org/bigdict/stardict-Urban_Dictionary_P2-2.4.2.tar.bz2 -Duden_Rechtschreibung = pkgs.fetchzip { - url = "http://download.huzheng.org/babylon/german/stardict-Duden_Rechtschreibung-2.4.2.tar.bz2"; - sha256 = "0xiprb45s88w62rn8rlbjrsagbiliay9hszsiy20glwabf6zsfji"; -}; -Duden = pkgs.fetchzip { - url = "http://download.huzheng.org/de/stardict-duden-2.4.2.tar.bz2"; - sha256 = "049i4ynfqqxykv1nlkyks94mvn14s22qdax5gg7hx1ks5y4xw64j"; -}; -FreeOnlineDictionaryOfComputing = pkgs.fetchzip { - url = "http://download.huzheng.org/dict.org/stardict-dictd_www.dict.org_foldoc-2.4.2.tar.bz2"; - sha256 = "1lw2i8dzxpx929cpgvv0x366dnh4drr10wzqmrhcd0kvwglqawgm"; -}; -Cappeller = pkgs.fetchzip { - url = "${repo}/sa-head/german-entries/tars/capeller-sanskrit-german__2021-10-05_14-23-18Z__1MB.tar.gz"; - sha256 = "0jwrj2aih2lrcjg0lqm8jrvq9vsas9s8j4c9ggbg2n0jyz03kci3"; - stripRoot = false; -}; -Yates = pkgs.fetchzip { - url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/yates__2021-10-05_14-23-18Z__2MB.tar.gz"; - sha256 = "1k7gbalysf48pwa06zfykrqhdk466g35xy64b30k4z8bybgdn8z2"; - stripRoot = false; -}; -Wilson = pkgs.fetchzip { - url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/wilson__2021-10-05_14-23-18Z__3MB.tar.gz"; - sha256 = "0r5z1xif56zlw9r2jp3fvwmcjv4f2fhd9r17j30nah9awx2m1isg"; - stripRoot = false; -}; -SpokenSanskrit = pkgs.fetchzip { - url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/spokensanskrit__2019-01-12_05-13-52Z__12MB.tar.gz"; - sha256 = "0x8j657mawvdcyd1knzvf33yp15z77d661n3h6g9hcj7wn9s5xyk"; - stripRoot = false; -}; -Grassmann = pkgs.fetchzip { - url = "${repo}/sa-head/german-entries/tars/grassman-sanskrit-german__2021-10-05_14-23-18Z__2MB.tar.gz"; - sha256 = "0jalsykaxkl6wzrky72lz8g3jdz26lmjpyibbfaf7a5vvnr55k02"; - stripRoot = false; -}; -Benfey = pkgs.fetchzip { - url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/benfey__2021-10-05_14-23-18Z__2MB.tar.gz"; - sha256 = "0lj3hgphqgnihn482g9kgjwbvdrcd38vc29v1fi36srn08qdhvcb"; - stripRoot = false; -}; -ApteSa = pkgs.fetchzip { - url = "${repo}/sa-head/en-entries/tars/apte-sa__2021-12-18_13-20-56Z__6MB.tar.gz"; - sha256 = "0cq1dd02d1pvmjnibbs2cscifjnk2z0nqccf5yzzilxkzsrarh32"; - stripRoot = false; -}; -MacDonell = pkgs.fetchzip { - url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/macdonell__2021-10-05_14-23-18Z__2MB.tar.gz"; - sha256 = "1yzmj0393mxvjv4n2lnvd2c722v2bmxxiyq7pscdwni3bxip3h8s"; - stripRoot = false; -}; + Duden_Rechtschreibung = pkgs.fetchzip { + url = "http://download.huzheng.org/babylon/german/stardict-Duden_Rechtschreibung-2.4.2.tar.bz2"; + sha256 = "0xiprb45s88w62rn8rlbjrsagbiliay9hszsiy20glwabf6zsfji"; + }; + Duden = pkgs.fetchzip { + url = "http://download.huzheng.org/de/stardict-duden-2.4.2.tar.bz2"; + sha256 = "049i4ynfqqxykv1nlkyks94mvn14s22qdax5gg7hx1ks5y4xw64j"; + }; + FreeOnlineDictionaryOfComputing = pkgs.fetchzip { + url = "http://download.huzheng.org/dict.org/stardict-dictd_www.dict.org_foldoc-2.4.2.tar.bz2"; + sha256 = "1lw2i8dzxpx929cpgvv0x366dnh4drr10wzqmrhcd0kvwglqawgm"; + }; + Cappeller = pkgs.fetchzip { + url = "${repo}/sa-head/german-entries/tars/capeller-sanskrit-german__2021-10-05_14-23-18Z__1MB.tar.gz"; + sha256 = "0jwrj2aih2lrcjg0lqm8jrvq9vsas9s8j4c9ggbg2n0jyz03kci3"; + stripRoot = false; + }; + Yates = pkgs.fetchzip { + url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/yates__2021-10-05_14-23-18Z__2MB.tar.gz"; + sha256 = "1k7gbalysf48pwa06zfykrqhdk466g35xy64b30k4z8bybgdn8z2"; + stripRoot = false; + }; + Wilson = pkgs.fetchzip { + url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/wilson__2021-10-05_14-23-18Z__3MB.tar.gz"; + sha256 = "0r5z1xif56zlw9r2jp3fvwmcjv4f2fhd9r17j30nah9awx2m1isg"; + stripRoot = false; + }; + SpokenSanskrit = pkgs.fetchzip { + url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/spokensanskrit__2019-01-12_05-13-52Z__12MB.tar.gz"; + sha256 = "0x8j657mawvdcyd1knzvf33yp15z77d661n3h6g9hcj7wn9s5xyk"; + stripRoot = false; + }; + Grassmann = pkgs.fetchzip { + url = "${repo}/sa-head/german-entries/tars/grassman-sanskrit-german__2021-10-05_14-23-18Z__2MB.tar.gz"; + sha256 = "0jalsykaxkl6wzrky72lz8g3jdz26lmjpyibbfaf7a5vvnr55k02"; + stripRoot = false; + }; + Benfey = pkgs.fetchzip { + url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/benfey__2021-10-05_14-23-18Z__2MB.tar.gz"; + sha256 = "0lj3hgphqgnihn482g9kgjwbvdrcd38vc29v1fi36srn08qdhvcb"; + stripRoot = false; + }; + ApteSa = pkgs.fetchzip { + url = "${repo}/sa-head/en-entries/tars/apte-sa__2021-12-18_13-20-56Z__6MB.tar.gz"; + sha256 = "0cq1dd02d1pvmjnibbs2cscifjnk2z0nqccf5yzzilxkzsrarh32"; + stripRoot = false; + }; + MacDonell = pkgs.fetchzip { + url = "https://github.com/indic-dict/stardict-sanskrit/raw/4ebd2d3db5820f7cbe3a649c3d5aa8f83d19b29f/sa-head/en-entries/tars/macdonell__2021-10-05_14-23-18Z__2MB.tar.gz"; + sha256 = "1yzmj0393mxvjv4n2lnvd2c722v2bmxxiyq7pscdwni3bxip3h8s"; + stripRoot = false; + }; */ - diff --git a/configs/stylix.nix b/configs/stylix.nix index a3ce601..3f7bb56 100644 --- a/configs/stylix.nix +++ b/configs/stylix.nix @@ -4,15 +4,17 @@ lib, inputs, ... -}: let - generatedWallpaper = pkgs.runCommand "wallpaper.png" {} '' +}: +let + generatedWallpaper = pkgs.runCommand "wallpaper.png" { } '' ${inputs.wallpaper-generator.packages.x86_64-linux.wp-gen}/bin/wallpaper-generator lines \ --output $out \ - ${lib.concatMapStringsSep " " - (n: "--base0${lib.toHexString n}=${config.lib.stylix.colors.withHashtag."base0${lib.toHexString n}"}") - (lib.range 0 15)} + ${lib.concatMapStringsSep " " ( + n: "--base0${lib.toHexString n}=${config.lib.stylix.colors.withHashtag."base0${lib.toHexString n}"}" + ) (lib.range 0 15)} ''; -in { +in +{ # https://danth.github.io/stylix/tricks.html # stylix.image = inputs.wallpapers.outPath + "/meteora/rodrigo-soares-250630.jpg"; stylix.enable = true; diff --git a/configs/sudo.nix b/configs/sudo.nix index a122336..1e58b2d 100644 --- a/configs/sudo.nix +++ b/configs/sudo.nix @@ -6,5 +6,5 @@ ''; }; - users.users.me.extraGroups = ["wheel"]; + users.users.me.extraGroups = [ "wheel" ]; } diff --git a/configs/tlp.nix b/configs/tlp.nix index c8aafab..eae2144 100644 --- a/configs/tlp.nix +++ b/configs/tlp.nix @@ -2,13 +2,20 @@ config, pkgs, ... -}: { +}: +{ boot.extraModulePackages = with config.boot.kernelPackages; [ tp_smapi acpi_call ]; - boot.kernelModules = ["tp_smapi" "acpi_call"]; - environment.systemPackages = [pkgs.tpacpi-bat pkgs.powertop]; + boot.kernelModules = [ + "tp_smapi" + "acpi_call" + ]; + environment.systemPackages = [ + pkgs.tpacpi-bat + pkgs.powertop + ]; services.tlp = { enable = true; diff --git a/configs/tmux.nix b/configs/tmux.nix index c9492b3..bdc12f8 100644 --- a/configs/tmux.nix +++ b/configs/tmux.nix @@ -1,4 +1,5 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ environment.systemPackages = [ pkgs.tmuxp pkgs.reptyr # move programs over to a tmux session diff --git a/configs/tor.nix b/configs/tor.nix index 0ccbfcb..1813cb6 100644 --- a/configs/tor.nix +++ b/configs/tor.nix @@ -1,5 +1,9 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ services.tor.enable = true; services.tor.client.enable = true; - environment.systemPackages = [pkgs.tor pkgs.torsocks]; + environment.systemPackages = [ + pkgs.tor + pkgs.torsocks + ]; } diff --git a/configs/uni.nix b/configs/uni.nix index 481b990..28896d3 100644 --- a/configs/uni.nix +++ b/configs/uni.nix @@ -3,20 +3,26 @@ pkgs, lib, ... -}: let +}: +let username = "meinhak99"; - fu-defaults = let mailhost = "mail.zedat.fu-berlin.de"; in { - imap.host = mailhost; - imap.port = 993; - imap.tls.enable = true; - smtp.host = mailhost; - smtp.port = 465; - smtp.tls.enable = true; - folders.drafts = "Entwürfe"; - folders.sent = "Gesendet"; - folders.trash = "Papierkorb"; - }; -in { + fu-defaults = + let + mailhost = "mail.zedat.fu-berlin.de"; + in + { + imap.host = mailhost; + imap.port = 993; + imap.tls.enable = true; + smtp.host = mailhost; + smtp.port = 465; + smtp.tls.enable = true; + folders.drafts = "Entwürfe"; + folders.sent = "Gesendet"; + folders.trash = "Papierkorb"; + }; +in +{ home-manager.users.me = { programs.ssh = { matchBlocks = { @@ -28,31 +34,33 @@ in { }; }; accounts.email.accounts = { - letos = - lib.recursiveUpdate pkgs.lib.niveum.email.defaults - { - userName = "slfletos"; - address = "letos.sprachlit@hu-berlin.de"; - passwordCommand = "${pkgs.coreutils}/bin/cat ${config.age.secrets.email-password-letos.path}"; - imap.host = "mailbox.cms.hu-berlin.de"; - imap.port = 993; - smtp.host = "mailhost.cms.hu-berlin.de"; - smtp.port = 25; - smtp.tls.useStartTls = true; - }; - fu = - lib.recursiveUpdate pkgs.lib.niveum.email.defaults - (lib.recursiveUpdate fu-defaults - (let userName = "meinhak99"; in { + letos = lib.recursiveUpdate pkgs.lib.niveum.email.defaults { + userName = "slfletos"; + address = "letos.sprachlit@hu-berlin.de"; + passwordCommand = "${pkgs.coreutils}/bin/cat ${config.age.secrets.email-password-letos.path}"; + imap.host = "mailbox.cms.hu-berlin.de"; + imap.port = 993; + smtp.host = "mailhost.cms.hu-berlin.de"; + smtp.port = 25; + smtp.tls.useStartTls = true; + }; + fu = lib.recursiveUpdate pkgs.lib.niveum.email.defaults ( + lib.recursiveUpdate fu-defaults ( + let + userName = "meinhak99"; + in + { userName = userName; address = "kieran.meinhardt@fu-berlin.de"; - aliases = ["${userName}@fu-berlin.de"]; + aliases = [ "${userName}@fu-berlin.de" ]; passwordCommand = "${pkgs.coreutils}/bin/cat ${config.age.secrets.email-password-meinhak99.path}"; himalaya = { enable = true; settings.backend = "imap"; }; - })); + } + ) + ); }; }; @@ -82,59 +90,57 @@ in { system.fsPackages = [ pkgs.sshfs ]; # https://www.zedat.fu-berlin.de/tip4u_157.pdf - fileSystems = let - fu-berlin-cifs-options = [ - "uid=${toString config.users.users.me.uid}" - "gid=${toString config.users.groups.users.gid}" - "rw" - "nounix" - "domain=fu-berlin" - "noauto" - "x-systemd.automount" - "x-systemd.device-timeout=1" - "x-systemd.idle-timeout=1min" - ]; + fileSystems = + let + fu-berlin-cifs-options = [ + "uid=${toString config.users.users.me.uid}" + "gid=${toString config.users.groups.users.gid}" + "rw" + "nounix" + "domain=fu-berlin" + "noauto" + "x-systemd.automount" + "x-systemd.device-timeout=1" + "x-systemd.idle-timeout=1min" + ]; - firstCharacter = lib.strings.substring 0 1; + firstCharacter = lib.strings.substring 0 1; - home-directory-mount = user: { - "${pkgs.lib.niveum.remoteDir}/fu/${user}/home" = { - device = "${user}@login.zedat.fu-berlin.de:/home/${firstCharacter user}/${user}"; - fsType = "sshfs"; - options = [ - "allow_other" - "_netdev" - "x-systemd.automount" - "reconnect" - "ServerAliveInterval=15" - "IdentityFile=${config.age.secrets.fu-sftp-key.path}" - ]; + home-directory-mount = user: { + "${pkgs.lib.niveum.remoteDir}/fu/${user}/home" = { + device = "${user}@login.zedat.fu-berlin.de:/home/${firstCharacter user}/${user}"; + fsType = "sshfs"; + options = [ + "allow_other" + "_netdev" + "x-systemd.automount" + "reconnect" + "ServerAliveInterval=15" + "IdentityFile=${config.age.secrets.fu-sftp-key.path}" + ]; + }; }; - }; - in home-directory-mount "meinhak99"; + in + home-directory-mount "meinhak99"; environment.systemPackages = [ (pkgs.writers.writeDashBin "hu-vpn-split" '' ${pkgs.openfortivpn}/bin/openfortivpn \ --password="$(cat "${config.age.secrets.email-password-letos.path}")" \ - --config=${ - pkgs.writeText "hu-berlin-split.config" '' + --config=${pkgs.writeText "hu-berlin-split.config" '' host = forti-ssl.vpn.hu-berlin.de port = 443 username = slfletos@split_tunnel - '' - } + ''} '') (pkgs.writers.writeDashBin "hu-vpn-full" '' ${pkgs.openfortivpn}/bin/openfortivpn \ --password="$(cat "${config.age.secrets.email-password-letos.path}")" \ - --config=${ - pkgs.writeText "hu-berlin-full.config" '' + --config=${pkgs.writeText "hu-berlin-full.config" '' host = forti-ssl.vpn.hu-berlin.de port = 443 username = slfletos@tunnel_all - '' - } + ''} '') (pkgs.writers.writeDashBin "fu-vpn" '' if ${pkgs.wirelesstools}/bin/iwgetid | ${pkgs.gnugrep}/bin/grep --invert-match eduroam diff --git a/configs/vscode.nix b/configs/vscode.nix index 8210338..b9b9f13 100644 --- a/configs/vscode.nix +++ b/configs/vscode.nix @@ -1 +1,4 @@ -{pkgs, ...}: {environment.systemPackages = [pkgs.vscode];} +{ pkgs, ... }: +{ + environment.systemPackages = [ pkgs.vscode ]; +} diff --git a/configs/wallpaper.nix b/configs/wallpaper.nix index 33a8ead..98e4b30 100644 --- a/configs/wallpaper.nix +++ b/configs/wallpaper.nix @@ -2,14 +2,16 @@ pkgs, lib, ... -}: let +}: +let # url = "http://wallpaper.r/realwallpaper-krebs-stars-berlin.png"; url = "http://wallpaper.r/realwallpaper-krebs.png"; stateDir = "~/.cache/wallpaper"; -in { +in +{ systemd.user.services.wallpaper = { - wantedBy = ["graphical-session.target"]; - after = ["network.target"]; + wantedBy = [ "graphical-session.target" ]; + after = [ "network.target" ]; script = '' set -euf diff --git a/configs/watson.nix b/configs/watson.nix index 67a1e05..869b28b 100644 --- a/configs/watson.nix +++ b/configs/watson.nix @@ -2,8 +2,9 @@ config, pkgs, ... -}: { - environment.systemPackages = [pkgs.watson]; +}: +{ + environment.systemPackages = [ pkgs.watson ]; environment.variables.WATSON_DIR = "${config.users.users.me.home}/cloud/Seafile/Documents/watson"; } diff --git a/configs/zsh.nix b/configs/zsh.nix index 0cb9ef2..32116cb 100644 --- a/configs/zsh.nix +++ b/configs/zsh.nix @@ -2,88 +2,97 @@ config, pkgs, ... -}: let +}: +let promptColours.success = "cyan"; promptColours.failure = "red"; -in { - programs.zsh = let - zsh-completions = pkgs.fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-completions"; - rev = "cf565254e26bb7ce03f51889e9a29953b955b1fb"; - sha256 = "1yf4rz99acdsiy0y1v3bm65xvs2m0sl92ysz0rnnrlbd5amn283l"; +in +{ + programs.zsh = + let + zsh-completions = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-completions"; + rev = "cf565254e26bb7ce03f51889e9a29953b955b1fb"; + sha256 = "1yf4rz99acdsiy0y1v3bm65xvs2m0sl92ysz0rnnrlbd5amn283l"; + }; + in + { + enable = true; + enableCompletion = true; + autosuggestions.enable = true; + syntaxHighlighting.enable = true; + syntaxHighlighting.highlighters = [ + "main" + "brackets" + "pattern" + "line" + ]; + interactiveShellInit = '' + setopt INTERACTIVE_COMMENTS CORRECT + setopt MULTIOS + setopt AUTO_NAME_DIRS + setopt AUTOCD CDABLE_VARS + setopt HIST_IGNORE_ALL_DUPS + setopt VI + setopt AUTO_MENU + setopt COMPLETE_IN_WORD + setopt ALWAYS_TO_END + unsetopt NOMATCH + unsetopt MENU_COMPLETE + + zstyle ':completion:*:*:*:*:*' menu select + zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' special-dirs true + zstyle ':completion:*' list-colors \'\' + zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' + zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" + zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories + + export KEYTIMEOUT=1 + + hash -d nixos=/etc/nixos niveum=${config.users.users.me.home}/sync/src/niveum + + autoload -U zmv run-help edit-command-line + + fpath=(${zsh-completions}/src $fpath) + ''; + promptInit = '' + autoload -Uz vcs_info + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' check-for-changes true + zstyle ':vcs_info:*' stagedstr '%F{green}+%f' + zstyle ':vcs_info:*' unstagedstr '%F{red}~%f' + zstyle ':vcs_info:*' use-prompt-escapes true + zstyle ':vcs_info:*' formats "%c%u%F{cyan}%b%f" + zstyle ':vcs_info:*' actionformats "(%a) %c%u%F{cyan}%b%f" + + precmd () { + vcs_info + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] || [ -n "$SSH_CONNECTION" ]; then + RPROMPT="$(hostname)" + else + RPROMPT="$vcs_info_msg_0_" + fi + if [[ -n $IN_NIX_SHELL ]]; then + PROMPT='%B%~%b %(?.%F{${promptColours.success}}.%F{${promptColours.failure}})λ%f ' + else + PROMPT='%B%~%b %(?.%F{${promptColours.success}}.%F{${promptColours.failure}})%#%f ' + fi + print -Pn "\e]2;%n@%M:%~\a" # title bar prompt + } + + zle-keymap-select zle-line-init () { + case $KEYMAP in + vicmd) print -n '\e]12;green\a';; + viins|main) print -n '\e]12;gray\a';; + esac + } + + zle -N zle-line-init + zle -N zle-keymap-select + zle -N edit-command-line + bindkey -M vicmd v edit-command-line + ''; }; - in { - enable = true; - enableCompletion = true; - autosuggestions.enable = true; - syntaxHighlighting.enable = true; - syntaxHighlighting.highlighters = ["main" "brackets" "pattern" "line"]; - interactiveShellInit = '' - setopt INTERACTIVE_COMMENTS CORRECT - setopt MULTIOS - setopt AUTO_NAME_DIRS - setopt AUTOCD CDABLE_VARS - setopt HIST_IGNORE_ALL_DUPS - setopt VI - setopt AUTO_MENU - setopt COMPLETE_IN_WORD - setopt ALWAYS_TO_END - unsetopt NOMATCH - unsetopt MENU_COMPLETE - - zstyle ':completion:*:*:*:*:*' menu select - zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' - zstyle ':completion:*' special-dirs true - zstyle ':completion:*' list-colors \'\' - zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' - zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" - zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories - - export KEYTIMEOUT=1 - - hash -d nixos=/etc/nixos niveum=${config.users.users.me.home}/sync/src/niveum - - autoload -U zmv run-help edit-command-line - - fpath=(${zsh-completions}/src $fpath) - ''; - promptInit = '' - autoload -Uz vcs_info - zstyle ':vcs_info:*' enable git - zstyle ':vcs_info:*' check-for-changes true - zstyle ':vcs_info:*' stagedstr '%F{green}+%f' - zstyle ':vcs_info:*' unstagedstr '%F{red}~%f' - zstyle ':vcs_info:*' use-prompt-escapes true - zstyle ':vcs_info:*' formats "%c%u%F{cyan}%b%f" - zstyle ':vcs_info:*' actionformats "(%a) %c%u%F{cyan}%b%f" - - precmd () { - vcs_info - if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] || [ -n "$SSH_CONNECTION" ]; then - RPROMPT="$(hostname)" - else - RPROMPT="$vcs_info_msg_0_" - fi - if [[ -n $IN_NIX_SHELL ]]; then - PROMPT='%B%~%b %(?.%F{${promptColours.success}}.%F{${promptColours.failure}})λ%f ' - else - PROMPT='%B%~%b %(?.%F{${promptColours.success}}.%F{${promptColours.failure}})%#%f ' - fi - print -Pn "\e]2;%n@%M:%~\a" # title bar prompt - } - - zle-keymap-select zle-line-init () { - case $KEYMAP in - vicmd) print -n '\e]12;green\a';; - viins|main) print -n '\e]12;gray\a';; - esac - } - - zle -N zle-line-init - zle -N zle-keymap-select - zle -N edit-command-line - bindkey -M vicmd v edit-command-line - ''; - }; } diff --git a/flake.nix b/flake.nix index a220396..2c62e6a 100644 --- a/flake.nix +++ b/flake.nix @@ -452,6 +452,8 @@ }; }; + formatter = eachSupportedSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-tree); + packages = eachSupportedSystem ( system: let diff --git a/lib/panoptikon.nix b/lib/panoptikon.nix index 140fecf..2b08cec 100644 --- a/lib/panoptikon.nix +++ b/lib/panoptikon.nix @@ -2,39 +2,43 @@ pkgs, lib, ... -}: { +}: +{ # watcher scripts - url = address: + url = + address: pkgs.writers.writeDash "watch-url" '' ${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} \ | ${pkgs.python3Packages.html2text}/bin/html2text --decode-errors=ignore ''; - urlSelector = selector: address: + urlSelector = + selector: address: pkgs.writers.writeDash "watch-url-selector" '' ${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} \ | ${pkgs.htmlq}/bin/htmlq ${lib.escapeShellArg selector} \ | ${pkgs.python3Packages.html2text}/bin/html2text ''; - urlJSON = {jqScript ? "."}: address: + urlJSON = + { + jqScript ? ".", + }: + address: pkgs.writers.writeDash "watch-url-json" '' ${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} | ${pkgs.jq}/bin/jq -f ${pkgs.writeText "script.jq" jqScript} ''; # reporter scripts - kpaste-irc = { - target, - retiolumLink ? false, - server ? "irc.r", - messagePrefix ? "change detected: ", - nick ? ''"$PANOPTIKON_WATCHER"-watcher'', - }: + kpaste-irc = + { + target, + retiolumLink ? false, + server ? "irc.r", + messagePrefix ? "change detected: ", + nick ? ''"$PANOPTIKON_WATCHER"-watcher'', + }: pkgs.writers.writeDash "kpaste-irc-reporter" '' KPASTE_CONTENT_TYPE=text/plain ${pkgs.kpaste}/bin/kpaste \ - | ${pkgs.gnused}/bin/sed -n "${ - if retiolumLink - then "2" - else "3" - }s/^/${messagePrefix}/p" \ + | ${pkgs.gnused}/bin/sed -n "${if retiolumLink then "2" else "3"}s/^/${messagePrefix}/p" \ | ${pkgs.nur.repos.mic92.ircsink}/bin/ircsink \ --nick ${nick} \ --server ${server} \ diff --git a/modules/go-webring.nix b/modules/go-webring.nix index 52bee08..fb2546f 100644 --- a/modules/go-webring.nix +++ b/modules/go-webring.nix @@ -84,7 +84,11 @@ in Type = "simple"; ExecStart = '' ${lib.getExe cfg.package} \ - ${lib.optionalString (cfg.contactInstructions != null) ("--contact " + lib.escapeShellArg cfg.contactInstructions)} \ + ${ + lib.optionalString (cfg.contactInstructions != null) ( + "--contact " + lib.escapeShellArg cfg.contactInstructions + ) + } \ --host ${cfg.host} \ --index ${pkgs.writeText "index.html" cfg.homePageTemplate} \ --listen ${cfg.listenAddress} \ diff --git a/modules/moodle-dl.nix b/modules/moodle-dl.nix index 1392988..462f0b6 100644 --- a/modules/moodle-dl.nix +++ b/modules/moodle-dl.nix @@ -4,18 +4,20 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.services.moodle-dl; - json = pkgs.formats.json {}; + json = pkgs.formats.json { }; moodle-dl-json = json.generate "moodle-dl.json" cfg.settings; stateDirectoryDefault = "/var/lib/moodle-dl"; -in { +in +{ options = { services.moodle-dl = { enable = mkEnableOption "moodle-dl, a Moodle downloader"; settings = mkOption { - default = {}; + default = { }; type = json.type; description = '' Configuration for moodle-dl. For a full example, see @@ -69,11 +71,11 @@ in { group = "moodle-dl"; }; - users.groups.moodle-dl = {}; + users.groups.moodle-dl = { }; systemd.services.moodle-dl = { description = "A Moodle downloader that downloads course content"; - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; serviceConfig = mkMerge [ { Type = "oneshot"; @@ -83,11 +85,11 @@ in { ExecStart = "${cfg.package}/bin/moodle-dl ${lib.optionalString cfg.notifyOnly "--without-downloading-files"}"; ExecStartPre = pkgs.writers.writeDash "moodle-dl-config" "${pkgs.jq}/bin/jq -s '.[0] * .[1]' ${toString moodle-dl-json} ${toString cfg.tokensFile} > ${cfg.directory}/config.json"; } - (mkIf (cfg.directory == stateDirectoryDefault) {StateDirectory = "moodle-dl";}) + (mkIf (cfg.directory == stateDirectoryDefault) { StateDirectory = "moodle-dl"; }) ]; inherit (cfg) startAt; }; }; - meta.maintainers = [maintainers.kmein]; + meta.maintainers = [ maintainers.kmein ]; } diff --git a/modules/panoptikon.nix b/modules/panoptikon.nix index 2d48532..b5ce73f 100644 --- a/modules/panoptikon.nix +++ b/modules/panoptikon.nix @@ -3,65 +3,69 @@ lib, pkgs, ... -}: { +}: +{ options.services.panoptikon = { enable = lib.mkEnableOption "Generic command output / website watcher"; watchers = lib.mkOption { - type = lib.types.attrsOf (lib.types.submodule (watcher: { - options = { - script = lib.mkOption { - type = lib.types.path; - description = '' - A script whose stdout is to be watched. - ''; - example = '' - pkgs.writers.writeDash "github-meta" ''' - ''${pkgs.curl}/bin/curl -sSL https://api.github.com/meta | ''${pkgs.jq}/bin/jq - ''' - ''; + type = lib.types.attrsOf ( + lib.types.submodule (watcher: { + options = { + script = lib.mkOption { + type = lib.types.path; + description = '' + A script whose stdout is to be watched. + ''; + example = '' + pkgs.writers.writeDash "github-meta" ''' + ''${pkgs.curl}/bin/curl -sSL https://api.github.com/meta | ''${pkgs.jq}/bin/jq + ''' + ''; + }; + frequency = lib.mkOption { + type = lib.types.str; + description = '' + How often to run the script. See systemd.time(7) for more information about the format. + ''; + example = "*:0/3"; + default = "daily"; + }; + loadCredential = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = '' + This can be used to pass secrets to the systemd service without adding them to the nix store. + ''; + default = [ ]; + }; + reporters = lib.mkOption { + type = lib.types.listOf lib.types.path; + description = '' + A list of scripts that take the diff (if any) via stdin and report it (e.g. to IRC, Telegram or Prometheus). The name of the watcher will be in the $PANOPTIKON_WATCHER environment variable. + ''; + example = '' + [ + (pkgs.writers.writeDash "telegram-reporter" ''' + ''${pkgs.curl}/bin/curl -X POST https://api.telegram.org/bot''${TOKEN}/sendMessage \ + -d chat_id=123456 \ + -d text="$(cat)" + ''') + (pkgs.writers.writeDash "notify" ''' + ''${pkgs.libnotify}/bin/notify-send "$PANOPTIKON_WATCHER has changed." + ''') + ] + ''; + }; }; - frequency = lib.mkOption { - type = lib.types.str; - description = '' - How often to run the script. See systemd.time(7) for more information about the format. - ''; - example = "*:0/3"; - default = "daily"; - }; - loadCredential = lib.mkOption { - type = lib.types.listOf lib.types.str; - description = '' - This can be used to pass secrets to the systemd service without adding them to the nix store. - ''; - default = []; - }; - reporters = lib.mkOption { - type = lib.types.listOf lib.types.path; - description = '' - A list of scripts that take the diff (if any) via stdin and report it (e.g. to IRC, Telegram or Prometheus). The name of the watcher will be in the $PANOPTIKON_WATCHER environment variable. - ''; - example = '' - [ - (pkgs.writers.writeDash "telegram-reporter" ''' - ''${pkgs.curl}/bin/curl -X POST https://api.telegram.org/bot''${TOKEN}/sendMessage \ - -d chat_id=123456 \ - -d text="$(cat)" - ''') - (pkgs.writers.writeDash "notify" ''' - ''${pkgs.libnotify}/bin/notify-send "$PANOPTIKON_WATCHER has changed." - ''') - ] - ''; - }; - }; - config = {}; - })); + config = { }; + }) + ); }; }; - config = let - cfg = config.services.panoptikon; - in + config = + let + cfg = config.services.panoptikon; + in lib.mkIf cfg.enable { users.extraUsers.panoptikon = { isSystemUser = true; @@ -70,45 +74,50 @@ group = "panoptikon"; }; - users.extraGroups.panoptikon = {}; + users.extraGroups.panoptikon = { }; - systemd.timers = lib.attrsets.mapAttrs' (watcherName: _: + systemd.timers = lib.attrsets.mapAttrs' ( + watcherName: _: lib.nameValuePair "panoptikon-${watcherName}" { timerConfig.RandomizedDelaySec = toString (60 * 60); - }) - cfg.watchers; + } + ) cfg.watchers; - systemd.services = - lib.attrsets.mapAttrs' (watcherName: watcherOptions: - lib.nameValuePair "panoptikon-${watcherName}" { - enable = true; - startAt = watcherOptions.frequency; - serviceConfig = { - Type = "oneshot"; - User = "panoptikon"; - Group = "panoptikon"; - WorkingDirectory = "/var/lib/panoptikon"; - RestartSec = toString (60 * 60); - Restart = "on-failure"; - LoadCredential = watcherOptions.loadCredential; - }; - unitConfig = { - StartLimitIntervalSec = "300"; - StartLimitBurst = "5"; - }; - environment.PANOPTIKON_WATCHER = watcherName; - wants = ["network-online.target"]; - script = '' - set -fux - ${watcherOptions.script} > ${lib.escapeShellArg watcherName} - diff_output=$(${pkgs.diffutils}/bin/diff --new-file ${lib.escapeShellArg (watcherName + ".old")} ${lib.escapeShellArg watcherName} || :) - if [ -n "$diff_output" ] - then - ${lib.strings.concatMapStringsSep "\n" (reporter: ''echo "$diff_output" | ${reporter} || :'') watcherOptions.reporters} - fi - mv ${lib.escapeShellArg watcherName} ${lib.escapeShellArg (watcherName + ".old")} - ''; - }) - cfg.watchers; + systemd.services = lib.attrsets.mapAttrs' ( + watcherName: watcherOptions: + lib.nameValuePair "panoptikon-${watcherName}" { + enable = true; + startAt = watcherOptions.frequency; + serviceConfig = { + Type = "oneshot"; + User = "panoptikon"; + Group = "panoptikon"; + WorkingDirectory = "/var/lib/panoptikon"; + RestartSec = toString (60 * 60); + Restart = "on-failure"; + LoadCredential = watcherOptions.loadCredential; + }; + unitConfig = { + StartLimitIntervalSec = "300"; + StartLimitBurst = "5"; + }; + environment.PANOPTIKON_WATCHER = watcherName; + wants = [ "network-online.target" ]; + script = '' + set -fux + ${watcherOptions.script} > ${lib.escapeShellArg watcherName} + diff_output=$(${pkgs.diffutils}/bin/diff --new-file ${ + lib.escapeShellArg (watcherName + ".old") + } ${lib.escapeShellArg watcherName} || :) + if [ -n "$diff_output" ] + then + ${lib.strings.concatMapStringsSep "\n" ( + reporter: ''echo "$diff_output" | ${reporter} || :'' + ) watcherOptions.reporters} + fi + mv ${lib.escapeShellArg watcherName} ${lib.escapeShellArg (watcherName + ".old")} + ''; + } + ) cfg.watchers; }; } diff --git a/modules/passport.nix b/modules/passport.nix index da54821..5c84739 100644 --- a/modules/passport.nix +++ b/modules/passport.nix @@ -3,7 +3,8 @@ lib, pkgs, ... -}: let +}: +let cfg = config.niveum.passport; sortOn = a: lib.sort (as1: as2: lib.lessThan (lib.getAttr a as1) (lib.getAttr a as2)); css = '' @@ -52,20 +53,22 @@ } ''; in - with lib; { - options.niveum.passport = { - enable = mkEnableOption "server passport"; +with lib; +{ + options.niveum.passport = { + enable = mkEnableOption "server passport"; - introductionHTML = mkOption {type = types.str;}; + introductionHTML = mkOption { type = types.str; }; - virtualHost = mkOption { - type = types.str; - }; + virtualHost = mkOption { + type = types.str; + }; - services = mkOption { - type = types.listOf (types.submodule { + services = mkOption { + type = types.listOf ( + types.submodule { options = { - title = mkOption {type = types.str;}; + title = mkOption { type = types.str; }; link = mkOption { type = types.nullOr types.str; default = null; @@ -75,61 +78,62 @@ in default = ""; }; }; - }); - default = []; + } + ); + default = [ ]; + }; + }; + + config = mkIf cfg.enable { + services.nginx.enable = true; + + services.nginx.virtualHosts."${cfg.virtualHost}".locations."/passport".extraConfig = '' + default_type "text/html"; + root ${ + pkgs.linkFarm "www" [ + { + name = "passport/index.html"; + path = pkgs.writeText "index.html" '' + + + + + ${config.networking.hostName} passport + + + +
+
+

${config.networking.hostName}

+ ${cfg.introductionHTML} +
+ +
+

Services

+
+ ${lib.strings.concatMapStringsSep "\n" (service: '' +
+ ${lib.optionalString (service.link != null) ""} + ${service.title} + ${lib.optionalString (service.link != null) ""} +
+
+ ${service.description} +
+ '') (sortOn "title" cfg.services)} +
+
+
+ +
+ ${config.networking.hostName} is part of the niveum network. +
+ + ''; + } + ] }; - }; - - config = mkIf cfg.enable { - services.nginx.enable = true; - - services.nginx.virtualHosts."${cfg.virtualHost}".locations."/passport".extraConfig = '' - default_type "text/html"; - root ${ - pkgs.linkFarm "www" [ - { - name = "passport/index.html"; - path = pkgs.writeText "index.html" '' - - - - - ${config.networking.hostName} passport - - - -
-
-

${config.networking.hostName}

- ${cfg.introductionHTML} -
- -
-

Services

-
- ${lib.strings.concatMapStringsSep "\n" (service: '' -
- ${lib.optionalString (service.link != null) ""} - ${service.title} - ${lib.optionalString (service.link != null) ""} -
-
- ${service.description} -
- '') (sortOn "title" cfg.services)} -
-
-
- -
- ${config.networking.hostName} is part of the niveum network. -
- - ''; - } - ] - }; - index index.html; - ''; - }; - } + index index.html; + ''; + }; +} diff --git a/modules/power-action.nix b/modules/power-action.nix index 03fe42e..dbd9579 100644 --- a/modules/power-action.nix +++ b/modules/power-action.nix @@ -4,7 +4,8 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.services.power-action; out = { @@ -27,7 +28,8 @@ with lib; let default = "*:0/1"; }; plans = mkOption { - type = with types; + type = + with types; attrsOf (submodule { options = { charging = mkOption { @@ -71,14 +73,18 @@ with lib; let state="$(${state})" ${concatStringsSep "\n" (mapAttrsToList writeRule cfg.plans)} ''; - charging_check = plan: - if (plan.charging == null) - then "" - else if plan.charging - then ''&& [ "$state" = "true" ]'' - else ''&& ! [ "$state" = "true" ]''; + charging_check = + plan: + if (plan.charging == null) then + "" + else if plan.charging then + ''&& [ "$state" = "true" ]'' + else + ''&& ! [ "$state" = "true" ]''; - writeRule = _: plan: "if [ $power -ge ${toString plan.lowerLimit} ] && [ $power -le ${toString plan.upperLimit} ] ${charging_check plan}; then ${plan.action}; fi"; + writeRule = + _: plan: + "if [ $power -ge ${toString plan.lowerLimit} ] && [ $power -le ${toString plan.upperLimit} ] ${charging_check plan}; then ${plan.action}; fi"; powerlvl = pkgs.writers.writeDash "powerlvl" '' cat /sys/class/power_supply/${cfg.battery}/capacity @@ -91,4 +97,4 @@ with lib; let fi ''; in - out +out diff --git a/modules/retiolum.nix b/modules/retiolum.nix index 908a356..184d3e0 100644 --- a/modules/retiolum.nix +++ b/modules/retiolum.nix @@ -4,10 +4,12 @@ lib, ... }: -with lib; let +with lib; +let netname = "retiolum"; cfg = config.networking.retiolum; -in { +in +{ options = { networking.retiolum.ipv4 = mkOption { type = types.str; @@ -33,10 +35,9 @@ in { config = { services.tinc.networks.${netname} = { name = cfg.nodename; - hosts = - builtins.mapAttrs - (name: _: builtins.readFile "${}/${name}") - (builtins.readDir ); + hosts = builtins.mapAttrs (name: _: builtins.readFile "${}/${name}") ( + builtins.readDir + ); rsaPrivateKeyFile = toString ; ed25519PrivateKeyFile = toString ; extraConfig = '' @@ -47,11 +48,11 @@ in { networking.extraHosts = builtins.readFile (toString ); - environment.systemPackages = [config.services.tinc.networks.${netname}.package]; + environment.systemPackages = [ config.services.tinc.networks.${netname}.package ]; networking.firewall = { - allowedTCPPorts = [655]; - allowedUDPPorts = [655]; + allowedTCPPorts = [ 655 ]; + allowedUDPPorts = [ 655 ]; }; #services.netdata.portcheck.checks.tinc.port = 655; diff --git a/modules/system-dependent.nix b/modules/system-dependent.nix index 632baba..b986773 100644 --- a/modules/system-dependent.nix +++ b/modules/system-dependent.nix @@ -4,32 +4,35 @@ pkgs, ... }: -with lib; { +with lib; +{ options.niveum = { - wirelessInterface = mkOption {type = types.str;}; + wirelessInterface = mkOption { type = types.str; }; - batteryName = mkOption {type = types.str;}; + batteryName = mkOption { type = types.str; }; - promptColours = let - colours16 = types.enum [ - "black" - "red" - "green" - "yellow" - "blue" - "magenta" - "cyan" - "white" - ]; - in { - success = mkOption { - type = colours16; - default = "green"; + promptColours = + let + colours16 = types.enum [ + "black" + "red" + "green" + "yellow" + "blue" + "magenta" + "cyan" + "white" + ]; + in + { + success = mkOption { + type = colours16; + default = "green"; + }; + failure = mkOption { + type = colours16; + default = "red"; + }; }; - failure = mkOption { - type = colours16; - default = "red"; - }; - }; }; } diff --git a/modules/telegram-bot.nix b/modules/telegram-bot.nix index ad8af60..33fcc5e 100644 --- a/modules/telegram-bot.nix +++ b/modules/telegram-bot.nix @@ -4,24 +4,29 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.niveum.bots; - botService = name: bot: + botService = + name: bot: nameValuePair "bot-${name}" { enable = bot.enable; startAt = bot.time; serviceConfig = { Type = "oneshot"; - LoadCredential = lib.optionals (bot.telegram.enable) [ - "telegram-token:${bot.telegram.tokenFile}" - ] ++ lib.optionals (bot.mastodon.enable) [ - "mastodon-token:${bot.mastodon.tokenFile}" - ] ++ lib.optionals (bot.matrix.enable) [ - "matrix-token:${bot.matrix.tokenFile}" - ]; + LoadCredential = + lib.optionals (bot.telegram.enable) [ + "telegram-token:${bot.telegram.tokenFile}" + ] + ++ lib.optionals (bot.mastodon.enable) [ + "mastodon-token:${bot.mastodon.tokenFile}" + ] + ++ lib.optionals (bot.matrix.enable) [ + "matrix-token:${bot.matrix.tokenFile}" + ]; }; - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; script = '' QUOTE=$(${bot.command}) if [ -n "$QUOTE" ]; then @@ -30,12 +35,14 @@ with lib; let ${lib.optionalString (bot.matrix.enable) '' export MATRIX_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/matrix-token")" export JSON_PAYLOAD=$(${pkgs.jq}/bin/jq -n --arg msgtype "m.text" --arg body "$QUOTE" '{msgtype: $msgtype, body: $body}') - ${strings.concatStringsSep "\n" (map (chatId: '' - ${pkgs.curl}/bin/curl -X POST "https://${bot.matrix.homeserver}/_matrix/client/r0/rooms/${chatId}/send/m.room.message" \ - -d "$JSON_PAYLOAD" \ - -H "Authorization: Bearer $MATRIX_TOKEN" \ - -H "Content-Type: application/json" - '') bot.matrix.chatIds)} + ${strings.concatStringsSep "\n" ( + map (chatId: '' + ${pkgs.curl}/bin/curl -X POST "https://${bot.matrix.homeserver}/_matrix/client/r0/rooms/${chatId}/send/m.room.message" \ + -d "$JSON_PAYLOAD" \ + -H "Authorization: Bearer $MATRIX_TOKEN" \ + -H "Content-Type: application/json" + '') bot.matrix.chatIds + )} ''} ${lib.optionalString (bot.mastodon.enable) '' @@ -49,78 +56,90 @@ with lib; let ${lib.optionalString (bot.telegram.enable) '' export TELEGRAM_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/telegram-token")" - ${strings.concatStringsSep "\n" (map (chatId: '' - ${pkgs.curl}/bin/curl -X POST "https://api.telegram.org/bot''${TELEGRAM_TOKEN}/sendMessage" \ - -d chat_id="${chatId}" \ - -d text="$QUOTE" ${ - lib.strings.optionalString (bot.telegram.parseMode != null) - "-d parse_mode=${bot.telegram.parseMode}" - } | ${pkgs.jq}/bin/jq -e .ok - '') - bot.telegram.chatIds)} + ${strings.concatStringsSep "\n" ( + map (chatId: '' + ${pkgs.curl}/bin/curl -X POST "https://api.telegram.org/bot''${TELEGRAM_TOKEN}/sendMessage" \ + -d chat_id="${chatId}" \ + -d text="$QUOTE" ${ + lib.strings.optionalString ( + bot.telegram.parseMode != null + ) "-d parse_mode=${bot.telegram.parseMode}" + } | ${pkgs.jq}/bin/jq -e .ok + '') bot.telegram.chatIds + )} ''} fi ''; }; -in { +in +{ options.niveum.bots = mkOption { - type = types.attrsOf (types.submodule { - options = { - enable = mkEnableOption "Mastodon and Telegram bot"; - time = mkOption {type = types.str;}; - command = mkOption {type = types.str;}; - matrix = mkOption { - default = {}; - type = types.submodule { - options = { - enable = mkEnableOption "Posting to Matrix"; - tokenFile = mkOption {type = types.path;}; - homeserver = mkOption { - type = types.str; + type = types.attrsOf ( + types.submodule { + options = { + enable = mkEnableOption "Mastodon and Telegram bot"; + time = mkOption { type = types.str; }; + command = mkOption { type = types.str; }; + matrix = mkOption { + default = { }; + type = types.submodule { + options = { + enable = mkEnableOption "Posting to Matrix"; + tokenFile = mkOption { type = types.path; }; + homeserver = mkOption { + type = types.str; + }; + chatIds = mkOption { + type = types.listOf types.str; + }; }; - chatIds = mkOption { - type = types.listOf types.str; + }; + }; + mastodon = mkOption { + default = { }; + type = types.submodule { + options = { + enable = mkEnableOption "Posting to Mastodon"; + language = mkOption { + type = types.str; + default = "en"; + }; + tokenFile = mkOption { type = types.path; }; + homeserver = mkOption { + type = types.str; + default = "social.krebsco.de"; + }; + }; + }; + }; + telegram = mkOption { + default = { }; + type = types.submodule { + options = { + enable = mkEnableOption "Posting to Telegram"; + tokenFile = mkOption { type = types.path; }; + chatIds = mkOption { + type = types.listOf (types.strMatching "-?[0-9]+|@[A-Za-z0-9]+"); + }; + parseMode = mkOption { + type = types.nullOr ( + types.enum [ + "HTML" + "Markdown" + ] + ); + default = null; + }; }; }; }; }; - mastodon = mkOption { - default = {}; - type = types.submodule { - options = { - enable = mkEnableOption "Posting to Mastodon"; - language = mkOption { - type = types.str; - default = "en"; - }; - tokenFile = mkOption {type = types.path;}; - homeserver = mkOption { - type = types.str; - default = "social.krebsco.de"; - }; - }; - }; - }; - telegram = mkOption { - default = {}; - type = types.submodule { - options = { - enable = mkEnableOption "Posting to Telegram"; - tokenFile = mkOption {type = types.path;}; - chatIds = mkOption { - type = types.listOf (types.strMatching "-?[0-9]+|@[A-Za-z0-9]+"); - }; - parseMode = mkOption { - type = types.nullOr (types.enum ["HTML" "Markdown"]); - default = null; - }; - }; - }; - }; - }; - }); - default = {}; + } + ); + default = { }; }; - config = {systemd.services = attrsets.mapAttrs' botService cfg;}; + config = { + systemd.services = attrsets.mapAttrs' botService cfg; + }; } diff --git a/packages/betacode.nix b/packages/betacode.nix index 01cb8a4..d7fdf79 100644 --- a/packages/betacode.nix +++ b/packages/betacode.nix @@ -3,14 +3,16 @@ haskell, haskellPackages, }: -writers.writeHaskellBin "betacode" { - libraries = [ - (haskell.lib.unmarkBroken (haskell.lib.doJailbreak haskellPackages.betacode)) - haskellPackages.text - ]; -} '' - import qualified Data.Text.IO as T - import qualified Data.Text as T - import Text.BetaCode - main = T.interact (either (error . T.unpack) id . fromBeta) -'' +writers.writeHaskellBin "betacode" + { + libraries = [ + (haskell.lib.unmarkBroken (haskell.lib.doJailbreak haskellPackages.betacode)) + haskellPackages.text + ]; + } + '' + import qualified Data.Text.IO as T + import qualified Data.Text as T + import Text.BetaCode + main = T.interact (either (error . T.unpack) id . fromBeta) + '' diff --git a/packages/brainmelter.nix b/packages/brainmelter.nix index 9ee5802..1190aa6 100755 --- a/packages/brainmelter.nix +++ b/packages/brainmelter.nix @@ -1,4 +1,10 @@ -{ writers, flite, netcat, gnused, ... }: +{ + writers, + flite, + netcat, + gnused, + ... +}: writers.writeDashBin "brainmelter" '' SERVER="brockman.news" PORT=6667 diff --git a/packages/closest/default.nix b/packages/closest/default.nix index cc24ac9..eed98ea 100644 --- a/packages/closest/default.nix +++ b/packages/closest/default.nix @@ -6,8 +6,15 @@ writers.writeDashBin "closest" '' ${ writers.writeHaskellBin "closest" { - libraries = with haskellPackages; [parallel optparse-applicative edit-distance]; - ghcArgs = ["-O3" "-threaded"]; + libraries = with haskellPackages; [ + parallel + optparse-applicative + edit-distance + ]; + ghcArgs = [ + "-O3" + "-threaded" + ]; } (builtins.readFile ./distance.hs) }/bin/closest +RTS -N4 -RTS --dictionary ${ fetchurl { diff --git a/packages/cyberlocker-tools.nix b/packages/cyberlocker-tools.nix index 0c997ea..6e6563f 100644 --- a/packages/cyberlocker-tools.nix +++ b/packages/cyberlocker-tools.nix @@ -1,4 +1,4 @@ -{pkgs}: +{ pkgs }: pkgs.symlinkJoin { name = "cyberlocker-tools"; paths = [ diff --git a/packages/depp.nix b/packages/depp.nix index 542a8bf..b4e904b 100644 --- a/packages/depp.nix +++ b/packages/depp.nix @@ -1,7 +1,8 @@ { lib, writeShellScriptBin, -}: let +}: +let aliasFlag = name: value: "-c alias.${name}=${lib.escapeShellArg value}"; aliases = { eroeffne = "init"; @@ -23,10 +24,10 @@ zustand = "status"; }; in - writeShellScriptBin "depp" '' - if [ $# -gt 0 ]; then - git ${lib.concatStringsSep " " (lib.attrsets.mapAttrsToList aliasFlag aliases)} "$@" - else - printf "${lib.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: n + " " + v) aliases)}\n" - fi - '' +writeShellScriptBin "depp" '' + if [ $# -gt 0 ]; then + git ${lib.concatStringsSep " " (lib.attrsets.mapAttrsToList aliasFlag aliases)} "$@" + else + printf "${lib.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: n + " " + v) aliases)}\n" + fi +'' diff --git a/packages/devanagari/default.nix b/packages/devanagari/default.nix index 9321968..985c1c3 100644 --- a/packages/devanagari/default.nix +++ b/packages/devanagari/default.nix @@ -1,4 +1,4 @@ -{yarn2nix-moretea, lib}: +{ yarn2nix-moretea, lib }: yarn2nix-moretea.mkYarnPackage { name = "devanagari"; src = lib.fileset.toSource { diff --git a/packages/devanagari/yarn.nix b/packages/devanagari/yarn.nix index 5a4c868..321cdb2 100644 --- a/packages/devanagari/yarn.nix +++ b/packages/devanagari/yarn.nix @@ -4,7 +4,8 @@ linkFarm, runCommandNoCC, gnutar, -}: rec { +}: +rec { offline_cache = linkFarm "offline" packages; packages = [ { diff --git a/packages/devour.nix b/packages/devour.nix index 456fa53..fbeaa8f 100644 --- a/packages/devour.nix +++ b/packages/devour.nix @@ -16,8 +16,8 @@ stdenv.mkDerivation { sha256 = "0f2jb8knx7lqy6wmf3rchgq2n2dj496lm8vgcs58rppzrmsk59d5"; }; - nativeBuildInputs = [makeWrapper]; - buildInputs = [xdo]; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ xdo ]; DESTDIR = "$(out)"; diff --git a/packages/dmenu-randr.nix b/packages/dmenu-randr.nix index 30bcfaa..bf0cb1a 100755 --- a/packages/dmenu-randr.nix +++ b/packages/dmenu-randr.nix @@ -15,7 +15,20 @@ writers.writeDashBin "dmenu-randr" '' #!/bin/sh - export PATH=${lib.makeBinPath [dmenu bc psmisc util-linux xorg.xrandr gawk libnotify arandr gnugrep coreutils]} + export PATH=${ + lib.makeBinPath [ + dmenu + bc + psmisc + util-linux + xorg.xrandr + gawk + libnotify + arandr + gnugrep + coreutils + ] + } # A UI for detecting and selecting all displays. Probes xrandr for connected # displays and lets user select one to use. User may also select "manual diff --git a/packages/emailmenu.nix b/packages/emailmenu.nix index 7e39ee3..f5bdf84 100644 --- a/packages/emailmenu.nix +++ b/packages/emailmenu.nix @@ -10,7 +10,15 @@ }: writers.writeDashBin "emailmenu" '' history_file=$HOME/.cache/emailmenu - PATH=${lib.makeBinPath [coreutils dmenu gawk libnotify xclip]} + PATH=${ + lib.makeBinPath [ + coreutils + dmenu + gawk + libnotify + xclip + ] + } chosen=$(${khard}/bin/khard email --parsable | awk '!seen[$0]++' | dmenu -i -p 📧 -1 -l 10 | tee --append "$history_file" | cut -f1) [ "$chosen" != "" ] || exit echo "$chosen" | tr -d '\n' | xclip -selection clipboard diff --git a/packages/fkill.nix b/packages/fkill.nix index 19000b0..2e533ec 100644 --- a/packages/fkill.nix +++ b/packages/fkill.nix @@ -7,7 +7,14 @@ fzf, }: writers.writeBashBin "fkill" '' - PATH=$PATH:${lib.makeBinPath [procps gawk gnused fzf]} + PATH=$PATH:${ + lib.makeBinPath [ + procps + gawk + gnused + fzf + ] + } if [ "$UID" != "0" ]; then pid=$(ps -f -u "$UID" | sed 1d | fzf -m | awk '{print $2}') diff --git a/packages/fzfmenu.nix b/packages/fzfmenu.nix index 3ea67af..3658d63 100644 --- a/packages/fzfmenu.nix +++ b/packages/fzfmenu.nix @@ -10,7 +10,13 @@ writers.writeBashBin "fzfmenu" '' # https://github.com/junegunn/fzf/wiki/Examples#fzf-as-dmenu-replacement set -efu - PATH=$PATH:${lib.makeBinPath [st fzf dash]} + PATH=$PATH:${ + lib.makeBinPath [ + st + fzf + dash + ] + } input=$(mktemp -p "$XDG_RUNTIME_DIR" -u --suffix .fzfmenu.input) output=$(mktemp -p "$XDG_RUNTIME_DIR" -u --suffix .fzfmenu.output) diff --git a/packages/gfs-fonts.nix b/packages/gfs-fonts.nix index 12fe074..1b359aa 100644 --- a/packages/gfs-fonts.nix +++ b/packages/gfs-fonts.nix @@ -2,8 +2,10 @@ fetchzip, symlinkJoin, lib, -}: let - gfs-font = name: sha256: +}: +let + gfs-font = + name: sha256: fetchzip { inherit name sha256; url = "http://www.greekfontsociety-gfs.gr/_assets/fonts/${name}.zip"; @@ -14,40 +16,40 @@ ''; }; in - symlinkJoin { - name = "gfs-fonts"; - paths = lib.mapAttrsToList gfs-font { - GFS_Artemisia = "1q39086pr2jhv118fjfv6l1li6japv4pdjnhh1scqw06mqrmydf4"; - GFS_Baskerville = "07gx5b9b43zv74d2lay37sajd4ba2wqn3b7xzvyhn265ds9x7cxk"; - GFS_Bodoni = "0jhl0728ikzha1krm01sk52nz3jzibidwmyvgidg61d87l8nbf2p"; - GFS_Bodoni_Classic = "06jw2irskn75s50mgwkx08rzwqi82gpc6lgjsimsi8p81566gfrh"; - GFS_Complutum = "1q7dxs2z3yrgchd2pz9h72mjrk62kdc2mmqw8kg9q76k28f8n3p0"; # -> GFSPolyglot.otf - GFS_Decker = "016v1j5n9ph4i2cpmlk26pcxhp3q2fjwlaryppd5akl84dfkpncl"; - GFS_Didot = "0ysvrp527wm0wxfp6wmlgmxfx7ysr5mwpmjmqp1h605cy44jblfm"; - GFS_Didot_Classic = "0n5awqksvday3l3d85yhwmbmfj9bcpxivy4wpd4zrkgl7b85af2c"; - GFS_Didot_Display = "0n2di2zyc76w6f8mc6hfilc2ir6igks7ldjp9fkw1gjp06330fi7"; - GFS_Elpis = "02l7wd3nbn1kpv7ghxh19k4dbvd49ijyxd6gq83gcr9vlmxcq2s2"; - GFS_Gazis = "0x9iwj6pinaykrds0iw6552hf256d0dr41sipdb1jnnlr2d3bf9w"; - GFS_Goschen = "1jvbn33wzq2yj0aygwy9pd2msg3wkmdp0npjzazadrmfjpnpkcy9"; - GFS_NeoHellenic = "1ixm2frdc6i5lbn9h0h4gdsvsw2k4hny75q8ig4kgs28ac3dbzq3"; - GFS_Olga = "1qaxaw3ngnbr1gb1xyk5f2z647zklg6sl3bqwi28l47j9mp0f8aj"; - GFS_Orpheus = "18n6fag4pyr8jdwnsz0vixf47jz4ym8mjmppc1w3k7v27cg1z9dz"; - GFS_Orpheus_Classic = "1rqy1kf7slw56zfhbv264yzarjisnqbqydj4f7hghiknhnmdakps"; - GFS_Orpheus_Sans = "02rh7z8c3h3xyfi52rn47z4finizx636d05bg5g23v0l0mqs6nkg"; - GFS_Philostratos = "0zh3d0cn6b2fjbwnvmg379z20zh7w626w2bnj19xcazjvqkwhzx1"; - GFS_Porson = "0c2axagkm6wxv8na2q11k6c5dmgkwx5hn9sh9qy82gbips9blnda"; - GFS_Pyrsos = "0y0dv7y3n01bbhhnczflx1zcc7by56cffmr2xqixj2rd1nvchx0j"; - GFS_Solomos = "1mpx9mw566awvfjdfx5sbz3wz5gbnjjw56gz30mk1lw06vxf0dxz"; - GFS_Theokritos = "0haasx819x8c8yvna6pqywgi4060av2570jm34cddnz1fgnhv1b8"; - # Heraklit - # Galatea - # Georgiou - # Ambrosia - # Fleischman - # Eustace - # Nicefore - # Jackson - # Garaldus - # Ignacio - }; - } +symlinkJoin { + name = "gfs-fonts"; + paths = lib.mapAttrsToList gfs-font { + GFS_Artemisia = "1q39086pr2jhv118fjfv6l1li6japv4pdjnhh1scqw06mqrmydf4"; + GFS_Baskerville = "07gx5b9b43zv74d2lay37sajd4ba2wqn3b7xzvyhn265ds9x7cxk"; + GFS_Bodoni = "0jhl0728ikzha1krm01sk52nz3jzibidwmyvgidg61d87l8nbf2p"; + GFS_Bodoni_Classic = "06jw2irskn75s50mgwkx08rzwqi82gpc6lgjsimsi8p81566gfrh"; + GFS_Complutum = "1q7dxs2z3yrgchd2pz9h72mjrk62kdc2mmqw8kg9q76k28f8n3p0"; # -> GFSPolyglot.otf + GFS_Decker = "016v1j5n9ph4i2cpmlk26pcxhp3q2fjwlaryppd5akl84dfkpncl"; + GFS_Didot = "0ysvrp527wm0wxfp6wmlgmxfx7ysr5mwpmjmqp1h605cy44jblfm"; + GFS_Didot_Classic = "0n5awqksvday3l3d85yhwmbmfj9bcpxivy4wpd4zrkgl7b85af2c"; + GFS_Didot_Display = "0n2di2zyc76w6f8mc6hfilc2ir6igks7ldjp9fkw1gjp06330fi7"; + GFS_Elpis = "02l7wd3nbn1kpv7ghxh19k4dbvd49ijyxd6gq83gcr9vlmxcq2s2"; + GFS_Gazis = "0x9iwj6pinaykrds0iw6552hf256d0dr41sipdb1jnnlr2d3bf9w"; + GFS_Goschen = "1jvbn33wzq2yj0aygwy9pd2msg3wkmdp0npjzazadrmfjpnpkcy9"; + GFS_NeoHellenic = "1ixm2frdc6i5lbn9h0h4gdsvsw2k4hny75q8ig4kgs28ac3dbzq3"; + GFS_Olga = "1qaxaw3ngnbr1gb1xyk5f2z647zklg6sl3bqwi28l47j9mp0f8aj"; + GFS_Orpheus = "18n6fag4pyr8jdwnsz0vixf47jz4ym8mjmppc1w3k7v27cg1z9dz"; + GFS_Orpheus_Classic = "1rqy1kf7slw56zfhbv264yzarjisnqbqydj4f7hghiknhnmdakps"; + GFS_Orpheus_Sans = "02rh7z8c3h3xyfi52rn47z4finizx636d05bg5g23v0l0mqs6nkg"; + GFS_Philostratos = "0zh3d0cn6b2fjbwnvmg379z20zh7w626w2bnj19xcazjvqkwhzx1"; + GFS_Porson = "0c2axagkm6wxv8na2q11k6c5dmgkwx5hn9sh9qy82gbips9blnda"; + GFS_Pyrsos = "0y0dv7y3n01bbhhnczflx1zcc7by56cffmr2xqixj2rd1nvchx0j"; + GFS_Solomos = "1mpx9mw566awvfjdfx5sbz3wz5gbnjjw56gz30mk1lw06vxf0dxz"; + GFS_Theokritos = "0haasx819x8c8yvna6pqywgi4060av2570jm34cddnz1fgnhv1b8"; + # Heraklit + # Galatea + # Georgiou + # Ambrosia + # Fleischman + # Eustace + # Nicefore + # Jackson + # Garaldus + # Ignacio + }; +} diff --git a/packages/gimp.nix b/packages/gimp.nix index a563609..3cfcd80 100644 --- a/packages/gimp.nix +++ b/packages/gimp.nix @@ -1,4 +1,10 @@ -{ gimp, fetchurl, runCommand, symlinkJoin, writers }: +{ + gimp, + fetchurl, + runCommand, + symlinkJoin, + writers, +}: let bring-out-the-gimp = fetchurl { url = "https://c.krebsco.de/bring-out-the-gimp.png"; @@ -8,13 +14,14 @@ let data-dir = symlinkJoin { name = "gimp"; paths = [ - (runCommand "splash" {} '' + (runCommand "splash" { } '' mkdir -p $out/${data-dir-prefix}/images install ${bring-out-the-gimp} $out/share/gimp/2.0/images/gimp-splash.png '') gimp ]; }; -in writers.writeDashBin "gimp" '' +in +writers.writeDashBin "gimp" '' exec env GIMP2_DATADIR=${data-dir}/${data-dir-prefix} ${gimp}/bin/gimp "$@" '' diff --git a/packages/go-webring.nix b/packages/go-webring.nix index 18824ca..fd8c8ab 100644 --- a/packages/go-webring.nix +++ b/packages/go-webring.nix @@ -1,4 +1,8 @@ -{ buildGoModule, fetchgit, lib }: +{ + buildGoModule, + fetchgit, + lib, +}: buildGoModule { pname = "go-webring"; version = "2024-12-18"; diff --git a/packages/heuretes.nix b/packages/heuretes.nix index ab81d83..47699c9 100644 --- a/packages/heuretes.nix +++ b/packages/heuretes.nix @@ -3,12 +3,13 @@ fetchurl, xan, util-linux, -}: let +}: +let database = fetchurl { url = "http://c.krebsco.de/greek.csv"; hash = "sha256-SYL10kerNI0HzExG6JXh765+CBBCHLO95B6OKErQ/sU="; }; in - writers.writeDashBin "heuretes" '' - ${xan}/bin/xan search -s simple "$*" ${database} | ${util-linux}/bin/column -s, -t - '' +writers.writeDashBin "heuretes" '' + ${xan}/bin/xan search -s simple "$*" ${database} | ${util-linux}/bin/column -s, -t +'' diff --git a/packages/hora.nix b/packages/hora.nix index 94e641c..6cb68ef 100644 --- a/packages/hora.nix +++ b/packages/hora.nix @@ -1,12 +1,13 @@ -{ symlinkJoin -, hledger -, writers -, lib -, git -, coreutils -, gnugrep -, timeLedger -, ... +{ + symlinkJoin, + hledger, + writers, + lib, + git, + coreutils, + gnugrep, + timeLedger, + ... }: let date = "${coreutils}/bin/date +'%Y-%m-%d %H:%M:%S'"; diff --git a/packages/k-lock.nix b/packages/k-lock.nix index d8790d4..abaa2b3 100644 --- a/packages/k-lock.nix +++ b/packages/k-lock.nix @@ -2,7 +2,8 @@ writers, lib, xlockmore, -}: let +}: +let xlockModes = lib.concatStringsSep "\\n" [ # "braid" "galaxy" @@ -12,18 +13,18 @@ "space" ]; in - writers.writeDashBin "k-lock" '' - MODE=$(printf "${xlockModes}" | shuf -n 1) +writers.writeDashBin "k-lock" '' + MODE=$(printf "${xlockModes}" | shuf -n 1) - ${xlockmore}/bin/xlock \ - -saturation 0.4 \ - -erasemode no_fade \ - +description \ - -showdate \ - -username " " \ - -password " " \ - -info " " \ - -validate "..." \ - -invalid "Computer says no." \ - -mode "$MODE" - '' + ${xlockmore}/bin/xlock \ + -saturation 0.4 \ + -erasemode no_fade \ + +description \ + -showdate \ + -username " " \ + -password " " \ + -info " " \ + -validate "..." \ + -invalid "Computer says no." \ + -mode "$MODE" +'' diff --git a/packages/klem.nix b/packages/klem.nix index dc084bb..33c2055 100644 --- a/packages/klem.nix +++ b/packages/klem.nix @@ -10,15 +10,20 @@ writers, options ? { }, ... -}: let +}: +let eval = lib.evalModules { modules = [ { - imports = [options]; + imports = [ options ]; options = { selection = lib.mkOption { default = "clipboard"; - type = lib.types.enum ["primary" "secondary" "clipboard"]; + type = lib.types.enum [ + "primary" + "secondary" + "clipboard" + ]; }; dmenu = lib.mkOption { default = "${dmenu}/bin/dmenu -i -p klem"; @@ -41,19 +46,19 @@ cfg = eval.config; in - writers.writeDashBin "klem" '' - set -efu +writers.writeDashBin "klem" '' + set -efu - ${xclip}/bin/xclip -selection ${cfg.selection} -out \ - | case $(echo "${ - lib.concatStringsSep "\n" (lib.attrNames cfg.scripts) - }" | ${cfg.dmenu}) in - ${lib.concatStringsSep "\n" (lib.mapAttrsToList (option: script: '' + ${xclip}/bin/xclip -selection ${cfg.selection} -out \ + | case $(echo "${lib.concatStringsSep "\n" (lib.attrNames cfg.scripts)}" | ${cfg.dmenu}) in + ${lib.concatStringsSep "\n" ( + lib.mapAttrsToList (option: script: '' '${option}') ${toString script} ;; - '') cfg.scripts)} - *) ${coreutils}/bin/cat ;; - esac \ - | ${xclip}/bin/xclip -selection ${cfg.selection} -in + '') cfg.scripts + )} + *) ${coreutils}/bin/cat ;; + esac \ + | ${xclip}/bin/xclip -selection ${cfg.selection} -in - ${libnotify}/bin/notify-send --app-name="klem" "Result copied to clipboard." - '' + ${libnotify}/bin/notify-send --app-name="klem" "Result copied to clipboard." +'' diff --git a/packages/literature-quote.nix b/packages/literature-quote.nix index 314de6d..ad003c9 100644 --- a/packages/literature-quote.nix +++ b/packages/literature-quote.nix @@ -6,7 +6,13 @@ gnused, }: writers.writeDashBin "literature-quote" '' - PATH=$PATH:${lib.makeBinPath [xan curl gnused]} + PATH=$PATH:${ + lib.makeBinPath [ + xan + curl + gnused + ] + } ROW=$(curl -Ls http://kmein.github.io/logotheca/quotes.csv | shuf -n1) ( QUOTE="$(echo "$ROW" | xan select 3)" diff --git a/packages/manual-sort.nix b/packages/manual-sort.nix index c8b51c8..7217649 100644 --- a/packages/manual-sort.nix +++ b/packages/manual-sort.nix @@ -1,5 +1,5 @@ -{writers}: -writers.writeHaskellBin "manual-sort" {} '' +{ writers }: +writers.writeHaskellBin "manual-sort" { } '' {-# LANGUAGE LambdaCase #-} import Data.Char (toLower) import System.Environment (getArgs) diff --git a/packages/mpv-tv.nix b/packages/mpv-tv.nix index 89cf73a..37f689e 100644 --- a/packages/mpv-tv.nix +++ b/packages/mpv-tv.nix @@ -1,7 +1,8 @@ { pkgs, lib, -}: let +}: +let m3u-to-tsv = '' ${pkgs.gnused}/bin/sed '/#EXTM3U/d;/#EXTINF/s/.*,//g' $out | ${pkgs.coreutils}/bin/paste -d'\t' - - > $out.tmp mv $out.tmp $out @@ -19,6 +20,6 @@ postFetch = m3u-to-tsv; }; in - pkgs.writers.writeDashBin "mpv-tv" '' - cat ${kodi-tv} ${live-tv} | ${pkgs.mpv}/bin/mpv --force-window=yes "$(${pkgs.dmenu}/bin/dmenu -i -l 5 | ${pkgs.coreutils}/bin/cut -f2)" - '' +pkgs.writers.writeDashBin "mpv-tv" '' + cat ${kodi-tv} ${live-tv} | ${pkgs.mpv}/bin/mpv --force-window=yes "$(${pkgs.dmenu}/bin/dmenu -i -l 5 | ${pkgs.coreutils}/bin/cut -f2)" +'' diff --git a/packages/noise-waves.nix b/packages/noise-waves.nix index 3e6c44c..c43c91a 100644 --- a/packages/noise-waves.nix +++ b/packages/noise-waves.nix @@ -1,4 +1,9 @@ -{ sox, mpv, writers, coreutils }: +{ + sox, + mpv, + writers, + coreutils, +}: # ref https://askubuntu.com/a/789472 writers.writeDashBin "noise-waves" '' file="/tmp/noise-$(${coreutils}/bin/date +%s | ${coreutils}/bin/md5sum | ${coreutils}/bin/cut -d' ' -f1).wav" diff --git a/packages/notemenu.nix b/packages/notemenu.nix index d24c054..f241d33 100644 --- a/packages/notemenu.nix +++ b/packages/notemenu.nix @@ -6,20 +6,24 @@ coreutils, noteDirectory ? "~/state/obsidian", currentDates ? false, - obsidian-vim + obsidian-vim, }: writers.writeDashBin "notemenu" '' set -efu PATH=$PATH:${ - lib.makeBinPath [rofi findutils coreutils] + lib.makeBinPath [ + rofi + findutils + coreutils + ] } cd ${noteDirectory} note_file=$({ ${lib.optionalString currentDates '' - echo $(date -I).md - echo $(date -I -d yesterday).md - ''} + echo $(date -I).md + echo $(date -I -d yesterday).md + ''} find . -not -path '*/.*' -type f -printf "%T@ %p\n" | sort --reverse --numeric-sort | cut --delimiter=" " --fields=2- } | rofi -dmenu -i -p 'notes') if test "$note_file" diff --git a/packages/opustags.nix b/packages/opustags.nix index 7124d99..65d97ba 100644 --- a/packages/opustags.nix +++ b/packages/opustags.nix @@ -23,9 +23,12 @@ stdenv.mkDerivation (finalAttrs: { doCheck = true; - buildInputs = [libogg]; + buildInputs = [ libogg ]; - nativeBuildInputs = [cmake pkg-config]; + nativeBuildInputs = [ + cmake + pkg-config + ]; meta = with lib; { homepage = "https://github.com/fmang/opustags"; diff --git a/packages/pls.nix b/packages/pls.nix index e11570f..22ece71 100644 --- a/packages/pls.nix +++ b/packages/pls.nix @@ -6,8 +6,9 @@ gnused, curl, nur, - downloadDirectory ? "~/mobile/audio/Musik/radiomitschnitt" -}: let + downloadDirectory ? "~/mobile/audio/Musik/radiomitschnitt", +}: +let playlistAPI = "https://radio.lassul.us"; sendIRC = writers.writeDash "send-irc" '' @@ -102,42 +103,42 @@ ${yt-dlp}/bin/yt-dlp --add-metadata --audio-format mp3 --audio-quality 0 -xic "$@" ''; in - writers.writeDashBin "pls" '' - case "$1" in - good|like|cool|nice|noice|top|yup|yass|yes|+) - response=$(${curl}/bin/curl -sS -XPOST "${playlistAPI}/good") - echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.good)} | shuf -n1 | ${sendIRC} +writers.writeDashBin "pls" '' + case "$1" in + good|like|cool|nice|noice|top|yup|yass|yes|+) + response=$(${curl}/bin/curl -sS -XPOST "${playlistAPI}/good") + echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.good)} | shuf -n1 | ${sendIRC} - # Download the song if a download URL is provided in the string (youtu.be) - downloadUrl=$(echo "$response" | grep -oE 'https?://(www\.)?(youtube\.com|youtu\.be)/[^\s]+') - if [ -n "$downloadUrl" ]; then - echo "Downloading song from URL: $downloadUrl" - mkdir -p ${lib.escapeShellArg downloadDirectory} - cd ${lib.escapeShellArg downloadDirectory} - ${download} "$downloadUrl" - else - echo "No download URL found in the response: $response" - fi - ;; - skip|next|bad|sucks|no|nope|flop|-) - ${curl}/bin/curl -sS -XPOST "${playlistAPI}/skip" - echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.bad)} | shuf -n1 | ${sendIRC} - ;; - 0|meh|neutral) - echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.neutral)} | shuf -n1 | ${sendIRC} - ;; - say|msg) - shift - echo "$@" | ${sendIRC} - ;; - recent) - ${curl}/bin/curl -sS -XGET "${playlistAPI}/recent" | tac | head - ;; - *) - ${curl}/bin/curl -sS -XGET "${playlistAPI}/current" \ - | ${miller}/bin/mlr --ijson --oxtab cat \ - | ${gnused}/bin/sed -n '/artist\|title\|youtube/p' - ;; - esac - wait - '' + # Download the song if a download URL is provided in the string (youtu.be) + downloadUrl=$(echo "$response" | grep -oE 'https?://(www\.)?(youtube\.com|youtu\.be)/[^\s]+') + if [ -n "$downloadUrl" ]; then + echo "Downloading song from URL: $downloadUrl" + mkdir -p ${lib.escapeShellArg downloadDirectory} + cd ${lib.escapeShellArg downloadDirectory} + ${download} "$downloadUrl" + else + echo "No download URL found in the response: $response" + fi + ;; + skip|next|bad|sucks|no|nope|flop|-) + ${curl}/bin/curl -sS -XPOST "${playlistAPI}/skip" + echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.bad)} | shuf -n1 | ${sendIRC} + ;; + 0|meh|neutral) + echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.neutral)} | shuf -n1 | ${sendIRC} + ;; + say|msg) + shift + echo "$@" | ${sendIRC} + ;; + recent) + ${curl}/bin/curl -sS -XGET "${playlistAPI}/recent" | tac | head + ;; + *) + ${curl}/bin/curl -sS -XGET "${playlistAPI}/current" \ + | ${miller}/bin/mlr --ijson --oxtab cat \ + | ${gnused}/bin/sed -n '/artist\|title\|youtube/p' + ;; + esac + wait +'' diff --git a/packages/polyglot.nix b/packages/polyglot.nix index 2102557..e4f6aa0 100644 --- a/packages/polyglot.nix +++ b/packages/polyglot.nix @@ -1,107 +1,108 @@ { writers, mpv, -}: let +}: +let arabicStories = "/home/kfm/cloud/syncthing/music/Arabic/Stories"; levantineTextbook = "/home/kfm/cloud/syncthing/music/Arabic/Damaszenisch"; in - writers.writeDashBin "polyglot" '' - languages='persian - arabic - coptic - sanskrit - levantine - hebrew' +writers.writeDashBin "polyglot" '' + languages='persian + arabic + coptic + sanskrit + levantine + hebrew' - kurdish="https://www.youtube.com/channel/UCvutKJerMREoQtzXiQaDNBQ - https://www.youtube.com/channel/UCdqSEXLhnsltwN4IESMInDA" + kurdish="https://www.youtube.com/channel/UCvutKJerMREoQtzXiQaDNBQ + https://www.youtube.com/channel/UCdqSEXLhnsltwN4IESMInDA" - persian="https://www.youtube.com/playlist?list=PL4aDVDOklYH5MnXNjCeRalFuRZ46I_p8Q - https://www.youtube.com/playlist?list=PL4aDVDOklYH404fg2zZoUQR6YcQp4UUrW - https://www.youtube.com/playlist?list=PL4aDVDOklYH4FhJZ4cX14HuUVsDJKUifr - https://www.youtube.com/playlist?list=PL4aDVDOklYH6i_Od0zD4ZFNqmZVBOTo4z - https://www.youtube.com/playlist?list=PL4aDVDOklYH5NuhQvc52KCPO0X64FU_bd - https://www.youtube.com/playlist?list=PL4aDVDOklYH6MFQfuQ5VIJmwuKfR1kgUR - https://www.youtube.com/playlist?list=PL4aDVDOklYH48_uuVl-AAPbkemzZFvnHH - https://www.youtube.com/playlist?list=PL4aDVDOklYH61WM-WmzjZyTFAE7AILb7j - https://www.youtube.com/channel/UCGY0LHNDQjt3GQrrc3r3Atw - https://www.youtube.com/channel/UC4jgHye1-kjDlY-2StrtVtA - https://www.youtube.com/channel/UCf67DKdLhpFW-7c7FZre2Ww - https://www.youtube.com/channel/UCLOGyLCPJL99gNriGAhwl7g - https://www.youtube.com/channel/UCxV5ZfGJjJhrzy_9am-S4QQ - https://www.youtube.com/channel/UCBSF89JJieetWjJTGZhGKJA - https://www.youtube.com/channel/UCFGB29XZkEGS1Vw7WplBqIg - https://www.youtube.com/channel/UChiyq4qjnAWMNhwPu2KL4yg - https://www.youtube.com/channel/UCULxPJn3NjsaXt4Nc-sIZrw - https://www.youtube.com/channel/UCYRyoX3ru_BfMiXVCGgRS6w - https://www.youtube.com/channel/UCbCvjr0v_-8LmZh9431N84w" + persian="https://www.youtube.com/playlist?list=PL4aDVDOklYH5MnXNjCeRalFuRZ46I_p8Q + https://www.youtube.com/playlist?list=PL4aDVDOklYH404fg2zZoUQR6YcQp4UUrW + https://www.youtube.com/playlist?list=PL4aDVDOklYH4FhJZ4cX14HuUVsDJKUifr + https://www.youtube.com/playlist?list=PL4aDVDOklYH6i_Od0zD4ZFNqmZVBOTo4z + https://www.youtube.com/playlist?list=PL4aDVDOklYH5NuhQvc52KCPO0X64FU_bd + https://www.youtube.com/playlist?list=PL4aDVDOklYH6MFQfuQ5VIJmwuKfR1kgUR + https://www.youtube.com/playlist?list=PL4aDVDOklYH48_uuVl-AAPbkemzZFvnHH + https://www.youtube.com/playlist?list=PL4aDVDOklYH61WM-WmzjZyTFAE7AILb7j + https://www.youtube.com/channel/UCGY0LHNDQjt3GQrrc3r3Atw + https://www.youtube.com/channel/UC4jgHye1-kjDlY-2StrtVtA + https://www.youtube.com/channel/UCf67DKdLhpFW-7c7FZre2Ww + https://www.youtube.com/channel/UCLOGyLCPJL99gNriGAhwl7g + https://www.youtube.com/channel/UCxV5ZfGJjJhrzy_9am-S4QQ + https://www.youtube.com/channel/UCBSF89JJieetWjJTGZhGKJA + https://www.youtube.com/channel/UCFGB29XZkEGS1Vw7WplBqIg + https://www.youtube.com/channel/UChiyq4qjnAWMNhwPu2KL4yg + https://www.youtube.com/channel/UCULxPJn3NjsaXt4Nc-sIZrw + https://www.youtube.com/channel/UCYRyoX3ru_BfMiXVCGgRS6w + https://www.youtube.com/channel/UCbCvjr0v_-8LmZh9431N84w" - hebrew="https://www.youtube.com/playlist?list=PLXU4ackZsIPp2G8XjfpsYso2p3IHyl-bJ - https://www.youtube.com/playlist?list=PLXU4ackZsIPqLOWeWZc1frv3VCAohi90p - https://www.youtube.com/playlist?list=PLXU4ackZsIPpWWdWvtM3UtZHFKFhmI2mj - https://www.youtube.com/playlist?list=PLXU4ackZsIPoz05eaLCHsCv4Wrk4n1g34 - https://www.youtube.com/channel/UCrMYJpbMhhQZhXi4ui3FKEw - https://www.youtube.com/playlist?list=PLXU4ackZsIPombqx98SIPanShjSUSlBW- - https://www.youtube.com/playlist?list=PLXU4ackZsIPrdSFUjNdw3eGK-qbtgqt-6 - https://www.youtube.com/playlist?list=PLXU4ackZsIPrVHjB4P9QrYzJvBKD3MLuA - https://www.youtube.com/playlist?list=PLXU4ackZsIPp_7fb7TMyOaaX_ORI6vH29 - https://www.youtube.com/channel/UCkKmeTinUEU27syZPKrzWQQ - https://www.youtube.com/channel/UC2gy2POCchS7JM_UCsZx5dw - https://www.youtube.com/channel/UCb2bkA-kSUz4Mj5YJv0zpJQ" + hebrew="https://www.youtube.com/playlist?list=PLXU4ackZsIPp2G8XjfpsYso2p3IHyl-bJ + https://www.youtube.com/playlist?list=PLXU4ackZsIPqLOWeWZc1frv3VCAohi90p + https://www.youtube.com/playlist?list=PLXU4ackZsIPpWWdWvtM3UtZHFKFhmI2mj + https://www.youtube.com/playlist?list=PLXU4ackZsIPoz05eaLCHsCv4Wrk4n1g34 + https://www.youtube.com/channel/UCrMYJpbMhhQZhXi4ui3FKEw + https://www.youtube.com/playlist?list=PLXU4ackZsIPombqx98SIPanShjSUSlBW- + https://www.youtube.com/playlist?list=PLXU4ackZsIPrdSFUjNdw3eGK-qbtgqt-6 + https://www.youtube.com/playlist?list=PLXU4ackZsIPrVHjB4P9QrYzJvBKD3MLuA + https://www.youtube.com/playlist?list=PLXU4ackZsIPp_7fb7TMyOaaX_ORI6vH29 + https://www.youtube.com/channel/UCkKmeTinUEU27syZPKrzWQQ + https://www.youtube.com/channel/UC2gy2POCchS7JM_UCsZx5dw + https://www.youtube.com/channel/UCb2bkA-kSUz4Mj5YJv0zpJQ" - arabic="https://www.youtube.com/channel/UCbqqV0gO5QbV9iGITdxp-cw - https://www.youtube.com/channel/UCxNwNoGEhHg7lGOhthG4r6A - https://www.youtube.com/channel/UCmYYUdR85LRVB5yT1Y7DjFA - https://www.youtube.com/channel/UCIgFDroRoDYnxBlOGmwJ78A - https://www.youtube.com/channel/UCn5ASYdp7CzbFH2qtqjIJ9w - https://www.youtube.com/channel/UCD8N8HjsCkCmykfPnVleVRg - https://www.youtube.com/channel/UCEmWUZanVYXEzZXYDHzD-iA - https://www.youtube.com/channel/UC9rnrMdYzfqdjiuNXV7q8oQ - https://live-hls-audio-web-aja.getaj.net/VOICE-AJA/01.m3u8 - http://asima.out.airtime.pro:8000/asima_a - http://edge.mixlr.com/channel/qtgru - http://ninarfm.grtvstream.com:8896/stream - http://andromeda.shoutca.st:8189/stream - http://www.dreamsiteradiocp4.com:8014/stream - http://n02.radiojar.com/sxfbks1vfy8uv.mp3 - http://stream-025.zeno.fm/5y95pu36sm0uv - ${arabicStories}" + arabic="https://www.youtube.com/channel/UCbqqV0gO5QbV9iGITdxp-cw + https://www.youtube.com/channel/UCxNwNoGEhHg7lGOhthG4r6A + https://www.youtube.com/channel/UCmYYUdR85LRVB5yT1Y7DjFA + https://www.youtube.com/channel/UCIgFDroRoDYnxBlOGmwJ78A + https://www.youtube.com/channel/UCn5ASYdp7CzbFH2qtqjIJ9w + https://www.youtube.com/channel/UCD8N8HjsCkCmykfPnVleVRg + https://www.youtube.com/channel/UCEmWUZanVYXEzZXYDHzD-iA + https://www.youtube.com/channel/UC9rnrMdYzfqdjiuNXV7q8oQ + https://live-hls-audio-web-aja.getaj.net/VOICE-AJA/01.m3u8 + http://asima.out.airtime.pro:8000/asima_a + http://edge.mixlr.com/channel/qtgru + http://ninarfm.grtvstream.com:8896/stream + http://andromeda.shoutca.st:8189/stream + http://www.dreamsiteradiocp4.com:8014/stream + http://n02.radiojar.com/sxfbks1vfy8uv.mp3 + http://stream-025.zeno.fm/5y95pu36sm0uv + ${arabicStories}" - levantine_general="https://www.youtube.com/channel/UCe6YxTdT2zsbhG8ThAEssLw - https://www.youtube.com/channel/UC8IsrQ3Fvg1X2QboSRIMBHA - https://www.youtube.com/channel/UCo65IZihlwP204bleDDuAyA - https://www.youtube.com/channel/UCDXBymJu72YX2LzKVlZyZaA - https://www.youtube.com/channel/UCpovzufzZSP3kCYm16B5Hyw - https://www.youtube.com/channel/UCKkKlH7eJFBWhofiP5kQEFQ - https://www.youtube.com/channel/UC-YYp3mws0sa9vI3VUCWqhw - https://www.youtube.com/channel/UCpa9WD4btPSyn0h-DZSATGw - https://www.youtube.com/channel/UCb7oMrqwZnr3ZCayqnkkb8w - https://www.youtube.com/channel/UCuLNZirpkm2HYxq-tTiXnOA - https://www.youtube.com/channel/UCSGBoIBGUxUmpTYJfYZXs-A - https://www.youtube.com/channel/UCPINCItSdAc7SBXxi6AcWpw - https://www.youtube.com/channel/UCbZvzUBn04a_a95HFMX6eTA - https://www.youtube.com/channel/UChJs6Kqju9BmN5FMHhBfRSA - https://www.youtube.com/channel/UCyC7OV3gEQkguVwl9qDGuTQ - https://www.youtube.com/channel/UCwv1qu4iX6Bm6X-uSSB2eBQ - ${levantineTextbook}" + levantine_general="https://www.youtube.com/channel/UCe6YxTdT2zsbhG8ThAEssLw + https://www.youtube.com/channel/UC8IsrQ3Fvg1X2QboSRIMBHA + https://www.youtube.com/channel/UCo65IZihlwP204bleDDuAyA + https://www.youtube.com/channel/UCDXBymJu72YX2LzKVlZyZaA + https://www.youtube.com/channel/UCpovzufzZSP3kCYm16B5Hyw + https://www.youtube.com/channel/UCKkKlH7eJFBWhofiP5kQEFQ + https://www.youtube.com/channel/UC-YYp3mws0sa9vI3VUCWqhw + https://www.youtube.com/channel/UCpa9WD4btPSyn0h-DZSATGw + https://www.youtube.com/channel/UCb7oMrqwZnr3ZCayqnkkb8w + https://www.youtube.com/channel/UCuLNZirpkm2HYxq-tTiXnOA + https://www.youtube.com/channel/UCSGBoIBGUxUmpTYJfYZXs-A + https://www.youtube.com/channel/UCPINCItSdAc7SBXxi6AcWpw + https://www.youtube.com/channel/UCbZvzUBn04a_a95HFMX6eTA + https://www.youtube.com/channel/UChJs6Kqju9BmN5FMHhBfRSA + https://www.youtube.com/channel/UCyC7OV3gEQkguVwl9qDGuTQ + https://www.youtube.com/channel/UCwv1qu4iX6Bm6X-uSSB2eBQ + ${levantineTextbook}" - sanskrit="https://www.youtube.com/channel/UCTnCQNG_1WIlunxbp1SAOvw - https://stream-23.zeno.fm/m08mkwsyw8quv - https://www.youtube.com/channel/UCqFg6QnwgtVHo1iFgpxrx-A" + sanskrit="https://www.youtube.com/channel/UCTnCQNG_1WIlunxbp1SAOvw + https://stream-23.zeno.fm/m08mkwsyw8quv + https://www.youtube.com/channel/UCqFg6QnwgtVHo1iFgpxrx-A" - language="$(echo "$languages" | shuf -n1)" - case "$language" in - arabic) - ${mpv}/bin/mpv --shuffle $arabic;; - persian) - ${mpv}/bin/mpv --shuffle $persian;; - coptic) - ;; - sanskrit) - ${mpv}/bin/mpv --shuffle $sanskrit;; - levantine) - ${mpv}/bin/mpv --shuffle $levantine;; - hebrew) - ${mpv}/bin/mpv --shuffle $hebrew;; - esac - '' + language="$(echo "$languages" | shuf -n1)" + case "$language" in + arabic) + ${mpv}/bin/mpv --shuffle $arabic;; + persian) + ${mpv}/bin/mpv --shuffle $persian;; + coptic) + ;; + sanskrit) + ${mpv}/bin/mpv --shuffle $sanskrit;; + levantine) + ${mpv}/bin/mpv --shuffle $levantine;; + hebrew) + ${mpv}/bin/mpv --shuffle $hebrew;; + esac +'' diff --git a/packages/python3Packages/indic-transliteration/default.nix b/packages/python3Packages/indic-transliteration/default.nix index 056f293..eba408c 100644 --- a/packages/python3Packages/indic-transliteration/default.nix +++ b/packages/python3Packages/indic-transliteration/default.nix @@ -15,7 +15,11 @@ buildPythonPackage (finalAttrs: { rev = "2ea25a03af15937916b6768835e056166986c567"; sha256 = "1pcf800hl0zkcffc47mkjq9mizsxdi0hwxlnij5bvbqdshd3w9ll"; }; - patches = [./regex-version.patch]; - propagatedBuildInputs = [backports_functools_lru_cache selenium regex]; + patches = [ ./regex-version.patch ]; + propagatedBuildInputs = [ + backports_functools_lru_cache + selenium + regex + ]; doCheck = false; }) diff --git a/packages/q.nix b/packages/q.nix index ab7cf7c..bd4c3d4 100644 --- a/packages/q.nix +++ b/packages/q.nix @@ -1,6 +1,22 @@ -{ writers, lib, todoman, khal, util-linux, wego, pass }: +{ + writers, + lib, + todoman, + khal, + util-linux, + wego, + pass, +}: writers.writeDashBin "q" '' - export PATH=$PATH:${lib.makeBinPath [todoman khal util-linux wego pass]} + export PATH=$PATH:${ + lib.makeBinPath [ + todoman + khal + util-linux + wego + pass + ] + } (todo list --due 240; echo) & (khal list today today; echo) & (cal -3; echo) & diff --git a/packages/radio-news/default.nix b/packages/radio-news/default.nix index b6f0366..8fb8e68 100644 --- a/packages/radio-news/default.nix +++ b/packages/radio-news/default.nix @@ -1,7 +1,21 @@ -{ writers, lib, gnused, curl, jq, yq }: +{ + writers, + lib, + gnused, + curl, + jq, + yq, +}: writers.writeBashBin "radio-news" '' set -efu - PATH=$PATH:${lib.makeBinPath [gnused curl jq yq]} + PATH=$PATH:${ + lib.makeBinPath [ + gnused + curl + jq + yq + ] + } EVENTS=$( curl https://www.goodnewsnetwork.org/feed/ \ diff --git a/packages/random-zeno.nix b/packages/random-zeno.nix index 708bb33..f5d83e1 100755 --- a/packages/random-zeno.nix +++ b/packages/random-zeno.nix @@ -1,8 +1,28 @@ -{ writers, lib, curl, pup, gnused, coreutils, pandoc, gawk, jq }: +{ + writers, + lib, + curl, + pup, + gnused, + coreutils, + pandoc, + gawk, + jq, +}: writers.writeDashBin "random-zeno" '' set -efu - export PATH=${lib.makeBinPath [ curl pup gnused coreutils pandoc gawk jq ]} + export PATH=${ + lib.makeBinPath [ + curl + pup + gnused + coreutils + pandoc + gawk + jq + ] + } root="http://www.zeno.org" character_limit=350 diff --git a/packages/scanned.nix b/packages/scanned.nix index 0352b3d..ca599bb 100644 --- a/packages/scanned.nix +++ b/packages/scanned.nix @@ -3,10 +3,15 @@ writers, imagemagick, ghostscript, - lib + lib, }: writers.writeDashBin "scanned" '' - export PATH=${lib.makeBinPath [ imagemagick ghostscript ]}:$PATH + export PATH=${ + lib.makeBinPath [ + imagemagick + ghostscript + ] + }:$PATH [ $# -eq 1 -a -f "$1" -a -r "$1" ] || exit 1 diff --git a/packages/stardict-tools.nix b/packages/stardict-tools.nix index f63be1a..d989257 100644 --- a/packages/stardict-tools.nix +++ b/packages/stardict-tools.nix @@ -21,9 +21,16 @@ stdenv.mkDerivation { which libtool ]; - buildInputs = [glib zlib gtk3 libmysqlclient pcre libxml2]; + buildInputs = [ + glib + zlib + gtk3 + libmysqlclient + pcre + libxml2 + ]; buildPhase = "make"; - configureFlags = ["--disable-dict"]; + configureFlags = [ "--disable-dict" ]; env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=format-security" ]; @@ -31,7 +38,7 @@ stdenv.mkDerivation { substituteInPlace tools/src/Makefile.am \ --replace-fail noinst_PROGRAMS bin_PROGRAMS ''; - installFlags = ["INSTALL_PREFIX=$(out)"]; + installFlags = [ "INSTALL_PREFIX=$(out)" ]; autoreconfPhase = '' patchShebangs ./autogen.sh ./autogen.sh diff --git a/packages/streams/default.nix b/packages/streams/default.nix index 0d07b7b..e788836 100644 --- a/packages/streams/default.nix +++ b/packages/streams/default.nix @@ -2582,8 +2582,7 @@ in ... }: "${station}\t${desc}\t${stream}" - ) - streams + ) streams ); playlist = writeText "streams.txt" (lib.concatMapStringsSep "\n" (station: station.stream) streams); } diff --git a/packages/tocharian-font.nix b/packages/tocharian-font.nix index 3d31c39..54bf00b 100644 --- a/packages/tocharian-font.nix +++ b/packages/tocharian-font.nix @@ -12,7 +12,7 @@ stdenv.mkDerivation { sha256 = "08bzkva9a6b2cfl38p9m22b1cf6yv27xsw6nrvq5ly5nffjm32hv"; }; dontUnpack = true; - buildInputs = [mupdf]; + buildInputs = [ mupdf ]; buildPhase = '' mutool extract $src ''; @@ -23,6 +23,6 @@ stdenv.mkDerivation { meta = with lib; { description = "Tocharian font by Lee Wilson"; platforms = platforms.all; - maintainers = with maintainers; [kmein]; + maintainers = with maintainers; [ kmein ]; }; } diff --git a/packages/trans.nix b/packages/trans.nix index a328d59..f64e473 100644 --- a/packages/trans.nix +++ b/packages/trans.nix @@ -2,12 +2,13 @@ fetchurl, writers, gawk, -}: let +}: +let script = fetchurl { url = "https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/trans.awk"; hash = "sha256-KT5iRRGtHpBTrPfs0L2e4JW6JrXVTVvgCXeFKFcr1P4="; }; in - writers.writeDashBin "trans" '' - exec ${gawk}/bin/gawk -f ${script} -- "$@" - '' +writers.writeDashBin "trans" '' + exec ${gawk}/bin/gawk -f ${script} -- "$@" +'' diff --git a/packages/ttspaste.nix b/packages/ttspaste.nix index 2e6f28d..af22126 100644 --- a/packages/ttspaste.nix +++ b/packages/ttspaste.nix @@ -8,4 +8,3 @@ writers.writeDashBin "ttspaste" '' '' # curl, mpv, # ${curl}/bin/curl -G http://tts.r/api/tts --data-urlencode 'text@-' | ${mpv}/bin/mpv - - diff --git a/packages/unicodmenu.nix b/packages/unicodmenu.nix index ed17867..179ca2c 100644 --- a/packages/unicodmenu.nix +++ b/packages/unicodmenu.nix @@ -12,41 +12,57 @@ xdotool, gawk, fetchFromGitHub, -}: let - emoji-flags = builtins.fromJSON (builtins.readFile "${fetchFromGitHub { - owner = "matiassingers"; - repo = "emoji-flags"; - rev = "93ae74505d09bb55a3eb3a511f1dfc0dd60a5347"; - sha256 = "10j73sx6jb250v37bz2p7w8big0v8da3r6kpqz9xcl667gl8svwx"; - }}/data.json"); - emoji-flags-file = writeText "emoji-flags.txt" (lib.strings.concatMapStringsSep "\n" ({ - emoji, - title, - ... - }: "${emoji} ${title}") - emoji-flags); - unicode-file = runCommand "unicode.txt" {} '' +}: +let + emoji-flags = builtins.fromJSON ( + builtins.readFile "${ + fetchFromGitHub { + owner = "matiassingers"; + repo = "emoji-flags"; + rev = "93ae74505d09bb55a3eb3a511f1dfc0dd60a5347"; + sha256 = "10j73sx6jb250v37bz2p7w8big0v8da3r6kpqz9xcl667gl8svwx"; + } + }/data.json" + ); + emoji-flags-file = writeText "emoji-flags.txt" ( + lib.strings.concatMapStringsSep "\n" ( + { + emoji, + title, + ... + }: + "${emoji} ${title}" + ) emoji-flags + ); + unicode-file = runCommand "unicode.txt" { } '' ${ - writers.writePython3 "generate.py" {flakeIgnore = ["E501" "E722"];} '' - import csv + writers.writePython3 "generate.py" + { + flakeIgnore = [ + "E501" + "E722" + ]; + } + '' + import csv - with open("${ - fetchurl { - url = "https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt"; - sha256 = "0wva6ygnh3wrzpzy0kcbc32hz1ydx3k2pqc5xkqrfw83cpnrlvl0"; - } - }", "r") as unicode_data: - reader = csv.reader(unicode_data, delimiter=";") - next(reader) # skip first row containing \0 - for row in reader: - codepoint = row[0] - name = row[1] - alternate_name = row[10] - try: - print(chr(int(codepoint, 16)), codepoint, name, alternate_name, sep=" ") - except: - continue - '' + with open("${ + fetchurl { + url = "https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt"; + sha256 = "0wva6ygnh3wrzpzy0kcbc32hz1ydx3k2pqc5xkqrfw83cpnrlvl0"; + } + }", "r") as unicode_data: + reader = csv.reader(unicode_data, delimiter=";") + next(reader) # skip first row containing \0 + for row in reader: + codepoint = row[0] + name = row[1] + alternate_name = row[10] + try: + print(chr(int(codepoint, 16)), codepoint, name, alternate_name, sep=" ") + except: + continue + '' } > $out ''; kaomoji-file = writeText "kaomoji.txt" '' @@ -86,26 +102,36 @@ 𓂸 penis ''; in - # ref https://github.com/LukeSmithxyz/voidrice/blob/9fe6802122f6e0392c7fe20eefd30437771d7f8e/.local/bin/dmenuunicode - writers.writeDashBin "unicodmenu" '' - history_file=$HOME/.cache/unicodmenu - touch "$history_file" - PATH=${lib.makeBinPath [coreutils dmenu gawk gnused libnotify xclip xdotool]} +# ref https://github.com/LukeSmithxyz/voidrice/blob/9fe6802122f6e0392c7fe20eefd30437771d7f8e/.local/bin/dmenuunicode +writers.writeDashBin "unicodmenu" '' + history_file=$HOME/.cache/unicodmenu + touch "$history_file" + PATH=${ + lib.makeBinPath [ + coreutils + dmenu + gawk + gnused + libnotify + xclip + xdotool + ] + } - all_characters() { - tac "$history_file" - cat ${kaomoji-file} ${unicode-file} ${emoji-flags-file} - } + all_characters() { + tac "$history_file" + cat ${kaomoji-file} ${unicode-file} ${emoji-flags-file} + } - chosen=$(all_characters | awk '!seen[$0]++' | dmenu -p unicode -i -l 10 | tee --append "$history_file" | sed "s/ .*//") + chosen=$(all_characters | awk '!seen[$0]++' | dmenu -p unicode -i -l 10 | tee --append "$history_file" | sed "s/ .*//") - [ "$chosen" != "" ] || exit + [ "$chosen" != "" ] || exit - echo "$chosen" | tr -d '\n' | xclip -selection clipboard + echo "$chosen" | tr -d '\n' | xclip -selection clipboard - if [ -n "$1" ]; then - xdotool key Shift+Insert - else - notify-send --app-name="$(basename "$0")" "'$chosen' copied to clipboard." & - fi - '' + if [ -n "$1" ]; then + xdotool key Shift+Insert + else + notify-send --app-name="$(basename "$0")" "'$chosen' copied to clipboard." & + fi +'' diff --git a/packages/untilport.nix b/packages/untilport.nix index 0db755f..516f469 100644 --- a/packages/untilport.nix +++ b/packages/untilport.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: +{ pkgs, ... }: pkgs.writers.writeDashBin "untilport" '' set -euf diff --git a/packages/vim-kmein/default.nix b/packages/vim-kmein/default.nix index bdc554e..9f2d03d 100644 --- a/packages/vim-kmein/default.nix +++ b/packages/vim-kmein/default.nix @@ -8,7 +8,8 @@ colorscheme ? null, lib, ... -}: neovim.override { +}: +neovim.override { configure = { vimAlias = true; viAlias = true; @@ -17,16 +18,21 @@ source ${./init.vim} let g:snippet_directory = '${vimPlugins.friendly-snippets}' luafile ${./init.lua} - '' + lib.optionalString (stylixColors != null) (with stylixColors.withHashtag; '' - luafile ${writeText "colors.lua" '' - require('base16-colorscheme').setup({ - base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', - base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', - base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', - base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' - }) - ''} - '') + lib.optionalString (colorscheme != null) '' + '' + + lib.optionalString (stylixColors != null) ( + with stylixColors.withHashtag; + '' + luafile ${writeText "colors.lua" '' + require('base16-colorscheme').setup({ + base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', + base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', + base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', + base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + }) + ''} + '' + ) + + lib.optionalString (colorscheme != null) '' colorscheme ${colorscheme} ''; packages.nvim = with vimPlugins; { @@ -60,16 +66,22 @@ vim-repeat vim-sensible vim-surround - (let version = "1.1.0"; pname = "vim-dim"; in vimUtils.buildVimPlugin { - pname = "vim-dim"; - version = version; - src = fetchFromGitHub { - owner = "jeffkreeftmeijer"; - repo = pname; - rev = version; - sha256 = "sha256-lyTZUgqUEEJRrzGo1FD8/t8KBioPrtB3MmGvPeEVI/g="; - }; - }) + ( + let + version = "1.1.0"; + pname = "vim-dim"; + in + vimUtils.buildVimPlugin { + pname = "vim-dim"; + version = version; + src = fetchFromGitHub { + owner = "jeffkreeftmeijer"; + repo = pname; + rev = version; + sha256 = "sha256-lyTZUgqUEEJRrzGo1FD8/t8KBioPrtB3MmGvPeEVI/g="; + }; + } + ) ]; opt = [ csv diff --git a/packages/vimPlugins/cheat-sh.nix b/packages/vimPlugins/cheat-sh.nix index 5cebd7c..e198f8f 100644 --- a/packages/vimPlugins/cheat-sh.nix +++ b/packages/vimPlugins/cheat-sh.nix @@ -1,7 +1,8 @@ { vimUtils, fetchFromGitHub, -}: (vimUtils.buildVimPlugin { +}: +(vimUtils.buildVimPlugin { pname = "cheat.sh-vim"; version = "826219d1"; src = fetchFromGitHub { diff --git a/packages/vimPlugins/icalendar-vim.nix b/packages/vimPlugins/icalendar-vim.nix index 053c587..9b9bc38 100644 --- a/packages/vimPlugins/icalendar-vim.nix +++ b/packages/vimPlugins/icalendar-vim.nix @@ -1,7 +1,8 @@ { vimUtils, fetchFromGitHub, -}: (vimUtils.buildVimPlugin { +}: +(vimUtils.buildVimPlugin { pname = "icalendar.vim"; version = "542fff45"; src = fetchFromGitHub { diff --git a/packages/vimPlugins/mdwa-nvim.nix b/packages/vimPlugins/mdwa-nvim.nix index 8672e92..0f80437 100644 --- a/packages/vimPlugins/mdwa-nvim.nix +++ b/packages/vimPlugins/mdwa-nvim.nix @@ -1,7 +1,8 @@ { vimUtils, fetchFromGitHub, -}: (vimUtils.buildVimPlugin { +}: +(vimUtils.buildVimPlugin { pname = "mdwa.nvim"; version = "9f37270"; src = fetchFromGitHub { diff --git a/packages/vimPlugins/vim-ernest.nix b/packages/vimPlugins/vim-ernest.nix index d369880..66b7c33 100644 --- a/packages/vimPlugins/vim-ernest.nix +++ b/packages/vimPlugins/vim-ernest.nix @@ -2,7 +2,8 @@ vimUtils, fetchFromGitHub, lib, -}: (vimUtils.buildVimPlugin { +}: +(vimUtils.buildVimPlugin { pname = "vim-ernest"; version = "4b99bc3"; src = fetchFromGitHub { diff --git a/packages/vimPlugins/vim-fetch.nix b/packages/vimPlugins/vim-fetch.nix index 99f0ee7..cc2f601 100644 --- a/packages/vimPlugins/vim-fetch.nix +++ b/packages/vimPlugins/vim-fetch.nix @@ -1,7 +1,8 @@ { vimUtils, fetchFromGitHub, -}: (vimUtils.buildVimPlugin { +}: +(vimUtils.buildVimPlugin { pname = "vim-fetch"; version = "76c08586"; src = fetchFromGitHub { diff --git a/packages/vimPlugins/vim-reason-plus.nix b/packages/vimPlugins/vim-reason-plus.nix index aad38ad..e2db852 100644 --- a/packages/vimPlugins/vim-reason-plus.nix +++ b/packages/vimPlugins/vim-reason-plus.nix @@ -1,7 +1,8 @@ { vimUtils, fetchFromGitHub, -}: (vimUtils.buildVimPlugin { +}: +(vimUtils.buildVimPlugin { pname = "vim-reason-plus"; version = "c11a2940"; src = fetchFromGitHub { diff --git a/packages/vimv.nix b/packages/vimv.nix index 219f1c4..1502ad0 100644 --- a/packages/vimv.nix +++ b/packages/vimv.nix @@ -12,14 +12,14 @@ stdenv.mkDerivation { rev = "4152496c1946f68a13c648fb7e583ef23dac4eb8"; sha256 = "1fsrfx2gs6bqx7wk7pgcji2i2x4alqpsi66aif4kqvnpqfhcfzjd"; }; - phases = ["installPhase"]; + phases = [ "installPhase" ]; installPhase = '' mkdir -p $out/bin sed 's:#!/bin/bash:#!${bash}/bin/bash:' $src/vimv > $out/bin/vimv chmod 755 $out/bin/vimv ''; meta = with lib; { - homepage = https://github.com/thameera/vimv; + homepage = "https://github.com/thameera/vimv"; description = "Batch-rename files using Vim"; license = licenses.mit; platforms = platforms.all; diff --git a/packages/weechat-declarative.nix b/packages/weechat-declarative.nix index 12bd2c4..230449b 100644 --- a/packages/weechat-declarative.nix +++ b/packages/weechat-declarative.nix @@ -2,39 +2,51 @@ pkgs, lib, ... -} @ args: let +}@args: +let # config cannot be declared in the input attribute set because that would # cause callPackage to inject the wrong config. Instead, get it from ... # via args. - config = args.config or {}; + config = args.config or { }; lib = - args.lib // - (let - attrPaths = let - recurse = path: value: - if builtins.isAttrs value - then lib.mapAttrsToList (name: recurse (path ++ [name])) value - else [(lib.nameValuePair path value)]; + args.lib + // ( + let + attrPaths = + let + recurse = + path: value: + if builtins.isAttrs value then + lib.mapAttrsToList (name: recurse (path ++ [ name ])) value + else + [ (lib.nameValuePair path value) ]; + in + attrs: lib.flatten (recurse [ ] attrs); + toWeechatValue = + x: + { + bool = builtins.toJSON x; + string = x; + list = lib.concatMapStringsSep "," toWeechatValue x; + int = toString x; + } + .${builtins.typeOf x}; in - attrs: lib.flatten (recurse [] attrs); - toWeechatValue = x: - { - bool = builtins.toJSON x; - string = x; - list = lib.concatMapStringsSep "," toWeechatValue x; - int = toString x; - } - .${builtins.typeOf x}; - in { - inherit attrPaths toWeechatValue; + { + inherit attrPaths toWeechatValue; - attrPathsSep = sep: attrs: lib.listToAttrs (map (x: x // {name = lib.concatStringsSep sep x.name;}) (attrPaths attrs)); + attrPathsSep = + sep: attrs: + lib.listToAttrs (map (x: x // { name = lib.concatStringsSep sep x.name; }) (attrPaths attrs)); - setCommand = name: value: "/set ${name} \"${toWeechatValue value}\""; + setCommand = name: value: "/set ${name} \"${toWeechatValue value}\""; - filterAddreplace = name: filter: "/filter addreplace ${name} ${filter.buffer} ${toWeechatValue filter.tags} ${filter.regex}"; - }); + filterAddreplace = + name: filter: + "/filter addreplace ${name} ${filter.buffer} ${toWeechatValue filter.tags} ${filter.regex}"; + } + ); cfg = eval.config; @@ -45,18 +57,18 @@ options = { scripts = lib.mkOption { type = lib.types.listOf lib.types.package; - default = []; + default = [ ]; description = '' some stuff from pkgs.weechatScripts ''; }; settings = lib.mkOption { - type = (pkgs.formats.json {}).type; + type = (pkgs.formats.json { }).type; description = '' your weechat config in nix-style syntax. secrets can be defined with \''${my.secret.value} ''; - default = {}; + default = { }; example = { irc.server_default.nicks = "rick_\\\${sec.data.foo}"; irc.server_default.msg_part = "ciao kakao"; @@ -69,7 +81,7 @@ address = "irc.hackint.org/6697"; ssl = true; autoconnect = true; - autojoin = ["#krebs"]; + autojoin = [ "#krebs" ]; }; weechat.bar.buflist.hidden = true; irc.server.hackint.command = lib.concatStringsSep "\\;" [ @@ -78,7 +90,7 @@ ]; filters.playlist_topic = { buffer = "irc.*.#the_playlist"; - tags = ["irc_topic"]; + tags = [ "irc_topic" ]; regex = "*"; }; relay = { @@ -95,7 +107,7 @@ }; files = lib.mkOption { type = lib.types.attrsOf lib.types.str; - default = {}; + default = { }; example = lib.literalExpression '' { "sec.conf" = toString (pkgs.writeText "sec.conf" ''' @@ -117,24 +129,25 @@ }; setFile = pkgs.writeText "weechat.set" ( - lib.optionalString (cfg.settings != {}) - (lib.concatStringsSep "\n" ( - lib.optionals - (cfg.settings.irc or {} != {}) - (lib.mapAttrsToList - (name: server: "/server add ${name} ${lib.toWeechatValue server.addresses}") - cfg.settings.irc.server) - ++ lib.optionals - (cfg.settings.matrix or {} != {}) - (lib.mapAttrsToList - (name: server: "/matrix server add ${name} ${server.address}") - cfg.settings.matrix.server) - ++ lib.mapAttrsToList lib.setCommand (lib.attrPathsSep "." cfg.settings) - ++ lib.optionals - (cfg.settings.filters or {} != {}) - (lib.mapAttrsToList lib.filterAddreplace cfg.settings.filters) - ++ lib.singleton cfg.extraCommands - )) + lib.optionalString (cfg.settings != { }) ( + lib.concatStringsSep "\n" ( + lib.optionals (cfg.settings.irc or { } != { }) ( + lib.mapAttrsToList ( + name: server: "/server add ${name} ${lib.toWeechatValue server.addresses}" + ) cfg.settings.irc.server + ) + ++ lib.optionals (cfg.settings.matrix or { } != { }) ( + lib.mapAttrsToList ( + name: server: "/matrix server add ${name} ${server.address}" + ) cfg.settings.matrix.server + ) + ++ lib.mapAttrsToList lib.setCommand (lib.attrPathsSep "." cfg.settings) + ++ lib.optionals (cfg.settings.filters or { } != { }) ( + lib.mapAttrsToList lib.filterAddreplace cfg.settings.filters + ) + ++ lib.singleton cfg.extraCommands + ) + ) ); weechatPkg = pkgs.weechat.override { @@ -148,31 +161,22 @@ wrapper = pkgs.writers.writeDashBin "weechat" '' CONFDIR=''${XDG_CONFIG_HOME:-$HOME/.config}/weechat ${pkgs.coreutils}/bin/mkdir -p "$CONFDIR" - ${ - lib.concatStringsSep "\n" - ( - lib.mapAttrsToList - (name: target: - /* - sh - */ - '' - ${pkgs.coreutils}/bin/cp ${lib.escapeShellArg target} "$CONFDIR"/${lib.escapeShellArg name} - ${pkgs.coreutils}/bin/chmod -w "$CONFDIR"/${lib.escapeShellArg name} - '') - cfg.files - ) - } + ${lib.concatStringsSep "\n" ( + lib.mapAttrsToList (name: target: /* sh */ '' + ${pkgs.coreutils}/bin/cp ${lib.escapeShellArg target} "$CONFDIR"/${lib.escapeShellArg name} + ${pkgs.coreutils}/bin/chmod -w "$CONFDIR"/${lib.escapeShellArg name} + '') cfg.files + )} exec ${weechatPkg}/bin/weechat "$@" ''; in - pkgs.symlinkJoin { - name = "weechat-configured"; - paths = [ - wrapper - weechatPkg - ]; - postBuild = '' - ln -s ${setFile} $out/weechat.set - ''; - } +pkgs.symlinkJoin { + name = "weechat-configured"; + paths = [ + wrapper + weechatPkg + ]; + postBuild = '' + ln -s ${setFile} $out/weechat.set + ''; +} diff --git a/packages/weechatScripts/hotlist2extern.nix b/packages/weechatScripts/hotlist2extern.nix index 0284d9b..54c3e09 100644 --- a/packages/weechatScripts/hotlist2extern.nix +++ b/packages/weechatScripts/hotlist2extern.nix @@ -21,13 +21,13 @@ stdenv.mkDerivation { ''; passthru = { - scripts = ["hotlist2extern.pl"]; + scripts = [ "hotlist2extern.pl" ]; }; meta = with lib; { inherit (weechat.meta) platforms; description = "Give hotlist to an external file/program"; license = licenses.gpl3; - maintainers = with maintainers; [kmein]; + maintainers = with maintainers; [ kmein ]; }; } diff --git a/packages/worldradio.nix b/packages/worldradio.nix index adacdbe..7ef0e79 100644 --- a/packages/worldradio.nix +++ b/packages/worldradio.nix @@ -2,7 +2,8 @@ jq, runCommand, fetchFromGitHub, -}: let +}: +let online-radio = fetchFromGitHub { owner = "kmein"; repo = "online-radio"; @@ -10,12 +11,11 @@ sha256 = "1q0iagx7df0sd6vl5anvpzyiw4jdwa6c67z45rx622a6cr6m4zzl"; }; in - runCommand "worldradio.m3u" {} '' - ${jq}/bin/jq --raw-output --slurp 'flatten | map(.url_resolved) | .[]' ${online-radio}/src/data/countries/*.json \ - | sort \ - | uniq \ - > $out - '' +runCommand "worldradio.m3u" { } '' + ${jq}/bin/jq --raw-output --slurp 'flatten | map(.url_resolved) | .[]' ${online-radio}/src/data/countries/*.json \ + | sort \ + | uniq \ + > $out +'' # anthoer method for running a world radio using Icecast Directory # curl http://dir.xiph.org/ | pup 'a[href^=http]:contains("Play") attr{href}' - diff --git a/systems/fatteh/configuration.nix b/systems/fatteh/configuration.nix index e575397..bbf2bf2 100644 --- a/systems/fatteh/configuration.nix +++ b/systems/fatteh/configuration.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ imports = [ ./hardware-configuration.nix ../../configs/networkmanager.nix diff --git a/systems/fatteh/hardware-configuration.nix b/systems/fatteh/hardware-configuration.nix index fae3e3b..6b1c1d2 100644 --- a/systems/fatteh/hardware-configuration.nix +++ b/systems/fatteh/hardware-configuration.nix @@ -7,15 +7,21 @@ pkgs, modulesPath, ... -}: { +}: +{ imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usb_storage" "sd_mod"]; - boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-intel"]; - boot.extraModulePackages = []; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "nvme" + "usb_storage" + "sd_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; boot = { loader = { @@ -28,14 +34,16 @@ }; }; - boot.initrd.luks.devices."luks-aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5".device = "/dev/disk/by-uuid/aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5"; + boot.initrd.luks.devices."luks-aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5".device = + "/dev/disk/by-uuid/aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5"; fileSystems."/" = { device = "/dev/disk/by-uuid/42b747ff-a432-4c0e-bb0a-59f0a68c44a2"; fsType = "ext4"; }; - boot.initrd.luks.devices."luks-67c1f7da-4318-49f7-bd98-cc731990b595".device = "/dev/disk/by-uuid/67c1f7da-4318-49f7-bd98-cc731990b595"; + boot.initrd.luks.devices."luks-67c1f7da-4318-49f7-bd98-cc731990b595".device = + "/dev/disk/by-uuid/67c1f7da-4318-49f7-bd98-cc731990b595"; fileSystems."/boot" = { device = "/dev/disk/by-uuid/9051-0891"; @@ -43,7 +51,7 @@ }; swapDevices = [ - {device = "/dev/disk/by-uuid/529a1893-773e-4d04-bf6c-16e67e1ed3c7";} + { device = "/dev/disk/by-uuid/529a1893-773e-4d04-bf6c-16e67e1ed3c7"; } ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking diff --git a/systems/ful/alew.nix b/systems/ful/alew.nix index efc99d2..a3aef10 100644 --- a/systems/ful/alew.nix +++ b/systems/ful/alew.nix @@ -1,4 +1,9 @@ -{ pkgs, config, inputs, ... }: +{ + pkgs, + config, + inputs, + ... +}: let postgrestPort = 3001; alewPort = 3000; @@ -6,8 +11,8 @@ in { systemd.services.postgrest = { enable = true; - wantedBy = ["podman-alew.service"]; - wants = ["postgresql.service"]; + wantedBy = [ "podman-alew.service" ]; + wants = [ "postgresql.service" ]; environment = { PGRST_DB_ANON_ROLE = "alew_1"; PGRST_DB_SCHEMA = "alew_2022_05"; # alew_2023_09 for most recent (beta) @@ -34,8 +39,8 @@ in # $ rsync -rav --delete . ful:/var/lib/alew --exclude .git --exclude .nuxt --exclude node_modules systemd.services.alew = { enable = true; - wantedBy = ["multi-user.target"]; - wants = ["postgrest.service"]; + wantedBy = [ "multi-user.target" ]; + wants = [ "postgrest.service" ]; path = [ pkgs.yarn pkgs.python3 @@ -45,7 +50,7 @@ in pkgs.gnumake ]; environment = { - NODE_OPTIONS= "--openssl-legacy-provider"; + NODE_OPTIONS = "--openssl-legacy-provider"; POSTGREST_URL = "http://localhost:${toString postgrestPort}"; BETA = "0"; PORT = toString alewPort; @@ -70,13 +75,13 @@ in group = "alew"; }; - users.extraGroups.alew = {}; + users.extraGroups.alew = { }; - environment.systemPackages = [pkgs.podman]; + environment.systemPackages = [ pkgs.podman ]; services.postgresql = { enable = true; - ensureDatabases = ["alew"]; + ensureDatabases = [ "alew" ]; ensureUsers = [ { name = "alew"; diff --git a/systems/ful/configuration.nix b/systems/ful/configuration.nix index 2bdc7aa..896780f 100644 --- a/systems/ful/configuration.nix +++ b/systems/ful/configuration.nix @@ -3,7 +3,8 @@ pkgs, lib, ... -}: { +}: +{ imports = [ ./hardware-configuration.nix ./matomo.nix @@ -27,8 +28,7 @@ niveum.passport = { enable = true; - introductionHTML = '' - ''; + introductionHTML = ''''; virtualHost = "ful.r"; services = [ @@ -70,7 +70,10 @@ }; networking = { - firewall.allowedTCPPorts = [80 443]; + firewall.allowedTCPPorts = [ + 80 + 443 + ]; hostName = "ful"; interfaces.enp0s3.useDHCP = true; retiolum = pkgs.lib.niveum.retiolumAddresses.ful; @@ -95,7 +98,12 @@ users.users.root.hashedPasswordFile = config.age.secrets.root.path; - environment.systemPackages = [pkgs.vim pkgs.git pkgs.tmux pkgs.python3]; + environment.systemPackages = [ + pkgs.vim + pkgs.git + pkgs.tmux + pkgs.python3 + ]; # since 22.05 timeout fails? # systemd.services.systemd-networkd-wait-online.enable = false; diff --git a/systems/ful/go-webring.nix b/systems/ful/go-webring.nix index 7f57d05..2c73f18 100644 --- a/systems/ful/go-webring.nix +++ b/systems/ful/go-webring.nix @@ -9,8 +9,14 @@ in listenAddress = "127.0.0.1:${toString port}"; package = pkgs.go-webring; members = [ - { username = "meteora"; site = "meteora.xn--kiern-0qa.de"; } - { username = "huldra"; site = "huldras-halbtraum.com"; } + { + username = "meteora"; + site = "meteora.xn--kiern-0qa.de"; + } + { + username = "huldra"; + site = "huldras-halbtraum.com"; + } ]; homePageTemplate = '' diff --git a/systems/ful/hardware-configuration.nix b/systems/ful/hardware-configuration.nix index 392a48d..82d8faf 100644 --- a/systems/ful/hardware-configuration.nix +++ b/systems/ful/hardware-configuration.nix @@ -4,7 +4,8 @@ pkgs, modulesPath, ... -}: { +}: +{ imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; @@ -18,7 +19,10 @@ efi.canTouchEfiVariables = true; }; initrd = { - availableKernelModules = ["virtio_pci" "usbhid"]; + availableKernelModules = [ + "virtio_pci" + "usbhid" + ]; }; kernelModules = [ "console=ttyS0" @@ -26,7 +30,7 @@ "nvme.shutdown_timeout=10" "libiscsi.debug_libiscsi_eh=1" ]; - extraModulePackages = []; + extraModulePackages = [ ]; }; fileSystems."/" = { @@ -39,5 +43,5 @@ fsType = "vfat"; }; - swapDevices = []; + swapDevices = [ ]; } diff --git a/systems/ful/hledger.nix b/systems/ful/hledger.nix index 7311f87..81c8474 100644 --- a/systems/ful/hledger.nix +++ b/systems/ful/hledger.nix @@ -2,7 +2,8 @@ config, pkgs, ... -}: { +}: +{ services.hledger-web = { enable = true; allow = "edit"; @@ -16,8 +17,8 @@ systemd.services.hledger-backup = { enable = false; startAt = "hourly"; - wants = ["network-online.target"]; - wantedBy = ["multi-user.target"]; + wants = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; script = '' ${pkgs.git}/bin/git config user.name "hledger-web" ${pkgs.git}/bin/git config user.email "hledger-web@${config.networking.hostName}" diff --git a/systems/ful/matomo.nix b/systems/ful/matomo.nix index 5a24838..fb88892 100644 --- a/systems/ful/matomo.nix +++ b/systems/ful/matomo.nix @@ -1,4 +1,5 @@ -{pkgs, lib, ...}: { +{ pkgs, lib, ... }: +{ services.nginx = { enable = true; recommendedGzipSettings = true; @@ -25,7 +26,7 @@ services.mysql = { enable = true; package = pkgs.mariadb; - ensureDatabases = ["matomo"]; + ensureDatabases = [ "matomo" ]; ensureUsers = [ { name = "matomo"; @@ -36,6 +37,6 @@ services.mysqlBackup = { enable = true; - databases = ["matomo"]; + databases = [ "matomo" ]; }; } diff --git a/systems/ful/panoptikon.nix b/systems/ful/panoptikon.nix index 4ee66a1..425d92e 100644 --- a/systems/ful/panoptikon.nix +++ b/systems/ful/panoptikon.nix @@ -3,16 +3,18 @@ pkgs, lib, ... -}: let +}: +let irc-xxx = pkgs.lib.panoptikon.kpaste-irc { target = lib.escapeShellArg "#xxx"; retiolumLink = true; }; - matrix = { - server ? "matrix.4d2.org", - target, - }: + matrix = + { + server ? "matrix.4d2.org", + target, + }: pkgs.writers.writeDash "matrix-reporter" '' export RAW_MESSAGE="$(cat)" export MESSAGE=$(printf '%s
%s
' "$PANOPTIKON_WATCHER" "$RAW_MESSAGE") @@ -26,9 +28,10 @@ matrix-kmein = matrix { target = "!zlwCuPiCNMSxDviFzA:4d2.org"; }; - telegram-kmein = let - chatId = "-1001796440545"; - in + telegram-kmein = + let + chatId = "-1001796440545"; + in pkgs.writers.writeDash "telegram-fulltext" '' export TOKEN="$(cat "$CREDENTIALS_DIRECTORY/token")" ${pkgs.curl}/bin/curl -X POST "https://api.telegram.org/bot''${TOKEN}/sendMessage" \ @@ -43,7 +46,8 @@ nick = "panoptikon-kmein"; retiolumLink = false; }; -in { +in +{ age.secrets.telegram-token-kmein.file = ../../secrets/telegram-token-kmein.age; age.secrets.matrix-token-lakai = { file = ../../secrets/matrix-token-lakai.age; @@ -64,83 +68,86 @@ in { } ''; } "https://api.github.com/meta"; - reporters = [irc-xxx]; + reporters = [ irc-xxx ]; }; lammla = { script = pkgs.lib.panoptikon.url "http://lammla.info/index.php?reihe=30"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; kratylos = { script = pkgs.lib.panoptikon.url "https://kratylos.reichert-online.org/current_issue/KRATYLOS"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; kobudo-tesshinkan = { script = pkgs.lib.panoptikon.url "https://kobudo-tesshinkan.eu/index.php/de/termine-berichte/lehrgaenge/"; - reporters = [telegram-kmein matrix-kmein]; + reporters = [ + telegram-kmein + matrix-kmein + ]; }; zeno-free = { script = pkgs.lib.panoptikon.urlSelector ".zenoCOMain" "http://www.zeno.org/Lesesaal/M/E-Books"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; carolinawelslau = { script = pkgs.lib.panoptikon.urlSelector "#main" "https://carolinawelslau.de/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; humboldt-preis = { script = pkgs.lib.panoptikon.urlSelector "#content-core" "https://www.hu-berlin.de/de/ueberblick/menschen/ehrungen/humboldtpreis"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; lisalittmann = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://lisalittmann.de/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; lisalittmann-archive = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://lisalittmann.de/archive/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; lisalittmann-projects = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://lisalittmann.de/projects/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; tatort = { script = pkgs.lib.panoptikon.urlSelector ".linklist" "https://www.daserste.de/unterhaltung/krimi/tatort/sendung/index.html"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; warpgrid-idiomarium = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://warpgrid.de/idiomarium/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; warpgrid-futurism = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://warpgrid.de/futurism/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; warpgrid-imagiary = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://warpgrid.de/imagiary/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; warpgrid-alchemy = { script = pkgs.lib.panoptikon.urlSelector "#site-content" "https://warpgrid.de/alchemy/"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; indogermanische-forschungen = { script = pkgs.lib.panoptikon.urlSelector "#latestIssue" "https://www.degruyter.com/journal/key/INDO/html"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; ig-neuigkeiten = { script = pkgs.lib.panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/aktuelles/neuigkeiten.html"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; ig-tagungen = { script = pkgs.lib.panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/tagungen/tagungen-der-ig.html"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; fu-distant = { script = pkgs.lib.panoptikon.urlSelector "#current_events" "https://www.geschkult.fu-berlin.de/en/e/ma-distant/Termine/index.html"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; fu-aegyptologie = { script = pkgs.lib.panoptikon.urlSelector "#current_events" "https://www.geschkult.fu-berlin.de/e/aegyptologie/termine/index.html"; - reporters = [matrix-kmein]; + reporters = [ matrix-kmein ]; }; }; }; diff --git a/systems/ful/radio.nix b/systems/ful/radio.nix index 5a69e8a..9e651cd 100644 --- a/systems/ful/radio.nix +++ b/systems/ful/radio.nix @@ -3,7 +3,8 @@ config, lib, ... -}: let +}: +let liquidsoapDirectory = "/var/cache/liquidsoap"; icecastPassword = "hackme"; refresh-qasaid = pkgs.writers.writeDashBin "refresh-qasaid" '' @@ -25,10 +26,12 @@ ''; qasida-poem = pkgs.writers.writeDash "qasida.sh" '' set -efu - ${pkgs.jq}/bin/jq -c '.[]' < ${pkgs.fetchurl { - url = "https://c.krebsco.de/qasaid.json"; - sha256 = "0vh1jzdrvjrdyq7dzya9k9g3jyli9jr0zfsqb2m1phm39psy4g2b"; - }} \ + ${pkgs.jq}/bin/jq -c '.[]' < ${ + pkgs.fetchurl { + url = "https://c.krebsco.de/qasaid.json"; + sha256 = "0vh1jzdrvjrdyq7dzya9k9g3jyli9jr0zfsqb2m1phm39psy4g2b"; + } + } \ | shuf -n1 \ | ${pkgs.jq}/bin/jq -r '"annotate:title=\"\(.poem) | https://www.hindawi.org/poems/\(.id)/\",artist=\"\(.author)\":https://downloads.hindawi.org/poems/\(.id)/\(.id).m4a"' ''; @@ -94,7 +97,8 @@ "$(${pkgs.htmlq}/bin/htmlq -f "$html" --text h1)" \ "$opus" ''; -in { +in +{ # https://github.com/savonet/liquidsoap/issues/1043#issuecomment-593354427 services.liquidsoap.streams.radio = pkgs.writeText "lyrikline.liq" '' set("protocol.external.curl","${pkgs.torsocks}/bin/torsocks ${pkgs.curl}/bin/curl") @@ -124,14 +128,14 @@ in { systemd.services.radio = { environment.TMPDIR = liquidsoapDirectory; - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; serviceConfig = { RuntimeMaxSec = "${toString (5 * 60 * 60)}s"; Restart = "always"; }; }; - environment.systemPackages = [refresh-qasaid]; + environment.systemPackages = [ refresh-qasaid ]; systemd.tmpfiles.rules = [ (pkgs.lib.niveum.tmpfilesConfig { diff --git a/systems/kabsa/configuration.nix b/systems/kabsa/configuration.nix index b74703d..f86a533 100644 --- a/systems/kabsa/configuration.nix +++ b/systems/kabsa/configuration.nix @@ -3,7 +3,8 @@ pkgs, lib, ... -}: { +}: +{ imports = [ ../kibbeh/hardware-configuration.nix ../../configs/tlp.nix @@ -43,11 +44,11 @@ wireguard-aether-psk.file = ../../secrets/kabsa-wireguard-aether-psk.age; }; - environment.systemPackages = [pkgs.zeroad]; + environment.systemPackages = [ pkgs.zeroad ]; networking = { hostName = "kabsa"; - wireless.interfaces = ["wlp3s0"]; + wireless.interfaces = [ "wlp3s0" ]; retiolum = pkgs.lib.niveum.retiolumAddresses.kabsa; }; diff --git a/systems/kabsa/hardware-configuration.nix b/systems/kabsa/hardware-configuration.nix index 3d12e08..83c5764 100644 --- a/systems/kabsa/hardware-configuration.nix +++ b/systems/kabsa/hardware-configuration.nix @@ -4,17 +4,25 @@ pkgs, modulesPath, ... -}: { - imports = [(modulesPath + "/installer/scan/not-detected.nix")]; +}: +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; boot = { initrd = { - availableKernelModules = ["ehci_pci" "ahci" "xhci_pci" "usb_storage" "sd_mod" "sdhci_pci"]; + availableKernelModules = [ + "ehci_pci" + "ahci" + "xhci_pci" + "usb_storage" + "sd_mod" + "sdhci_pci" + ]; luks.devices."luksmap".device = "/dev/disk/by-uuid/03b6abd0-e9ce-49c8-9659-a1d94f645d0f"; - kernelModules = []; + kernelModules = [ ]; }; - kernelModules = ["kvm-intel"]; - extraModulePackages = []; + kernelModules = [ "kvm-intel" ]; + extraModulePackages = [ ]; loader = { efi.canTouchEfiVariables = true; systemd-boot = { @@ -37,7 +45,7 @@ "/mnt/sd-card" = { device = "/dev/disk/by-id/mmc-5E4S5_0xc5155d05-part1"; fsType = "ext4"; - options = ["nofail"]; + options = [ "nofail" ]; }; }; diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index 205fb35..76bcbe0 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -3,7 +3,8 @@ config, pkgs, ... -}: { +}: +{ imports = [ ./gitea.nix ./hardware-configuration.nix @@ -77,7 +78,10 @@ }; networking = { - firewall.allowedTCPPorts = [80 443]; + firewall.allowedTCPPorts = [ + 80 + 443 + ]; hostName = "makanek"; interfaces.ens3.useDHCP = true; retiolum = pkgs.lib.niveum.retiolumAddresses.makanek; @@ -122,17 +126,17 @@ locations."/" = { root = "/var/www/kmein.de"; extraConfig = '' - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization'; + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization'; - # Handle preflight requests - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization'; - return 204; # No Content - } + # Handle preflight requests + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization'; + return 204; # No Content + } ''; }; }; diff --git a/systems/makanek/gitea.nix b/systems/makanek/gitea.nix index 043d344..d4ef9bd 100644 --- a/systems/makanek/gitea.nix +++ b/systems/makanek/gitea.nix @@ -1,21 +1,26 @@ { config, pkgs, ... }: let domain = "code.kmein.de"; -in { +in +{ services.anubis = { defaultOptions.settings = { USER_DEFINED_DEFAULT = true; }; - instances = let instance = "gitea"; in { - ${instance}.settings = { - BIND = "/run/anubis/anubis-${instance}/anubis.sock"; - METRICS_BIND = "/run/anubis/anubis-${instance}/anubis-metrics.sock"; - TARGET = "http://localhost:${toString config.services.gitea.settings.server.HTTP_PORT}"; - USER_DEFINED_INSTANCE = true; - OG_PASSTHROUGH = true; - SERVE_ROBOTS_TXT = true; + instances = + let + instance = "gitea"; + in + { + ${instance}.settings = { + BIND = "/run/anubis/anubis-${instance}/anubis.sock"; + METRICS_BIND = "/run/anubis/anubis-${instance}/anubis-metrics.sock"; + TARGET = "http://localhost:${toString config.services.gitea.settings.server.HTTP_PORT}"; + USER_DEFINED_INSTANCE = true; + OG_PASSTHROUGH = true; + SERVE_ROBOTS_TXT = true; + }; }; - }; }; users.users.nginx.extraGroups = [ config.services.anubis.instances."gitea".group ]; @@ -39,7 +44,9 @@ in { proxyPass = "http://unix:${config.services.anubis.instances."gitea".settings.BIND}"; proxyWebsockets = true; }; - "/metrics".proxyPass = "http://unix:${config.services.anubis.instances."gitea".settings.METRICS_BIND}"; + "/metrics".proxyPass = "http://unix:${ + config.services.anubis.instances."gitea".settings.METRICS_BIND + }"; }; }; diff --git a/systems/makanek/hardware-configuration.nix b/systems/makanek/hardware-configuration.nix index ad132fc..aaec95c 100644 --- a/systems/makanek/hardware-configuration.nix +++ b/systems/makanek/hardware-configuration.nix @@ -4,19 +4,26 @@ pkgs, modulesPath, ... -}: { - imports = [(modulesPath + "/profiles/qemu-guest.nix")]; +}: +{ + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; boot = { initrd = { - availableKernelModules = ["ata_piix" "virtio_pci" "xhci_pci" "sd_mod" "sr_mod"]; - kernelModules = []; + availableKernelModules = [ + "ata_piix" + "virtio_pci" + "xhci_pci" + "sd_mod" + "sr_mod" + ]; + kernelModules = [ ]; }; - kernelModules = []; - extraModulePackages = []; + kernelModules = [ ]; + extraModulePackages = [ ]; loader.grub = { enable = true; - devices = ["/dev/sda"]; + devices = [ "/dev/sda" ]; configurationLimit = 3; }; }; @@ -26,7 +33,7 @@ fsType = "ext4"; }; - swapDevices = []; + swapDevices = [ ]; zramSwap.enable = true; nix.settings.max-jobs = lib.mkDefault 2; diff --git a/systems/makanek/hedgedoc.nix b/systems/makanek/hedgedoc.nix index d9c848b..b0bc3a2 100644 --- a/systems/makanek/hedgedoc.nix +++ b/systems/makanek/hedgedoc.nix @@ -3,11 +3,13 @@ pkgs, lib, ... -}: let +}: +let backupLocation = "/var/lib/codimd-backup"; stateLocation = "/var/lib/codimd/state.sqlite"; domain = "pad.kmein.de"; -in { +in +{ services.nginx.virtualHosts.${domain} = { enableACME = true; forceSSL = true; @@ -18,17 +20,20 @@ in { }; security.acme.certs.${domain}.group = "hedgecert"; - users.groups.hedgecert.members = ["codimd" "nginx"]; + users.groups.hedgecert.members = [ + "codimd" + "nginx" + ]; security.dhparams = { enable = true; - params.hedgedoc = {}; + params.hedgedoc = { }; }; services.hedgedoc = { enable = true; settings = { - allowOrigin = [domain]; + allowOrigin = [ domain ]; allowAnonymous = true; allowGravatar = false; allowFreeURL = true; @@ -40,7 +45,7 @@ in { domain = domain; useSSL = true; protocolUseSSL = true; - sslCAPath = ["/etc/ssl/certs/ca-certificates.crt"]; + sslCAPath = [ "/etc/ssl/certs/ca-certificates.crt" ]; sslCertPath = "/var/lib/acme/${domain}/cert.pem"; sslKeyPath = "/var/lib/acme/${domain}/key.pem"; dhParamPath = config.security.dhparams.params.hedgedoc.path; @@ -70,7 +75,7 @@ in { script = '' ${pkgs.sqlite}/bin/sqlite3 -json ${stateLocation} "select shortid, alias, ownerId, content from Notes" \ | ${ - pkgs.writers.writePython3 "hedgedoc-json-to-fs.py" {} '' + pkgs.writers.writePython3 "hedgedoc-json-to-fs.py" { } '' import json import pathlib import sys diff --git a/systems/makanek/horoscopy.nix b/systems/makanek/horoscopy.nix index c889a55..49d5c36 100644 --- a/systems/makanek/horoscopy.nix +++ b/systems/makanek/horoscopy.nix @@ -2,7 +2,8 @@ pkgs, lib, ... -}: let +}: +let port = 5040; punkt = pkgs.fetchzip { url = "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/tokenizers/punkt.zip"; @@ -14,10 +15,11 @@ hash = "sha256-KBAbCvayTEr4+cOHnMXHCBA+8RWDMiQF65xzP4fOdaE="; }; horoscopy = import horoscopy-src; -in { +in +{ systemd.services.horoscopy = { - wants = ["network-online.target"]; - wantedBy = ["multi-user.target"]; + wants = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; description = "AI astrologer"; serviceConfig = { DynamicUser = true; diff --git a/systems/makanek/matterbridge.nix b/systems/makanek/matterbridge.nix index b373449..cc4cca2 100644 --- a/systems/makanek/matterbridge.nix +++ b/systems/makanek/matterbridge.nix @@ -2,52 +2,58 @@ pkgs, lib, ... -}: { +}: +{ services.matterbridge = { enable = false; - configPath = let - bridgeBotToken = lib.strings.fileContents ; - in - toString ((pkgs.formats.toml {}).generate "config.toml" { - general = { - RemoteNickFormat = "[{NICK}] "; - Charset = "utf-8"; - }; - telegram.krebs.Token = bridgeBotToken; - irc = let - Nick = "ponte"; - in { - hackint = { - Server = "irc.hackint.org:6697"; - UseTLS = true; - inherit Nick; + configPath = + let + bridgeBotToken = lib.strings.fileContents ; + in + toString ( + (pkgs.formats.toml { }).generate "config.toml" { + general = { + RemoteNickFormat = "[{NICK}] "; + Charset = "utf-8"; }; - }; - mumble.lassulus = { - Server = "lassul.us:64738"; - Nick = "krebs_bridge"; - SkipTLSVerify = true; - }; - gateway = [ - { - name = "krebs-bridge"; - enable = true; - inout = [ - { - account = "irc.hackint"; - channel = "#krebs"; - } - { - account = "telegram.krebs"; - channel = "-330372458"; - } - { - account = "mumble.lassulus"; - channel = 6; # "nixos" - } - ]; - } - ]; - }); + telegram.krebs.Token = bridgeBotToken; + irc = + let + Nick = "ponte"; + in + { + hackint = { + Server = "irc.hackint.org:6697"; + UseTLS = true; + inherit Nick; + }; + }; + mumble.lassulus = { + Server = "lassul.us:64738"; + Nick = "krebs_bridge"; + SkipTLSVerify = true; + }; + gateway = [ + { + name = "krebs-bridge"; + enable = true; + inout = [ + { + account = "irc.hackint"; + channel = "#krebs"; + } + { + account = "telegram.krebs"; + channel = "-330372458"; + } + { + account = "mumble.lassulus"; + channel = 6; # "nixos" + } + ]; + } + ]; + } + ); }; } diff --git a/systems/makanek/menstruation.nix b/systems/makanek/menstruation.nix index 0b45260..07c5d3c 100644 --- a/systems/makanek/menstruation.nix +++ b/systems/makanek/menstruation.nix @@ -4,15 +4,17 @@ lib, inputs, ... -}: let +}: +let backendPort = 8000; -in { +in +{ services.redis.servers.menstruation = { enable = true; port = 6379; }; - environment.systemPackages = [pkgs.redis]; + environment.systemPackages = [ pkgs.redis ]; niveum.passport.services = [ { @@ -28,7 +30,7 @@ in { "menstruation-backend.service" "redis-menstruation.service" ]; - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; environment = { MENSTRUATION_ENDPOINT = "http://localhost:${toString backendPort}"; MENSTRUATION_MODERATORS = "18980945"; @@ -50,7 +52,7 @@ in { age.secrets.telegram-token-menstruation.file = ../../secrets/telegram-token-menstruation.age; systemd.services.menstruation-backend = { - wants = ["network-online.target"]; + wants = [ "network-online.target" ]; environment.ROCKET_PORT = toString backendPort; serviceConfig = { Restart = "always"; diff --git a/systems/makanek/moinbot.nix b/systems/makanek/moinbot.nix index 8bbb41e..8880ed0 100644 --- a/systems/makanek/moinbot.nix +++ b/systems/makanek/moinbot.nix @@ -1,7 +1,8 @@ { pkgs, ... -}: { +}: +{ systemd.services.moinbot = { startAt = "7:00"; script = '' diff --git a/systems/makanek/monitoring/blackbox.nix b/systems/makanek/monitoring/blackbox.nix index 2ad59f0..7c08146 100644 --- a/systems/makanek/monitoring/blackbox.nix +++ b/systems/makanek/monitoring/blackbox.nix @@ -8,7 +8,10 @@ method = "GET"; no_follow_redirects = false; preferred_ip_protocol = "ip4"; - valid_http_versions = ["HTTP/1.1" "HTTP/2.0"]; + valid_http_versions = [ + "HTTP/1.1" + "HTTP/2.0" + ]; tls_config.insecure_skip_verify = true; }; prober = "http";